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
84 changes: 84 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,101 @@
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';

class App extends Component {

getGreeting(lang){
// console.log('holaaaaaaaa: ', lang)
switch(lang){
case 'de':
return 'Hallo';
case 'fr':
return 'Bonjour';
case 'en':
return 'Hello';
case 'es':
return 'Hola';
default :
return 'noe xx`x'
}
};

render() {
return (
<div className="App">
<h1>IdCard</h1>
{/* TODO: Use the IdCard component */}
<IdCard
firstName="John"
lastName="Doe"
gender="male"
height="178"
birth="Tue Jul 14 1992"
picture="https://randomuser.me/api/portraits/men/44.jpg" />

<IdCard
firstName="Dolores"
lastName="Obrien"
gender="female"
height="172"
birth="Tue May 11 1993"
picture="https://randomuser.me/api/portraits/women/44.jpg" />

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

<Greetings
lang="es" greeting = {this.getGreeting} children="Ludwig">
</Greetings>

<Greetings
lang="en" greeting = {this.getGreeting} children="François">
</Greetings>

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

<h1> BoxColor</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" />
</div>
);
}
}

export default App;


17 changes: 17 additions & 0 deletions src/components/BoxColor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from "react";
import { convertStringToHex } from '../helpers';

function BoxColor(props){
const { r, g, b } = props;
const hex = convertStringToHex(r,g,b);
const result = {'background-color': convertStringToHex(r,g,b)};

return(
<div style={result}>
<h1>rgb({r},{g},{b})</h1>
<p>{hex}</p>
</div>
);
}

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

function CreditCard(props){
const {type,number,expirationMonth,expirationYear,bank,owner,bgColor,color} = props;
const result = {'background-color': bgColor, 'color': color};

return(
<div className="credit-card" style={result}>
<img src={type === "Visa" ? "/img/visa.png" : "/img/master-card.svg"} align="right" alt="logo-bank"></img>

<div className="number">
•••• •••• •••• {number.slice(-4)}
</div>
<p >

Expires {expirationMonth}/{expirationYear} {bank} <br/>
{owner}
</p>
</div>
);
}

export default CreditCard;
16 changes: 16 additions & 0 deletions src/components/Greetings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from "react";
import "../css/Greetings.css";

function Greetings(props){
return(
<div className="greetings">
<p>
{props.greeting(props.lang)} {props.children}
</p>
</div>
);
}

export default Greetings;


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";
import "../css/IdCard.css";

function IdCard(props){
return(
<div className="id-card">
<div><img src={props.picture} alt="img-id-card"></img></div>
<div>
<ul>
<li><span>First name: </span> {props.firstName}</li>
<li><span>Last name: </span> {props.lastName}</li>
<li><span>Gender: </span> {props.gender}</li>
<li><span>Height: </span> {props.height}</li>
<li><span>Birth: </span>birth: {props.birth}</li>
</ul>
</div>
</div>
);
}

export default IdCard;
16 changes: 16 additions & 0 deletions src/components/Random.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from "react";
import "../css/Random.css";
import { generateRandom } from "../helpers/index";


function Random(props){
const { min, max } = props;
const random = generateRandom(min, max);
return(
<div className='marc'>
<p>Random value between {props.min} and {props.max} => {random}</p>
</div>
);
}

export default Random;
31 changes: 31 additions & 0 deletions src/css/CreditCard.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

div {
display: block;
}

.CreditCard .number {
font-size: 1.9em;
text-align: center;
margin: 20px 0;
}
user agent stylesheet
div {
display: block;
}
.credit-card{
margin: 10px;
padding: 20px;
width: 300px;
border-radius: 10px;
display: inline-block;
}

.credit-card .number {
font-size: 1.9em;
text-align: center;
margin: 20px 0;
}

.credit-card img {
height: 20px;
}
Empty file added src/css/Random.css
Empty file.
12 changes: 12 additions & 0 deletions src/css/greetings.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.greetings{
border: 1em;
box-sizing: border-box;
width: 100%;
border: solid #5B6DCD 5px;
padding: 5px;
margin: 5px;
flex: auto;
display: flex;
flex-direction: row;
}

19 changes: 19 additions & 0 deletions src/css/idCard.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.id-card{
border: 1em;
box-sizing: border-box;
width: 100%;
border: solid #5B6DCD 5px;
padding: 5px;
margin: 5px;
flex: auto;
display: flex;
flex-direction: row;
}

.id-card ul{
list-style-type: none;
}

.id-card ul span{
font-weight: bold;
}
10 changes: 10 additions & 0 deletions src/helpers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const generateRandom = (min, max) => {
return Math.floor(Math.random() * (max - min)) + min;
}

export const convertStringToHex = (r,g,b) => {
let rgb = ''+r+g+b;
let nou = '#'+parseInt(rgb).toString(16);

return nou;
}
14 changes: 14 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,23 @@ body {
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
width: 80%;
margin: 0 auto;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
monospace;
}

.marc{
border: 1em;
box-sizing: border-box;
width: 100%;
border: solid #5B6DCD 5px;
padding: 5px;
margin: 5px;
flex: auto;
display: flex;
flex-direction: row;
}