diff --git a/public/favicon.ico b/public/favicon.ico deleted file mode 100644 index a11777c..0000000 Binary files a/public/favicon.ico and /dev/null differ diff --git a/public/logo192.png b/public/logo192.png deleted file mode 100644 index fc44b0a..0000000 Binary files a/public/logo192.png and /dev/null differ diff --git a/public/logo512.png b/public/logo512.png deleted file mode 100644 index a4e47a6..0000000 Binary files a/public/logo512.png and /dev/null differ diff --git a/public/manifest.json b/public/manifest.json deleted file mode 100644 index 080d6c7..0000000 --- a/public/manifest.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "short_name": "React App", - "name": "Create React App Sample", - "icons": [ - { - "src": "favicon.ico", - "sizes": "64x64 32x32 24x24 16x16", - "type": "image/x-icon" - }, - { - "src": "logo192.png", - "type": "image/png", - "sizes": "192x192" - }, - { - "src": "logo512.png", - "type": "image/png", - "sizes": "512x512" - } - ], - "start_url": ".", - "display": "standalone", - "theme_color": "#000000", - "background_color": "#ffffff" -} diff --git a/public/robots.txt b/public/robots.txt deleted file mode 100644 index e9e57dc..0000000 --- a/public/robots.txt +++ /dev/null @@ -1,3 +0,0 @@ -# https://www.robotstxt.org/robotstxt.html -User-agent: * -Disallow: diff --git a/src/App.css b/src/App.css index 74b5e05..4090794 100644 --- a/src/App.css +++ b/src/App.css @@ -1,38 +1,25 @@ -.App { - text-align: center; -} - -.App-logo { - height: 40vmin; - pointer-events: none; -} -@media (prefers-reduced-motion: no-preference) { - .App-logo { - animation: App-logo-spin infinite 20s linear; - } -} -.App-header { - background-color: #282c34; - min-height: 100vh; +.App > *{ display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - font-size: calc(10px + 2vmin); - color: white; -} + flex-direction: row; + justify-content: flex-start; + /* align-items: center; */ + text-align: left; + padding: 10px; + margin: 20px; + border: 1px solid black; + line-height: 7px; + padding: 10px; + gap: 20px; -.App-link { - color: #61dafb; } -@keyframes App-logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } +.rating-stars{ + display: flex; + flex-direction: column; + font-size: 1.5rem; + padding: 20px; + line-height: 10px; + border: none; } diff --git a/src/App.js b/src/App.js index 3784575..5157923 100644 --- a/src/App.js +++ b/src/App.js @@ -1,23 +1,148 @@ -import logo from './logo.svg'; -import './App.css'; +import "./App.css"; +import Greetings from "./components/Greetings"; +import IdCard from "./components/IdCard"; +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 image1 from "./assets/images/maxence.png" +import image2 from "./assets/images/maxence-glasses.png" +import Dice from "./components/Dice"; +import Carousel from "./components/Carousel"; +import NumbersTable from "./components/NumbersTable"; +import RGBColorPicker from "./components/RGBColorPicker"; function App() { return (
-
- logo -

- Edit src/App.js and save to reload. -

