Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37,610 changes: 37,610 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

130 changes: 113 additions & 17 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,121 @@
import React from 'react';
import logo from './logo.svg';

import './App.css';
import BoxColor from './components/BoxColor.component';
import ClickablePicture from './components/ClickablePicture.component';
import CreditCard from './components/CreditCard.component';
import Dice from './components/Dice.component';
import DriverCard from './components/DriverCard.component';
import Greetings from './components/Greetings.component';
import Idcard from './components/Idcard.component';
import LikeButton from './components/LikeButton.component';
import Random from './components/Random.component';
import Rating from './components/Rating.component';






function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
<>
<div className="App">
<h2>Idcard</h2>
<Idcard
lastName="Doe"
firstName="John"
gender="male"
height={178}
birth={new Date('1992-07-14')}
href="https://randomuser.me/api/portraits/men/44.jpg"
/>
<Idcard
lastName="Delores "
firstName="Obrien"
gender="female"
height={172}
birth={new Date('1988-05-11')}
href="https://randomuser.me/api/portraits/women/44.jpg"
/>
<h2>Greetings</h2>
<Greetings lang="de" children="Ludwig" />
<Greetings lang="fr" children="Francois" />
<h2>Random</h2>
<Random min={1} max={6} />
<Random min={1} max={100} />
<h2>BoxColor</h2>
<BoxColor r={255} g={0} b={0} />
<BoxColor r={128} g={255} b={0} />
<h2>CreditCard</h2>
<CreditCard
type="Visa"
number="0123456789018845"
expirationMonth={3}
expirationYear={2021}
bank="BNP"
owner="Maxence Bouret"
bgColor="#11aa99"
color="white"
/>
<CreditCard
type="Master Card"
number="0123456789010995"
expirationMonth={3}
expirationYear={2021}
bank="N26"
owner="Maxence Bouret"
bgColor="#eeeeee"
color="#222222"
/>
<CreditCard
type="Visa"
number="0123456789016984"
expirationMonth={12}
expirationYear={2019}
bank="Name of the Bank"
owner="Firstname Lastname"
bgColor="#ddbb55"
color="white"
/>
<h2>Rating</h2>
<Rating>0</Rating>
<Rating>1.49</Rating>
<Rating>1.5</Rating>
<Rating>3</Rating>
<Rating>4</Rating>
<Rating>5</Rating>
<h2>Driver Card</h2>
<DriverCard
name="Travis Kalanick"
rating={4.2}
img="https://si.wsj.net/public/resources/images/BN-TY647_37gql_OR_20170621052140.jpg?width=620&height=428"
car={{
model: 'Toyota Corolla Altis',
licensePlate: 'CO42DE',
}}
/>
<DriverCard
name="Dara Khosrowshahi"
rating={4.9}
img="https://ubernewsroomapi.10upcdn.com/wp-content/uploads/2017/09/Dara_ELT_Newsroom_1000px.jpg"
car={{
model: 'Audi A3',
licensePlate: 'BE33ER',
}}
/>
<h2>Like button</h2>
<LikeButton />
<h2>Clickable Picture</h2>
<ClickablePicture
img="/img/persons/maxence.png"
imgClicked="/img/persons/maxence-glasses.png"
/>
<h2>Dice</h2>

<Dice></Dice>
</div>
</>
);
}

Expand Down
17 changes: 17 additions & 0 deletions src/components/BoxColor.component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react'
import '../styles/styles.css';

function BoxColor(props) {
return (
<div
className="box-color"
style={{ backgroundColor: `rgb(${props.r}, ${props.g}, ${props.b}`}}
>
<span>
rgb ({props.r}, {props.g}, {props.b})
</span>
</div>
);
}

export default BoxColor
29 changes: 29 additions & 0 deletions src/components/ClickablePicture.component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from "react";


class ClickablePicture extends React.Component {

constructor(props) {
super(props)
this.img = props.img
this.imgClicked = props.imgClicked
}


state = {
clicked: false
}

changeState = () => {
this.setState({
clicked: !this.state.clicked
})
}

render(){
return <img onClick={this.changeState} src={this.state.clicked ? this.imgClicked : this.img} alt=""/>
}
}


