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
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"emmet.includeLanguages": {
"javascript": "javascriptreact"
}
}
40,048 changes: 40,048 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@ import logo from './logo.svg';
import './App.css';

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

export default App;
7 changes: 7 additions & 0 deletions src/BoxColor.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.box-color{
padding: 10px;
margin-top: 5px;
border: 1px solid #000;
width: 500px;
text-align: center;
}
20 changes: 20 additions & 0 deletions src/BoxColor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import './BoxColor.css';

function rgbToHex(r, g, b) {
return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
}

function BoxColor(props) {

const {r,g,b} = props;
const hex = rgbToHex(r,g,b);

return (
<div className="box-color" style={{backgroundColor: hex}}>
<p>{`rgb(${r},${g},${b})`}</p>
<p>{hex}</p>
</div>
);
}

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

.credit-card{
border: 1px solid #ccc;
width: 300px;
padding: 5px;
margin-top: 10px;
border-radius: 5px;
}

.logo img{
height: 20px;
}
37 changes: 37 additions & 0 deletions src/CreditCard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import './CreditCard.css';

function creditNumberHide(cardNumber) {
const sliced = cardNumber.slice(12);
return `•••• •••• •••• ${sliced}`;
}

function formatDate(expYear, expMonth){
const slicedYear = `${expYear}`.slice(2);
const formatMonth = `${expMonth}`.length === 1 ? `0${expMonth}` : expMonth;
return `${formatMonth}/${slicedYear}`;
}

function CreditCard(props) {
const {type, number, expirationMonth, expirationYear, bank, owner, bgColor, color} = props;

return(
<div className="credit-card" style={{backgroundColor: bgColor, color}}>

<div className="logo">
<img src={type === 'Visa' ? './img/visa.png' : './img/master-card.svg'} alt="logo"></img>
</div>
<div className="top">
<p>{creditNumberHide(number)}</p>
</div>
<div className="mid">
<p>{formatDate(expirationYear, expirationMonth)} {bank}</p>
</div>
<div className="bottom">
<p>{owner}</p>
</div>

</div>
);
}

export default CreditCard;
24 changes: 24 additions & 0 deletions src/DriverCard.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.driver-card{
display: flex;
justify-content: center;
align-items: center;
background-color: #455EB5;
margin-top: 10px;
border-radius: 10px;
color: white;
gap: 30px;
width: 800px;
}

.driver-img{
width: 120px;
height: 120px;
border-radius: 50%;
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}

.driver-text{
width: 300px;
}
21 changes: 21 additions & 0 deletions src/DriverCard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import './DriverCard.css';
import Rating from './Rating'

function DriverCard(props) {

const{name, rating, img, car} = props;
return (
<div className="driver-card">
<div className="driver-img" style={{backgroundImage: `url(${img})`}}>

</div>
<div className="driver-text">
<h4>{name}</h4>
<Rating>{rating}</Rating>
<p>{`${car.model} - ${car.licensePlate}`}</p>
</div>
</div>
)
}

export default DriverCard;
6 changes: 6 additions & 0 deletions src/Greetings.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.greetings{
border: 1px solid #000;
margin-top: 10px;
width: 500px;
padding-left: 5px;
}
24 changes: 24 additions & 0 deletions src/Greetings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import './Greetings.css';

function chooseLang(lang){
switch(lang){
case 'en': return 'Hello';
case 'es': return 'Hola';
case 'fr': return 'Bonjour';
case 'de': return 'Hallo';
default: return 'Hello';

}
}

function Greetings(props){

return(
    <div className="greetings">
<h2>{chooseLang(props.lang)} {props.children}</h2>
</div>
);
}


export default Greetings;
13 changes: 13 additions & 0 deletions src/IdCard.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.IdCard{
display: flex;
border: 1px solid black;
padding: 5px;
margin-top: 5px;
}

ul li{
list-style: none;
}
span{
font-weight: bold;
}
26 changes: 26 additions & 0 deletions src/IdCard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import './IdCard.css';

function IdCard(props){

const slicedDate = `${props.birth}`.slice(0,15);

return(
<div className="IdCard">
<div className="img-wrapper">
<img src={props.picture} alt="" />
</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> {slicedDate}</li>
</ul>
</div>
</div>
);
}


export default IdCard;
4 changes: 4 additions & 0 deletions src/LikeButton.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.like-btn-container{
margin-top: 10px;
display: flex;
}
32 changes: 32 additions & 0 deletions src/LikeButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import './LikeButton.css';
import {useState} from 'react';

function LikeButton(props){

const colors = ['red', 'green', 'blue', 'yellow', 'orange', 'purple', 'pink', 'brown', 'black', 'white'];

const [count, setCount] = useState(0);
const [color, setColor] = useState(colors[0]);

function incrementCount(){
setCount(prevCount => prevCount + 1);
}

function changeColor(){
const randomIndex = Math.floor(Math.random() * colors.length);
setColor(colors[randomIndex]);
}

function countAndColor(){
incrementCount();
changeColor();
}

return (
<div>
<button onClick={countAndColor} style={{backgroundColor: color}}>{count} Likes</button>
</div>
);
}

export default LikeButton;
6 changes: 6 additions & 0 deletions src/Random.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.random{
border: 1px solid #000;
margin-top: 10px;
width: 500px;
padding-left: 5px;
}
17 changes: 17 additions & 0 deletions src/Random.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import './Random.css'

function randomBetween(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}

function Random(props) {

const {min, max} = props;
return (
<div className="random">
<h2>{`Random value between ${min} and ${max} => ${randomBetween(min, max)}`}</h2>
</div>
);
}

export default Random;
Empty file added src/Rating.css
Empty file.
27 changes: 27 additions & 0 deletions src/Rating.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import './Rating.css';

function formatRating(rating) {

let roundedRating = Math.round(rating);
let emptyStars = 5 - roundedRating;
let stars = [];

for (let i = 0; i < roundedRating; i++) {
stars.push('★');
}
for (emptyStars; emptyStars--;) {
stars.push('☆');
}
return stars.join('');
}


function Rating(props) {
return (
<div>
<p>{formatRating((Number(props.children)))}</p>
</div>
);
}

export default Rating;
10 changes: 10 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
*{
box-sizing: border-box;
}

body {
margin: 0;
padding: 10px;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
Expand All @@ -11,3 +16,8 @@ code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}

.card-container{
display: flex;
gap: 10px;
}
Loading