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
122 changes: 122 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@

.App {
margin-left: 10px;
font-size: 18px;
font-family: Verdana, Geneva, Tahoma, sans-serif;
}

.IdCard {
display: flex;
}

.IdCard img {
width: 156px;
}

.right {
display: flex;
flex-direction: column;
}

.right li {
list-style-type: none;
}

.box {
padding: 10px;
margin-bottom: 10px;
border: solid 1px black;
}

.tx-center p {
text-align: center;
}

.CreditCard {
padding: 50px;
width: 350px;
border-radius: 10px;
margin-bottom: 15px;
}

.CreditCard img {
width: 70px;
}

.number {
text-align: center;
font-size: 2rem;
}

.type {
text-align: right;
}

.bank {
margin-left: 10px;
}

.Rating {
font-size: 3rem;
}

.DriverCard {
background-color: #425cbb;
border-radius: 10px;
color: #fff;
padding: 5px;
display: flex;
justify-content: center;
margin: 10px;
align-items: center;
}

.DriverCard img {
height: 150px;
width: 150px;
object-fit: cover;
border-radius: 100px;
margin-right: 20px;
}

.DriverCard h2 {
font-size: 1.5em;
font-weight: bold;
}

.ratingCard {
font-size: 3rem;
}

.NumbersTable {
display: flex;
}

.NumbersBox {
list-style-type: none;
border: solid 1px;
padding: 30px;
}

.country-button {
border: 0px;
border-radius: 10px;
background-color: lightblue;
padding: 10px;
margin: 5px;
}

.country-button:hover {
background-color: darkblue;
color: white;
}

.SignupPage {
display: flex;
flex-direction: column;
}

.SignupPage input {
padding: 10px;
margin: 5px 0px 5px 0px;
}
119 changes: 117 additions & 2 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,129 @@
import React, { Component } from 'react';
import IdCard from './components/IdCard';
import './App.css';
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';
import DriverCard from './components/DriverCard';
import LikeButton from './components/LikeButton';
import ClickablePicture from './components/ClickablePicture';
import Dice from './components/Dice';
import NumbersTable from './components/NumbersTable';
import Facebook from './components/Facebook';
import SignupPage from './components/SignupPage';

class App extends Component {
render() {
return (
<div className="App">
<h1>IdCard</h1>
{/* TODO: Use the IdCard component */}
<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"
/>

<h1>Greetings</h1>
{/* TODO: Use the Greetings component */}
<Greetings lang="de">Ludwig</Greetings>
<Greetings lang="fr">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>CreditCard</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" />

<h1>Rating</h1>
<Rating>0</Rating>
<Rating>1.49</Rating>
<Rating>1.5</Rating>
<Rating>3</Rating>
<Rating>4</Rating>
<Rating>5</Rating>

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

<h1>LikeButton</h1>
<LikeButton /> <LikeButton />

<h1>ClickablePicture</h1>
<ClickablePicture
img="/img/persons/maxence.png"
imgClicked="/img/persons/maxence-glasses.png"
/>

<h1>Dice</h1>
<Dice />

<h1>NumbersTable</h1>
<NumbersTable limit={12} />

<h1>Facebook</h1>
<Facebook />

<h1>Signup Form</h1>
<SignupPage />

</div>
);
}
Expand Down
22 changes: 22 additions & 0 deletions src/components/BoxColor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react'

const BoxColor = (props) => {
const componentToHex = (c) => {
let hex = c.toString(16);
return hex.length === 1 ? "0" + hex : hex;
}

const rgbToHex = (r, g, b) => {
return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
}
const hex = rgbToHex(props.r, props.b, props.g);

return (
<div className="box tx-center" style={{backgroundColor: 'rgb(' + props.r + ', ' + props.g + ', ' + props.b + ')'}} >
<p><strong>rgb({props.r},{props.g},{props.b})</strong></p>
<p><strong>{hex}</strong></p>
</div>
)
}

export default BoxColor;
18 changes: 18 additions & 0 deletions src/components/ClickablePicture.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React, { Component } from 'react'

export default class ClickablePicture extends Component {

state = {
img: this.props.img
}

changePicture = () => {
(this.state.img === this.props.img) ? this.setState({ img: this.props.imgClicked }) : this.setState({ img: this.props.img })
}

render() {
return (
<img src ={this.state.img} alt = "" onClick = {this.changePicture}/>
)
}
}
26 changes: 26 additions & 0 deletions src/components/CreditCard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react'

const CreditCard = (props) => {
let imgUrl = '';
if (props.type === "Visa") {
imgUrl = './img/visa.png'
} else {
imgUrl = './img/master-card.svg';
}
return (
<div className="CreditCard" style={{backgroundColor: props.bgColor, color: props.color}}>
<div className="type">
<img src={imgUrl} alt={props.type}/>
</div>
<div className="number">
<p>•••• •••• •••• {props.number.slice(12, 16)}</p>
</div>
<div className="expiresBank">
<span>Expires {props.expirationMonth}/{props.expirationYear}</span><span className="bank">{props.bank}</span>
</div>
<div className="owner">{props.owner}</div>
</div>
)
}

export default CreditCard;
27 changes: 27 additions & 0 deletions src/components/Dice.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React, { Component } from 'react'

export default class Dice extends Component {
constructor() {
super();
this.state = {
img: '/img/dice' + (Math.floor(Math.random() * 6) + 1) + '.png'
}
}

changePicture = () => {
this.setState({
img: '/img/dice-empty.png'
})
setTimeout(() => {
this.setState({
img: '/img/dice' + (Math.floor(Math.random() * 6) + 1) + '.png'
})
}, 1000)
}

render() {
return (
<img src={this.state.img} alt="" onClick={this.changePicture} style={{width: 100+"px"}} />
)
}
}
24 changes: 24 additions & 0 deletions src/components/DriverCard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react'

const DriverCard = (props) => {
let string = '';
for (let i = 0; i < Math.round(props.rating); i++) {
string += '★';
}


return (
<div className="DriverCard">
<img className="left" src={props.img} alt={props.name} style={{maxWidth: 100 + '%'}}></img>
<div className="right">
<h2>{props.name}</h2>
<div className="ratingCard">
{string.padEnd(5, "☆")}
</div>
<p>{props.car.model} - {props.car.licensePlate}</p>
</div>
</div>
)
}

export default DriverCard;
Loading