- - Learn React - -
+ + + + + Ludwig + + François + + + + + + + + + +
+ + + + + +
+ +
+ 0 + + 1.49 + + 1.5 + + 3 + + 4 + + 5 +
+ + + + +
+ + +
+ + + +
+ + + + + + +
); } diff --git a/src/assets/images/master-card.svg b/src/assets/images/master-card.svg deleted file mode 100644 index 00d7f2e..0000000 --- a/src/assets/images/master-card.svg +++ /dev/null @@ -1,177 +0,0 @@ - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/assets/images/mastercard.png b/src/assets/images/mastercard.png new file mode 100644 index 0000000..1884f5b Binary files /dev/null and b/src/assets/images/mastercard.png differ diff --git a/src/components/BoxColor.jsx b/src/components/BoxColor.jsx new file mode 100644 index 0000000..81ad5b8 --- /dev/null +++ b/src/components/BoxColor.jsx @@ -0,0 +1,13 @@ +import React from 'react'; + +export default function BoxColor({ r, g, b }) { + const divStyle = { + backgroundColor: `rgb(${r}, ${g}, ${b})`, + }; //inline style to pass it down as style and cleaner code + + return ( +
+

rgb({r}, {g}, {b})

+
+ ); +} diff --git a/src/components/Carousel.css b/src/components/Carousel.css new file mode 100644 index 0000000..0f7cdae --- /dev/null +++ b/src/components/Carousel.css @@ -0,0 +1,23 @@ +.carousel{ + display:flex; + flex-direction:column; + padding: 3rem; + justify-content: center; + align-items: center; + +} + +.carousel>img{ + width: 15rem; + height: auto; +} + +.buttons-carousel>button{ + padding: 10px 15px; + border-radius: 10px; + border: 1px solid rgba(128, 128, 128, 0.075); + margin: 5px; + color: rgba(0, 0, 0, 0.564); + cursor: pointer; + +} \ No newline at end of file diff --git a/src/components/Carousel.jsx b/src/components/Carousel.jsx new file mode 100644 index 0000000..bfc5f3d --- /dev/null +++ b/src/components/Carousel.jsx @@ -0,0 +1,35 @@ +import React, { useState } from "react"; +import "./Carousel.css"; + +export default function Carousel({ images }) { + //onclick, the arr goes to the next index + const [currentIndex, setCurrentIndex] = useState(0); + + function handleClickRight() { + //if currentIndex is greater than the length of the array + if (currentIndex === images.length - 1) { + setCurrentIndex(0); + } else { + setCurrentIndex(currentIndex + 1); //increase the count + } + } + + function handleClickLeft() { + // if the current index is less than 0 + if (currentIndex === 0) { + setCurrentIndex(images.length - 1); + } else { + setCurrentIndex(currentIndex + -1); //decrease the count + } + } + let imgSource = images[currentIndex]; + return ( +
+ imageCarousel +
+ + +
{" "} +
+ ); +} diff --git a/src/components/ClickablePicture.jsx b/src/components/ClickablePicture.jsx new file mode 100644 index 0000000..4a83b95 --- /dev/null +++ b/src/components/ClickablePicture.jsx @@ -0,0 +1,18 @@ +import React, {useState} from 'react' + +export default function ClickablePicture({img, imgClicked}) { + + const [image, setImage] = useState(img); + + + function changeImage(){ + // Toggle between img and imgClicked + setImage(prevImage => prevImage === img ? imgClicked : img); + } + + return ( +
+ img +
+ ) +} diff --git a/src/components/CreditCard.css b/src/components/CreditCard.css new file mode 100644 index 0000000..a3a4206 --- /dev/null +++ b/src/components/CreditCard.css @@ -0,0 +1,39 @@ +.credit-card { + display: flex; + flex-direction: column; + text-align: left; + width: 18rem; + height: 10rem; + justify-content: flex-end; + border-radius: 10px; +} + +.credit-card > div > img { + width: 3rem; + padding: 0px 20px 0px 0; +} +.img-div-cc { + display: flex; + justify-content: flex-end; +} + +.card-details { + display: flex; + flex-direction: column; +} +.card-details > p:nth-child(1) { + font-size: 1.4rem; + justify-content: center; + display: flex; + letter-spacing: 3px; + padding: 10px 0; +} + +.more-details { + + justify-content: flex-start; + padding: 0 0 10px 10px; + display: flex; + align-items: center; + margin: 4px; +} diff --git a/src/components/CreditCard.jsx b/src/components/CreditCard.jsx new file mode 100644 index 0000000..a3275db --- /dev/null +++ b/src/components/CreditCard.jsx @@ -0,0 +1,22 @@ +import React from 'react' +import MasterCard from "../assets/images/mastercard.png" +import Visa from "../assets/images/visa.png" +import "./CreditCard.css"; + +export default function CreditCard({type, number, expirationMonth, expirationYear, bank, owner, bgColor, color}) { + + // Determine the img source based on the card type + const cardImage = type === "Visa" ? Visa : type === "Master Card" ? MasterCard : null; + + return ( +
+
{type}
+
+

**** **** **** {number.slice(-4)}

+

Expires {expirationMonth}/{expirationYear} {bank}

+

{owner}

+
+ +
+ ) +} diff --git a/src/components/Dice.jsx b/src/components/Dice.jsx new file mode 100644 index 0000000..6a78422 --- /dev/null +++ b/src/components/Dice.jsx @@ -0,0 +1,35 @@ +import React, { useState } from "react"; +import emptyDice 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"; + +export default function Dice() { + let dices = [dice1, dice2, dice3, dice4, dice5, dice6]; + + let style = { + width: "100px", + } + + const [diceImg, setDiceImg] = useState(dice1); + + function handleClick() { + //show the empty dice first + setDiceImg(emptyDice); + + //set timer to show the random dice after 1sec + setTimeout(() => { + const randomDice = dices[Math.floor(Math.random() * dices.length)]; + setDiceImg(randomDice); + }, 1000); + + } + return ( +
+ dice-img +
+ ); +} diff --git a/src/components/DriverCard.css b/src/components/DriverCard.css new file mode 100644 index 0000000..70f1bbc --- /dev/null +++ b/src/components/DriverCard.css @@ -0,0 +1,38 @@ +.drivers-license { + font-size: 0.8rem; + font-family: Arial, Helvetica, sans-serif; + width: 30rem; + height: 7rem; + align-items:center; + background-color: rgb(54, 54, 203); + border: none; + border-radius: 10px; + color: white; + display: flex; + justify-content: center; + +} +.driver-info{ + display: flex; + min-width: 17rem; + flex-direction: row; + align-items: center; + gap: 15px; +} + +.driver-img-div{ +display: flex; +justify-self: flex-start; +justify-content: center; +align-items: flex-start; +} + +.driver-img { + width: 5rem; + height: 5rem; + border-radius: 50%; +} + +.text-driver>h1{ + font-size: 1rem; +} diff --git a/src/components/DriverCard.jsx b/src/components/DriverCard.jsx new file mode 100644 index 0000000..adfb0f8 --- /dev/null +++ b/src/components/DriverCard.jsx @@ -0,0 +1,24 @@ +import React from "react"; +import Rating from "./Rating"; +import "./DriverCard.css"; + +export default function DriverCard({ name, rating, img, car }) { + let driversLicense = car.licensePlate; + let carModel = car.model; + return ( +
+
+
drivers-img
+
+

{name}

+ {/* rating gets converted into stars */} + {rating} + {/* obj properties get accessed by dot notation */} +

+ {driversLicense} - {carModel} +

+
+
+
+ ); +} diff --git a/src/components/Greetings.jsx b/src/components/Greetings.jsx new file mode 100644 index 0000000..9ccba32 --- /dev/null +++ b/src/components/Greetings.jsx @@ -0,0 +1,19 @@ +import React from "react"; + +export default function Greetings({ lang, children }) { + return ( +
+

+ {" "} + {lang === "en" + ? "Hello" + : lang === "fr" + ? "Bonjour" + : lang === "de" + ? "Hallo" + : "Hello"}{" "} + {children} +

+
+ ); +} diff --git a/src/components/IdCard.jsx b/src/components/IdCard.jsx new file mode 100644 index 0000000..471c201 --- /dev/null +++ b/src/components/IdCard.jsx @@ -0,0 +1,16 @@ +import React from 'react'; + +export default function IdCard({ lastName, firstName, gender, height, birth, picture }) { + return ( +
+ {`${firstName} +
+

First Name: {firstName}

+

Last Name: {lastName}

+

Gender: {gender}

+

Height: {height} cm

+

Birth: {birth.toDateString()}

+
+
+ ); +} diff --git a/src/components/LikeButton.jsx b/src/components/LikeButton.jsx new file mode 100644 index 0000000..92fff80 --- /dev/null +++ b/src/components/LikeButton.jsx @@ -0,0 +1,55 @@ +import React, {useState} from 'react' + +export default function LikeButton() { + let colors = [ + "red", + "yellow", + "green", + "blue", + "violet", + "orange", + "pink", + "brown", + "gray", + + ] + + const [count, setCount] = useState(0); + const [color, setColor] = useState("red"); // Initial color + +//function to generate random color + function getRandomColor() { + return colors[Math.floor(Math.random() * colors.length)]; + } + +//change color with every click & add count with every click + function increaseLikeCount() { + setCount(count + 1); + setColor(getRandomColor()); + } +//set color as bgcolor + let style = { + backgroundColor: color, + height: "2rem", + borderRadius: "10px", + color: "white", + border: "none", + padding: "15px", + alignItems: "center", + display: "flex", + } + + // function resetButton(){ + // setCount(0); + // } + + + + return ( +
+ + {/* */} +
+ ) +} + diff --git a/src/components/NumbersTable.jsx b/src/components/NumbersTable.jsx new file mode 100644 index 0000000..8cef202 --- /dev/null +++ b/src/components/NumbersTable.jsx @@ -0,0 +1,32 @@ +import React from 'react' + +export default function NumbersTable({ limit }) { + +let countList = [] + for (let i = 1; i < limit; i++){ + countList.push(i); + } + return ( +
+ {countList.map((number)=>( +
{number}
+ ))} + +
+ ) +} diff --git a/src/components/RGBColorPicker.jsx b/src/components/RGBColorPicker.jsx new file mode 100644 index 0000000..679bf14 --- /dev/null +++ b/src/components/RGBColorPicker.jsx @@ -0,0 +1,66 @@ +import React, { useState } from "react"; +import SingleColorPicker from "./SingleColorPicker"; + +export default function RGBColorPicker() { + const [red, setRed] = useState(0); + const [green, setGreen] = useState(0); + const [blue, setBlue] = useState(0); + + const onChangeRed = (event) => { + setRed(Number(event.target.value)); // Update the red value + }; + + const onChangeGreen = (event) => { + setGreen(Number(event.target.value)); // Update the green value + }; + + const onChangeBlue = (event) => { + setBlue(Number(event.target.value)); // Update the blue value + }; + + return ( +
+ + {/* Red Input */} +
+
+ +
+ + {/* Green Input */} +
+
+ +
+ + {/* Blue Input */} +
+
+ +
+ + {/* Result Color Box */} +
+ + {/* RGB Value Display */} +

RGB({red}, {green}, {blue})

+
+ ); +} diff --git a/src/components/Random.jsx b/src/components/Random.jsx new file mode 100644 index 0000000..e9e0816 --- /dev/null +++ b/src/components/Random.jsx @@ -0,0 +1,17 @@ +import React, { useState, useEffect } from 'react'; + +export default function Random({ min, max }) { + const [randomNumber, setRandomNumber] = useState(null); + + //use effect to not make changes with the same numbers + useEffect(() => { + const number = Math.floor(Math.random() * (max - min + 1)) + min; + setRandomNumber(number); + }, [min, max]); // Depend on min and max to recalculate if they change + + return ( +
+

Random Value between {min} and {max} {" => "} {randomNumber}

+
+ ); +} diff --git a/src/components/Rating.js b/src/components/Rating.js new file mode 100644 index 0000000..a991171 --- /dev/null +++ b/src/components/Rating.js @@ -0,0 +1,18 @@ +import React from 'react' + +export default function Rating({children}) { + + const roundedRating = Math.round(children); + const stars = []; + + for (let i = 0; i < 5; i++) { // we loop to fill the array with either the following conditions + if (i < roundedRating) { //check if i matches the number given or is smaller than. + stars.push() // thats a filled star + } else { + stars.push() // span pushes on that index, an empty star + } + } + return ( +
{stars}
+ ) +} diff --git a/src/components/SingleColorPicker.jsx b/src/components/SingleColorPicker.jsx new file mode 100644 index 0000000..651ee66 --- /dev/null +++ b/src/components/SingleColorPicker.jsx @@ -0,0 +1,16 @@ +import React from 'react'; + +export default function SingleColorPicker({ color, value, onChange }) { + return ( +
+ + +
+ ); +} diff --git a/src/logo.svg b/src/logo.svg deleted file mode 100644 index 9dfc1c0..0000000 --- a/src/logo.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file