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
10 changes: 10 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
.App {
text-align: center;
display: flex;
flex-flow: column;
justify-content: center;
align-items: center;
}

.App-logo {
Expand Down Expand Up @@ -36,3 +40,9 @@
transform: rotate(360deg);
}
}

.creditCard {
display: flex;
flex-direction: row;
padding: 5rem, 5rem;
}
157 changes: 142 additions & 15 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,152 @@
import logo from './logo.svg';
import React from 'react';
// import logo from './logo.svg';
import './App.css';
import IdCard from './components/IdCard/IdCard'
import Greeting from './components/Greetings/Greetings';
import Random from './components/Random/Random';
import BoxColor from './components/BoxColor/BoxColor';
import CreditCard from './components/CreditCard/CreditCard';
import Rating from './components/Rating/Rating';
import DriverCard from './components/DriverCard/DriverCard';
import LikeButton from './components/LikeButton/LikeButton';
import ClickablePicture from './components/ClickablePicture/ClickablePicture';
import Dice from './components/Dice/Dice';
import Carousel from './components/Carousel/Carousel';
import NumbersTable from './components/NumbersTable/NumbersTable';
import Facebook from './components/Facebook/Facebook';

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>
<h1> LAB | React Training</h1>
<h4>Iteration 1:</h4>
<IdCard
lastName='Doe'
firstName='John'
gender='male'
height={178}
birth={new Date("1992-07-14")}
picture="https://randomuser.me/api/portraits/men/44.jpg"
/>

<IdCard
lastName='Delores '
firstName='Obrien'
gender='female'
height={172}
birth={new Date("1988-05-11")}
picture="https://randomuser.me/api/portraits/women/44.jpg"
/>

<h4>Iteration 2:</h4>
<Greeting lang="de">Ludwig</Greeting>
<Greeting lang="fr">François</Greeting>

<h4>Iteration 3:</h4>
<Random min={1} max={6}/>
<Random min={1} max={100}/>

<h4>Iteration 4:</h4>
<BoxColor r={255} g={0} b={0} />
<BoxColor r={128} g={255} b={0} />

<h4>Iteration 5:</h4>
<div className='creditCard'>

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

<h4>Iteration 6:</h4>
<Rating>0</Rating>
<Rating>1.49</Rating>
<Rating>1.5</Rating>
<Rating>3</Rating>
<Rating>4</Rating>
<Rating>5</Rating>

<h4>Iteration 7:</h4>
<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"
}}
/>

<h4>Iteration 8:</h4>
<LikeButton />

<h4>Iterarion 9:</h4>
<ClickablePicture
img='maxence.png'
imgClicked='maxence-glasses.png'
/>

<h4>Iterarion 10:</h4>
<Dice />

<h4>Iterarion 11:</h4>
<Carousel
images={[
'https://randomuser.me/api/portraits/women/1.jpg',
'https://randomuser.me/api/portraits/men/1.jpg',
'https://randomuser.me/api/portraits/women/2.jpg',
'https://randomuser.me/api/portraits/men/2.jpg'
]}
/>

<h4>Iterarion 12:</h4>
<NumbersTable limit={12} />

<h4>Iterarion 13 and 14:</h4>
<Facebook />

</div>
);
}

export default App;

Binary file added src/assets/images/mastercard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/visa.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/components/BoxColor/BoxColor.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.BoxColor {
border: 1px solid black;
padding: 5px;
margin: 10px 0;
width: 30rem;
}
14 changes: 14 additions & 0 deletions src/components/BoxColor/BoxColor.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import './BoxColor.css';

function BoxColor({ r, g, b }) {
const color = `rgb(${r}, ${g}, ${b})`;

return (
<div className='BoxColor' style={{ backgroundColor: color }}>
<p>{color}</p>
</div>
);
}

export default BoxColor;
23 changes: 23 additions & 0 deletions src/components/Carousel/Carousel.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React, { useState } from "react";

