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
110 changes: 110 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,124 @@
import React, { Component } from 'react';
import IdCard from './components/IdCard';
import Greetings from './components/Greetings';
import Random from './components/Random';
import BoxColor from './components/BoxColor';
import CreditCard from './components/CreditCard';
import Rating from './components/Rating';

class App extends Component {
constructor(props) {
super(props)
this.state = {
dataIdCard: [
{
lastName: 'Doe',
firstName: 'John',
gender: 'male',
height: 178,
birth: `${new Date("1992-07-14").toString().slice(0, 16)}`,
picture: "https://randomuser.me/api/portraits/men/44.jpg"
},
{
lastName: 'Delores ',
firstName: 'Obrien',
gender: 'female',
height: 172,
birth: `${new Date("1988-05-11").toString().slice(0, 16)}`,
picture: "https://randomuser.me/api/portraits/women/44.jpg"
}],
dataGreetings: [
{
lang: "de",
name: "Ludwig"
},
{
lang: "fr",
name: "François"
}],
dataRandom: [
{
max: 1,
min: 6
},
{
max: 1,
min: 100
}],
dataBoxColor: [
{
r: 255,
g: 0,
b: 0
},
{
r: 128,
g: 255,
b: 0
}],
dataCreditCard: [
{
ype: "Visa",
number: "0123456789018845",
expirationMonth: 3,
expirationYear: 2021,
bank: "BNP",
owner: "Maxence Bouret",
bgColor: "#11aa99",
color: "white"
},
{
ype: "Master Card",
number: "0123456789010995",
expirationMonth: 3,
expirationYear: 2021,
bank: "N26",
owner: "Maxence Bouret",
bgColor: "#eeeeee",
color: "222222"
},
{
ype: "Visa",
number: "0123456789016984",
expirationMonth: 12,
expirationYear: 2019,
bank: "Name of the Bank",
owner: "Firstname Lastname",
bgColor: "#ddbb55",
color: "white"
},
],
dataRating: [0, 1.49, 1.5, 3, 4, 5]
};
}

render() {
const {dataIdCard, dataGreetings, dataRandom, dataBoxColor, dataCreditCard, dataRating} = this.state;
return (
<div className="App">
<h1>IdCard</h1>
<IdCard people={dataIdCard} />
{/* TODO: Use the IdCard component */}

<h1>Greetings</h1>
<Greetings gree={dataGreetings} />
{/* TODO: Use the Greetings component */}

<h1>Random</h1>
<Random randomarray={dataRandom} />
{/* TODO: Use the Random component */}

<h1>BoxColor</h1>
<BoxColor boxcolorarray={dataBoxColor} />
{/* TODO: Use the BoxColor component */}

<h1>CreditCard</h1>
<CreditCard creditCardrarray={dataCreditCard} />
{/* TODO: Use the CreditCard component */}

<h1>Rating</h1>
<Rating Ratingarray={dataRating} />
{/* TODO: Use the Rating component */}
</div>
);
}
Expand Down
15 changes: 15 additions & 0 deletions src/components/BoxColor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react'

export default function BoxColor(props) {
return (
<>
{props.boxcolorarray.map((color, index) => {
return (
<div key={index}>
<p>rgb({color.r},{color.g},{color.b})</p>
</div>
)
})}
</>
)
}
18 changes: 18 additions & 0 deletions src/components/CreditCard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react'

export default function CreditCard(params) {
return (
<>
{params.creditCardrarray.map((card,index) => {
return (
<div key={index}>
<p>{card.ype}</p>
<h3>{card.number}</h3>
<p>Expires {card.expirationMonth}/{card.expirationYear} {card.bank}</p>
<p>{card.owner}</p>
</div>
)
})}
</>
)
}
26 changes: 26 additions & 0 deletions src/components/Greetings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react'

export default function Greetings(props) {
return (
<>
{props.gree.map((element, index) => {
return (
<div key={index}>
{element.lang === 'de' &&
<p>Hallo {element.name}</p>
}
{element.lang === 'fr' &&
<p>Bonjour {element.name}</p>
}
{element.lang === 'en' &&
<p>Hello {element.name}</p>
}
{element.lang === 'es' &&
<p>Hola {element.name}</p>
}
</div>
)
})}
</>
)
}
21 changes: 21 additions & 0 deletions src/components/IdCard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react'

export default function IdCard(props) {
return (
<>
{props.people.map((element, index) => {
return (
<div key={index}>
<img src={element.picture} alt=""/>
<p><strong>First name: </strong>{element.firstName}</p>
<p><strong>Last name: </strong>{element.lastName}</p>
<p><strong>Gender: </strong>{element.gender}</p>
<p><strong>Height: </strong>{element.height/100}m</p>
<p>{element.birth}</p>
</div>
)
})}
</>
)
}

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

export default function Random(props) {
return (
<>
{props.randomarray.map((elems, index) => {
return (
<div key={index}>
<p>Random value between {elems.min} and {elems.max} => {Math.floor((Math.random()*(elems.max-elems.min) + elems.min))}</p>
</div>
)
})}
</>
)
}
9 changes: 9 additions & 0 deletions src/components/Rating.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react'

export default function Rating() {
return (
<div>

</div>
)
}