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
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"@testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"react-scripts": "^5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
Expand Down
151 changes: 136 additions & 15 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,144 @@
import logo from './logo.svg';

import './App.css';

import Idcard from './components/Idcard/Idcard';
import Greetings 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 Clickable from './components/Clickable';

import img from "./assets/images/maxence.png";
import imgClicked from "./assets/images/maxence-glasses.png";
import Dice from './components/Dice';
import Carousel from './components/Carousel/Carousel';
import NumbersTable from './components/NumbersTable/NumbersTable';
import RGBColorPicker from './components/RgbColorPicker';
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>

<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/81.jpg"
/>

<Greetings lang="de">Ludwig</Greetings>

<Greetings lang="fr">François</Greetings>

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

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


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

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

<Rating>0</Rating>

<Rating>1.49</Rating>

<Rating>1.5</Rating>

<Rating>3</Rating>

<Rating>4</Rating>

<Rating>5</Rating>

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

<LikeButton />

<Clickable
img={img}
imgClicked={imgClicked}
/>
<Dice />

<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'
]}

/>

<NumbersTable limit={32} />
<RGBColorPicker/>
</div>
);
}
Expand Down
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.
10 changes: 10 additions & 0 deletions src/components/BoxColor/BoxColor.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.cbox{
margin:10px;
padding:30px;
text-align: center;
border:2px solid #000000;
height: 100px;
font-weight:500;
font-size: xx-large;
display: flex;
}
15 changes: 15 additions & 0 deletions src/components/BoxColor/BoxColor.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import "./BoxColor.css"
function BoxColor(props)
{
const toHex = (number) => {
let hex = number.toString(16);
return hex.length === 1 ? "0" + hex : hex;
};
let color='#'+(toHex(props.r))+(toHex(props.g))+(toHex(props.b))
return <div className='cbox' style={{backgroundColor:color}}>
<p>rgb({props.r},{props.g},{props.b})</p>
<p>{color}</p>
</div>
}

export default BoxColor
12 changes: 12 additions & 0 deletions src/components/Carousel/Carousel.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.carousel{
display:flex;
width:100%;
justify-content:center;
align-items:center;
}
.carousel button{
padding:10px 15px;
}
.carousel img{
margin:10px;
}
26 changes: 26 additions & 0 deletions src/components/Carousel/Carousel.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react';
import './Carousel.css'

function Carousel(props)
{
let arr=props.images
let len=arr.length
const[img_num , setImg]=React.useState(2)
function left()
{
if(img_num===0)
setImg(len-1)
else
setImg((img_num-1)%len)
}
function right()
{
setImg((img_num+1)%len)
}
return <div className='carousel'>
<button onClick={left}>Left</button>
<img src={arr[img_num]} alt='pic' style={{width:'300px'}}/>
<button onClick={right}>Right</button>
</div>
}
export default Carousel
14 changes: 14 additions & 0 deletions src/components/Clickable.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
function Clickable(props)
{
const [img,putGlasses]=React.useState(props.img)
function glasses()
{
putGlasses(props.imgClicked)
}
return <div>
<img src={img} alt='pic' onClick={glasses} style={{width:'150px'}}/>
</div>
}

export default Clickable
16 changes: 16 additions & 0 deletions src/components/CreditCard/CreditCard.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.credit{
width:300px;
border-radius: 10px;
padding:18px;
height: 150px;

margin:5px;
display: inline-block;
}
.credit > div{
text-align: right;
}
.credit img{
width:50px;

}
23 changes: 23 additions & 0 deletions src/components/CreditCard/CreditCard.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import './CreditCard.css'
import visa from '../../assets/images/visa.png'
import mastercard from '../../assets/images/mastercard.png'
function CreditCard(props)
{
const img = props.type === 'Visa' ? visa : mastercard;
let mon=props.expirationMonth
let yr=props.expirationYear%100
let ex=''
if(mon<10)
ex='0'+mon+'/'+yr

return <div className='credit' style={{backgroundColor: props.bgColor,color:props.color}}>
<div>
<img src={img} alt='pic' />
</div>
<h1>.... .... .... {props.number.slice(12)}</h1>
<p>Expires {ex} {props.bank}</p>
<p>{props.owner}</p>
</div>;
}

export default CreditCard;
46 changes: 46 additions & 0 deletions src/components/Dice.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import dice0 from '../assets/images/dice-empty.png'
import dice1 from '../assets/images/dice1.png'
import dice2 from '../assets/images/dice2.png'
import dice3 from '../assets/images/dice3.png'
import dice4 from '../assets/images/dice4.png'
import dice5 from '../assets/images/dice5.png'
import dice6 from '../assets/images/dice6.png'

import React from 'react';

function Dice()
{
const [img, throwDice]=React.useState(dice0)
setInterval(change,1000)
function change()
{
let n=parseInt(Math.random()*6)
switch(n)
{
case 0:
throwDice(dice0)
break;
case 1:
throwDice(dice1)
break;
case 2:
throwDice(dice2)
break;
case 3:
throwDice(dice3)
break;
case 4:
throwDice(dice4)
break;
case 5:
throwDice(dice5)
break;
default :
throwDice(dice6)
break;
}
}
return <div> <img src={img} alt='dice' style={{width:'100px'}}/> </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 @@
.driver{
display: flex;
width:100%;
border-radius: 10px;
background-color: rgb(68, 118, 255);
justify-content: center;
align-items: center;
padding:25px;
margin:10px;
color: white;
}
.driver img{
width:100px;
height:100px;
border-radius: 50%;
margin-right: 15px;
}
18 changes: 18 additions & 0 deletions src/components/DriverCard/DriverCard.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import './DriverCard.css'
import Rating from '../Rating/Rating';
function DriverCard(props)
{
return <div className='driver'>
<div>
<img src={props.img} alt='pic' />
</div>
<div>
<h1>{props.name}</h1>
<Rating>{props.rating}</Rating>
<p>{props.car.model}-
{props.car.licensePlate}</p>
</div>

</div>
}
export default DriverCard
Loading