From abb8c57a1339041e13d40083fad45cfba5c3e95c Mon Sep 17 00:00:00 2001 From: superquique Date: Tue, 10 Mar 2026 20:16:22 -0600 Subject: [PATCH] Implement all iterations --- {src/assets/images => public}/master-card.svg | 0 {src/assets/images => public}/visa.png | Bin src/App.css | 100 ++++++++++++++++++ src/App.jsx | 98 +++++++++++++++++ src/components/ CreditCard.jsx | 22 ++++ src/components/BoxColor.jsx | 12 +++ src/components/DriverCard.jsx | 17 +++ src/components/Greetings.jsx | 14 +++ src/components/IdCard.jsx | 21 ++++ src/components/Random.jsx | 9 ++ src/components/Rating.jsx | 12 +++ src/index.css | 2 +- 12 files changed, 306 insertions(+), 1 deletion(-) rename {src/assets/images => public}/master-card.svg (100%) rename {src/assets/images => public}/visa.png (100%) create mode 100644 src/components/ CreditCard.jsx create mode 100644 src/components/BoxColor.jsx create mode 100644 src/components/DriverCard.jsx create mode 100644 src/components/Greetings.jsx create mode 100644 src/components/IdCard.jsx create mode 100644 src/components/Random.jsx create mode 100644 src/components/Rating.jsx diff --git a/src/assets/images/master-card.svg b/public/master-card.svg similarity index 100% rename from src/assets/images/master-card.svg rename to public/master-card.svg diff --git a/src/assets/images/visa.png b/public/visa.png similarity index 100% rename from src/assets/images/visa.png rename to public/visa.png diff --git a/src/App.css b/src/App.css index e69de29..d67619e 100644 --- a/src/App.css +++ b/src/App.css @@ -0,0 +1,100 @@ +h1 { + margin: 10px; + padding: 5px; + display: flex; + justify-content: center; + border: 2px solid black; +} + +.id-card { + display: flex; + gap: 10px; + align-items: start; + border: 2px solid black; + margin: 10px; + padding: 5px; + line-height: 0.4rem; +} + +.greetings { + border: 2px solid black; + margin: 10px; + padding: 5px; + font-size: 1.3rem; +} + +.random { + border: 2px solid black; + margin: 10px; + padding: 5px; + font-size: 1.3rem; +} + +.box-color { + margin: 10px; + padding: 5px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + gap: 0; + border: 2px solid black; +} + +.credit-card { + border-radius: 15px; + display: flex; + flex-direction: column; + justify-content: space-evenly; + align-items: center; + width: 30vw; + height: 25vh; + margin: 10px; + padding: 20px; +} + +.credit-card p { + margin: 0; +} + +.credit-card-row { + display: flex; +} + +.star-container { + margin: 10px; +} + +.rating { + --star-size: 30px; + --star-color: royalblue; /* Empty star color */ + --star-background: white; /* Filled star color */ + + display: block; + font-size: var(--star-size); + line-height: 1; +} + +.rating::before { + content: '★★★★★'; + letter-spacing: 3px; + -webkit-text-stroke: 2px white; + background: linear-gradient(90deg, + var(--star-background) var(--percent), + var(--star-color) var(--percent) + ); + -webkit-background-clip: text; + -webkit-text-fill-color: transparent; +} + +.driver-card { + margin: 10px; + padding: 10px; + background-color: royalblue; + color: white; + border-radius: 20px; + display: flex; + justify-content: center; + align-items: center; + gap: 10px; +} \ No newline at end of file diff --git a/src/App.jsx b/src/App.jsx index 98d0f49..b36fa09 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,9 +1,107 @@ import "./App.css"; +import IdCard from "./components/IdCard"; +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"; function App() { return (

LAB | React Training

