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
105 changes: 102 additions & 3 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,113 @@
import React, { Component } from 'react';
import Idcard from './components/Idcard'
import Greetings from './components/Greeting'
import Random from './components/Random'
import BoxColor from './components/BoxColor'
import CreditCard from './components/CreditCards'
import Rating from './components/Rating'
import DriverCard from './components/DriverCard'
import LikeButton from './components/LikeButton'
import ClickablePicture from './components/ClickablePicture'

class App extends Component {
render() {
return (
<div className="App">
<h1>IdCard</h1>
{/* TODO: Use the IdCard component */}


<Idcard
lastName='Doe'
firstName='John'
gender='male'
height={178}
birth={new Date("1992-07-14").toString()}
picture="https://randomuser.me/api/portraits/men/44.jpg"
/>
<Idcard
lastName='Delores '
firstName='Obrien'
gender='female'
height={172}
birth={new Date("1988-05-11").toString()}
picture="https://randomuser.me/api/portraits/women/44.jpg"
/>

<h1>Greetings</h1>
{/* TODO: Use the Greetings component */}
<Greetings lang="de">Hallo Ludwig</Greetings>
<Greetings lang="fr">Bonjour François</Greetings>

<h1>Random</h1>
<Random min={1} max={6}/>
<Random min={1} max={100}/>

<h1>Colors</h1>
<BoxColor r={255} g={0} b={0} />
<BoxColor r={128} g={255} b={0} />

<h1>Credit Card</h1>

<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" />

<h1>Rating</h1>
<Rating>0</Rating>
<Rating>1.49</Rating>
<Rating>1.5</Rating>
<Rating>3</Rating>
<Rating>4</Rating>
<Rating>5</Rating>

<h1> Driver Cards</h1>
<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"
}} />

<h1>Likes</h1>
<LikeButton/><LikeButton/>

<h1>clickable picture</h1>
<ClickablePicture
img="/img/persons/maxence.png"
imgClicked="/img/persons/maxence-glasses.png"/>

</div>
);
}
Expand Down
16 changes: 16 additions & 0 deletions src/components/BoxColor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React, { Component } from 'react'

const BoxColor = (props) => {
const a = `rgb(${props.r}, ${props.g}, ${props.b}`;
const divStyle =
{backgroundColor: a};

return (
<div className="pepe" style={divStyle}>

</div>
)

}

export default BoxColor;
24 changes: 24 additions & 0 deletions src/components/ClickablePicture.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React, { Component } from 'react'

class ClickablePicture extends Component {
state = {
pictureClicked: this.props.img
}

picture = () => {
let picture = (this.state.pictureClicked === this.props.img) ? this.props.imgClicked : this.props.img;
this.setState({
pictureClicked: picture
})

};

render() {
return (
<img onClick={this.picture} src={this.state.pictureClicked} alt=""/>
)
}
};


export default ClickablePicture;
17 changes: 17 additions & 0 deletions src/components/CreditCards.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React, { Component } from 'react'

const CreditCards = (props) => {
const {type, number, expirationYear, expirationMonth, bank, owner, bgColor, color} = props;
const divStyle =
{backgroundColor: bgColor, color: color};
return (
<div style={divStyle}>
<p>{type}</p>
<p>{number}</p>
<p>Expires {expirationMonth}/{expirationYear} {bank}</p>
<p>{owner}</p>
</div>
)
}

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

const DriverCard= (props) => {
console.log(props.car)
return (
<div className="container">
<img src={props.img} alt=""/>
<p>{props.name}</p>
<Rating> {props.rating}</Rating>
<p>{props.car.model}, {props.car.licensePlate} </p>
</div>
)
}
export default DriverCard;
11 changes: 11 additions & 0 deletions src/components/Greeting.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react'

const Greeting = (props) => {
return (
<div>
<p>{props.children}</p>
</div>
)
}

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

const Idcard = (props) => {

return (
<div>
<p>{props.lastName}</p>
<p>{props.firstName}</p>
<p>{props.gender}</p>
<p>{props.height}</p>
<p>{props.birth}</p>
<img src={props.picture} alt=""/>
</div>
)

}

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

class LikeButton extends Component {
state = {
number: 0
}

like = () => {
let num = this.state.number;
this.setState({
number: ++num
})
console.log(num)
};

render() {
return (
<button onClick={this.like} > {this.state.number} Likes</button>
)
}
};

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

const Random = (props) => {
const random = () => {
return Math.floor(Math.random()*(props.max - props.min) + props.min)}
return (

<div>
<p>Random value between {props.min} and {props.max} => {random()}</p>
</div>
)
}

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

const Rating = (props) => {
let stars = '';
for (let index = 0; index < 5; index++) {
(Math.round(props.children) <= index) ? stars += '☆' : stars += '★';
}

return (
<div>
<p>{stars}</p>
</div>
)
}

export default Rating;
13 changes: 13 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,16 @@ code {
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
monospace;
}

div.pepe {
height: 100px;
width: 100px;
}

img {
max-width: 150px;
}

.container{
background:teal;
}
Loading