export default ClickablePicture;
20 changes: 20 additions & 0 deletions src/components/CreditCard.component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react'

function CreditCard(props) {
return (
<div className="credit-card" style={{ backgroundColor: props.bgColor, color: props.color }}>
<h3>{props.type}</h3>
<p className="number-card">
**** **** **** {props.number.substr(12, 14)}
</p>
<div className="atributes">
<span>
Expires : {props.expirationMonth} / {props.expirationYear}
</span> <br></br>
<span>{props.owner}</span>
</div>
</div>
);
}

export default CreditCard
51 changes: 51 additions & 0 deletions src/components/Dice.component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import React from 'react';


class Dice extends React.Component {
constructor(props) {
super(props);
this.initialDice = '/img/dice-empty.png';
this.images = [

'/img/dice1.png',
'/img/dice2.png',
'/img/dice3.png',
'/img/dice4.png',
'/img/dice5.png',
'/img/dice6.png',
];


this.state = {
imageUrl: this.initialDice,
};
}


setEmpty =() => {
this.setState({
imageUrl: this.initialDice,
});
}

changeState = () => {
this.setEmpty()

setTimeout(() => {
this.setState({
imageUrl: this.images[Math.floor(Math.random() * (5 - 0 + 1))],
});
}, 1000);
}


render(){
return (
<div class="dice-div">
<img onClick={this.changeState} src={this.state.imageUrl} alt="" />
</div>
);
}

}
export default Dice;
19 changes: 19 additions & 0 deletions src/components/DriverCard.component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react'
import Rating from './Rating.component'

function DriverCard(props) {
return (
<div className="driver-card" style={{ backgroundColor: '#455eb5' }}>
<img src={props.img} alt=""></img>
<div className="info-card">
<h3>{props.name}</h3>
<Rating>{props.rating}</Rating>
<p>
{props.car.model}- {props.car.licensePlate}
</p>
</div>
</div>
);
}

export default DriverCard
27 changes: 27 additions & 0 deletions src/components/Greetings.component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react'

function Greetings(props) {
let text;
if (props.lang === 'es') {
text = 'Hola';
}
if (props.lang === 'fr') {
text = 'Bonjour';
}
if (props.lang === 'de') {
text = 'Halo';
}
if (props.lang === 'en') {
text = 'Hello';
}

return (
<div className="greeting-card" >
<p>
{text} {props.children}
</p>
</div>
);
}

export default Greetings
30 changes: 30 additions & 0 deletions src/components/Idcard.component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react'
import '../styles/styles.css'

function Idcard(props) {
return (

<div className="idCard">

<img src={props.href} alt=""></img>
<div className="content">
<strong>First Name: </strong>
{props.firstName} <br></br>
<strong>Last Name :</strong>
{props.lastName} <br></br>
<strong>Gender: </strong>
{props.gender}
<br></br>
<strong>Height</strong>
{props.height}
<br></br>
<strong>Birth:</strong>
{props.birth.toDateString()}
<br></br>
</div>
</div>

);
}

export default Idcard
35 changes: 35 additions & 0 deletions src/components/LikeButton.component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react'
// import{ useState } from 'react';

class LikeButton extends React.Component {
state = {
counter: 0,
color: ['purple', 'blue', 'green', 'yellow', 'orange', 'red'],
ref : 0
};


changeState = () => {

this.setState({
counter: this.state.counter +1,
ref: Math.floor(Math.random() * (5 - 0 + 1) ),
});
}

render() {
return (
<div>
<button
style={{ backgroundColor: this.state.color[this.state.ref] }}
onClick={this.changeState}
>

{this.state.counter} Likes
</button>
</div>
);
}
}

export default LikeButton
16 changes: 16 additions & 0 deletions src/components/Random.component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react'
import '../styles/styles.css';

function Random(props) {

let number = Math.floor(Math.random() * (props.max - props.min + 1) + props.min);
return (
<div className="random-card">
<p>Random value between {props.min} and {props.max} -- {number}</p>


</div>
)
}

export default Random
Loading