+ + + + + Ludwig + François + + + + + + + +
+ + + + + +
+ +
+ 0 + 1.49 + 1.5 + 3 + 4 + 5 +
+ + + + +
); } diff --git a/src/components/ CreditCard.jsx b/src/components/ CreditCard.jsx new file mode 100644 index 0000000..88755ec --- /dev/null +++ b/src/components/ CreditCard.jsx @@ -0,0 +1,22 @@ +function CreditCard ({type, number, expirationMonth, expirationYear, bank, owner, + bgColor, color +}) { + const typeImages = { + "Visa": "../../public/visa.png", + "Master Card": "../../public/master-card.svg" + } + + return ( +
+ credit card logo +

•••• •••• •••• {number.slice(12)}

+
+

Expires {expirationMonth}/{expirationYear} {bank}

+

{owner}

+
+
+ ) +} + +export default CreditCard; \ No newline at end of file diff --git a/src/components/BoxColor.jsx b/src/components/BoxColor.jsx new file mode 100644 index 0000000..5d6243c --- /dev/null +++ b/src/components/BoxColor.jsx @@ -0,0 +1,12 @@ +function BoxColor ({r, g, b}) { + const toHex = (c) => c.toString(16).padStart(2, '0'); + + return ( +
+

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

+

#{toHex(r)}{toHex(g)}{toHex(b)}

+
+ ) +} + +export default BoxColor; \ No newline at end of file diff --git a/src/components/DriverCard.jsx b/src/components/DriverCard.jsx new file mode 100644 index 0000000..4194b19 --- /dev/null +++ b/src/components/DriverCard.jsx @@ -0,0 +1,17 @@ +import Rating from "./Rating"; + +function DriverCard ({name, rating, img, car}) { + return ( +
+ Driver profile picture +
+

{name}

+ {rating} +

{car.model} - {car.licensePlate}

+
+
+ ) +} + +export default DriverCard; \ No newline at end of file diff --git a/src/components/Greetings.jsx b/src/components/Greetings.jsx new file mode 100644 index 0000000..9acd9f9 --- /dev/null +++ b/src/components/Greetings.jsx @@ -0,0 +1,14 @@ +function Greetings ({lang, children}) { + const helloString = { + de: "Hallo", + en: "Hello", + es: "Hola", + fr: "Bonjour" + } + + return ( +
{helloString[lang]} {children}
+ ) +} + +export default Greetings; \ No newline at end of file diff --git a/src/components/IdCard.jsx b/src/components/IdCard.jsx new file mode 100644 index 0000000..b9303bd --- /dev/null +++ b/src/components/IdCard.jsx @@ -0,0 +1,21 @@ +function IdCard ({lastName, firstName, gender, + height, birth, picture}) { + + return ( +
+
+ +
+ +
+

First name: {firstName}

+

Last name: {lastName}

+

Gender: {gender}

+

Height: {height}

+

Birth: {birth.toDateString()}

+
+
+ ) +} + +export default IdCard; \ No newline at end of file diff --git a/src/components/Random.jsx b/src/components/Random.jsx new file mode 100644 index 0000000..61be806 --- /dev/null +++ b/src/components/Random.jsx @@ -0,0 +1,9 @@ +function Random ({min, max}) { + const randNumber = Math.floor(Math.random() * max + min); + + return ( +
Random value between {min} and {max} ⇒ {randNumber}
+ ) +} + +export default Random; \ No newline at end of file diff --git a/src/components/Rating.jsx b/src/components/Rating.jsx new file mode 100644 index 0000000..e07ed6c --- /dev/null +++ b/src/components/Rating.jsx @@ -0,0 +1,12 @@ +function Rating ({children}) { + const ratingValue = parseFloat(children); + const percentage = (ratingValue / 5) * 100; + + return ( +
+ +
+ ) +} + +export default Rating; \ No newline at end of file diff --git a/src/index.css b/src/index.css index ec2585e..3e3b6a1 100644 --- a/src/index.css +++ b/src/index.css @@ -10,4 +10,4 @@ body { code { font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace; -} +} \ No newline at end of file