Skip to content
Open

done #42

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
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}
7 changes: 7 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,10 @@
transform: rotate(360deg);
}
}
*{
margin: 0;
padding:0;
}
body{
padding: 5px;
}
143 changes: 141 additions & 2 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
import logo from './logo.svg';
import './App.css';
import IdCard from '//components/Idcard';
import Greeting from './components/Greetings';
import Random from './components/Random';
import BoxColor from './components/BoxColor';
import Rating from './components/Rating';
import CreditCard from './components/CreditCard';
import DriverCard from './components/DriverCard';
import LikeButton from './components/LikeButton';
import Clickable from './components/Clickable';
import Dice from './components/Dice';
import Caraousel from './components/Carousel';
import Table from './components/Table'
import RGBColorPicker from './components/RgbColorPicker';
//importing images
import img from "./assets/images/maxence.png";
import imgClicked from "./assets/images/maxence-glasses.png";

function App() {
return (
Expand All @@ -18,8 +34,131 @@ function App() {
Learn React
</a>
</header>
</div>
{/* </div> */}
<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"

/>

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

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

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

<Caraousel

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

/>

<Table limit={50} />
<RGBColorPicker />
</div>
);
}

export default App;
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.
9 changes: 9 additions & 0 deletions src/components/BoxColor.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.cbox{
margin:10px;
padding:30px;
text-align: center;
border:2px solid #000000;
height: 100px;
font-weight:500;
font-size: xx-large;
}
15 changes: 15 additions & 0 deletions src/components/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.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.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.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.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.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;
}
Loading