function Carousel({ images }) {
const [currentIndex, setCurrentIndex] = useState(0);

const changeImageLeft = () => {
setCurrentIndex((prevIndex) => (prevIndex === 0 ? images.length - 1 : prevIndex - 1));
};

const changeImageRight = () => {
setCurrentIndex((prevIndex) => (prevIndex === images.length - 1 ? 0 : prevIndex + 1));
};

return (
<div className="Carousel">
<button className="left" onClick={changeImageLeft}>Left</button>
<img src={images[currentIndex]} alt="Images" />
<button className="right" onClick={changeImageRight}>Right</button>
</div>
);
}

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

function ClickablePicture({ img, imgClicked }) {
const [isClicked, setIsClicked] = useState(false);

const handleClick = () => {
setIsClicked(!isClicked);
};

return (
<div className='ClickablePicture'>
<img src={isClicked ? imgClicked : img} onClick={handleClick} alt="Imagen" />
</div>
);
}

export default ClickablePicture;
19 changes: 19 additions & 0 deletions src/components/CreditCard/CreditCard.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.CreditCard {
padding: 20px;
border-radius: 2%;
margin: 10px;
width: 350px;
}

.cardNumber {
font-size: xx-large;
}

.cardInfo{
text-align: left;
}

.cardLogo{
width: 50px;
margin-left: 250px;
}
18 changes: 18 additions & 0 deletions src/components/CreditCard/CreditCard.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import './CreditCard.css';
import Visa from '../../assets/images/visa.png'
import MasterCard from '../../assets/images/mastercard.png'

function CreditCard({type, number, expirationMonth, expirationYear, bank, owner, bgColor, color}){
const logo = (type === 'Visa') ? Visa : MasterCard;
return (
<div className='CreditCard' style={{backgroundColor: `${bgColor}`, color: `${color}`}}>
<img className='cardLogo' src={logo} alt='Bank logo'/>
<p className='cardNumber'>•••• •••• •••• {number.slice(-4)}</p>
<div className='cardInfo'>Expires {expirationMonth}/{expirationYear}{bank}</div>
<div className='cardInfo'>{owner}</div>
</div>
)
}

export default CreditCard
8 changes: 8 additions & 0 deletions src/components/Dice/Dice.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
img {
width: 100px;
margin-top: 20px;
}

.Dice {
display: block;
}
29 changes: 29 additions & 0 deletions src/components/Dice/Dice.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React, {useState} from "react";
import './Dice.css'
import DiceEmpty from './../../assets/images/dice-empty.png'
import DiceOne from './../../assets/images/dice1.png'
import DiceTwo from './../../assets/images/dice2.png'
import DiceThree from './../../assets/images/dice3.png'
import DiceFour from './../../assets/images/dice4.png'
import DiceFive from './../../assets/images/dice5.png'
import DiceSix from './../../assets/images/dice6.png'

function Dice(){
const [diceChanges, setDiceChanges] = useState(DiceThree)
const dice = [DiceOne, DiceTwo, DiceThree, DiceFour, DiceFive, DiceSix]

const switchDice = () => {
setDiceChanges(DiceEmpty)
setTimeout(() => {
setDiceChanges(dice[Math.floor(Math.random() * dice.length)])
}, 1000)
}

return (
<div className='Dice'>
<img onClick={switchDice} src={diceChanges} alt="Dice" />
</div>
)
}

export default Dice
17 changes: 17 additions & 0 deletions src/components/DriverCard/DriverCard.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.DriverCard {
margin: 10px;
display: flex;
color: white;
background-color: rgb(86, 67, 207);
width: 700px;
border-radius: 10px;
padding: 20px;
text-align: left;
}

.DriverCard img {
width: 8rem;
border-radius: 50%;
margin-left: 100px;
margin-right: 20px;
}
25 changes: 25 additions & 0 deletions src/components/DriverCard/DriverCard.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react';
import './DriverCard.css';

function DriverCard({name, rating, img, car}) {
const roundedRating = Math.round(rating)
const stars = Array.from({ length: 5}, (_, index) => {
if (index < roundedRating) {
return '★';
} else {
return '☆';
}
});
return (
<div className='DriverCard'>
<img className='driverImage' src={img} alt='DriverImage'/>
<div className='DriverInfo'>
<p><br />{name}<br /></p>
<p>{stars}</p>
<div>{`${car.model} - ${car.licensePlate}`}</div>
</div>
</div>
)
}

export default DriverCard
Loading