diff --git a/src/App.css b/src/App.css index e69de29..a886baa 100644 --- a/src/App.css +++ b/src/App.css @@ -0,0 +1,83 @@ +.idcard { + display: flex; + width: 500px; + height: 200px; + border: 1px solid #000; + padding: 10px; + margin: 20px 10px; + text-align: left; + gap: 10px; +} + +.greetings, +.random, +.rating { + display: flex; + width: 500px; + height: 50px; + border: 1px solid #000; + padding: 10px; + margin: 20px 10px; +} + +.credit-card { + display: flex; + flex-direction: column; + justify-content: space-between; + width: 400px; + height: 200px; + border: none; + border-radius: 10px; + padding: 10px; + margin: 20px 10px; + text-align: left; + gap: 10px; +} + +.card-type { + display: flex; + justify-content: flex-end; + padding: 10px; +} + +.card-number { + font-size: 2em; + letter-spacing: 2px; + padding-left: 20px; +} + +.card-details { + display: flex; + flex-wrap: wrap; + gap: 10px 20px; + font-size: 0.9em; + align-items: flex-end; +} + +.card-owner { + flex-basis: 100%; + font-size: 1.2em; + font-weight: bold; + padding-bottom: 15px; +} + +.driver-card { + background-color: blue; + color: white; + display: flex; + align-items: center; + width: 400px; + height: 150px; + border-radius: 10px; + padding: 10px 20px; + margin: 20px 10px; + text-align: left; + gap: 20px; +} + +.driver-img { + width: 100px; + height: 100px; + border-radius: 50%; + object-fit: cover; +} diff --git a/src/App.jsx b/src/App.jsx index 98d0f49..99f6817 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,9 +1,102 @@ 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"; function App() { return (

LAB | React Training

+ + + + + Ludwig + François + + + + + + + + + + + + + + 0 + 1.49 + 1.5 + 3 + 4 + 5 + + + +
); } diff --git a/src/components/BoxColor.jsx b/src/components/BoxColor.jsx new file mode 100644 index 0000000..281e72d --- /dev/null +++ b/src/components/BoxColor.jsx @@ -0,0 +1,17 @@ +const BoxColor = (props) => { + const { r, g, b } = props; + const backgroundColor = `rgb(${r}, ${g}, ${b})`; + const hex = + "#" + + [r, g, b] + .map((x) => x.toString(16).padStart(2, "0")) + .join("") + .toUpperCase(); + + return ( +
+ {backgroundColor} {hex} +
+ ); +}; +export default BoxColor; diff --git a/src/components/CreditCard.jsx b/src/components/CreditCard.jsx new file mode 100644 index 0000000..06bbf92 --- /dev/null +++ b/src/components/CreditCard.jsx @@ -0,0 +1,41 @@ +import visa from "../assets/images/visa.png"; +import mastercard from "../assets/images/master-card.svg"; + +const CreditCard = (props) => { + const { + type, + number, + expirationMonth, + expirationYear, + bank, + owner, + bgColor, + color, + } = props; + + const maskedNumber = "•••• •••• •••• " + number.slice(-4); + + return ( +
+
+ {type} +
+
{maskedNumber}
+
+ + Expires {expirationMonth}/{expirationYear} + + {bank} + {owner} +
+
+ ); +}; +export default CreditCard; diff --git a/src/components/DriverCard.jsx b/src/components/DriverCard.jsx new file mode 100644 index 0000000..7087e83 --- /dev/null +++ b/src/components/DriverCard.jsx @@ -0,0 +1,22 @@ +const DriverCard = (props) => { + const { name, rating, img, car } = props; + + return ( +
+
+ {name} +
+

{name}

+

+ {"★".repeat(Math.round(rating)) + + "☆".repeat(5 - Math.round(rating))} +

+

+ {car.model} - {car.licensePlate} +

+
+
+
+ ); +}; +export default DriverCard; diff --git a/src/components/Greetings.jsx b/src/components/Greetings.jsx new file mode 100644 index 0000000..a1fd069 --- /dev/null +++ b/src/components/Greetings.jsx @@ -0,0 +1,15 @@ +const Greetings = (props) => { + const { lang, children } = props; + const greetings = { + en: "Hello", + fr: "Bonjour", + es: "Hola", + de: "Hallo", + }; + return ( +
+ {greetings[lang]} {children} +
+ ); +}; +export default Greetings; diff --git a/src/components/IdCard.jsx b/src/components/IdCard.jsx new file mode 100644 index 0000000..179fe27 --- /dev/null +++ b/src/components/IdCard.jsx @@ -0,0 +1,27 @@ +const IdCard = (props) => { + const { lastName, firstName, gender, height, birth, picture } = props; + + return ( +
+ {`${firstName} +
+

+ Last Name: {lastName} +

+

+ First Name: {firstName} +

+

+ Gender: {gender} +

+

+ Height: {height} cm +

+

+ Birth: {birth.toDateString()} +

+
+
+ ); +}; +export default IdCard; diff --git a/src/components/Random.jsx b/src/components/Random.jsx new file mode 100644 index 0000000..aee222d --- /dev/null +++ b/src/components/Random.jsx @@ -0,0 +1,10 @@ +const Random = (props) => { + const { min, max } = props; + return ( +
+ Random number between {min} and {max}:{" "} + {Math.floor(Math.random() * (max - min + 1)) + min} +
+ ); +}; +export default Random; diff --git a/src/components/Rating.jsx b/src/components/Rating.jsx new file mode 100644 index 0000000..7fe11e2 --- /dev/null +++ b/src/components/Rating.jsx @@ -0,0 +1,7 @@ +const Rating = ({ children }) => { + const roundedRating = Math.round(children); + const stars = "★".repeat(roundedRating) + "☆".repeat(5 - roundedRating); + + return
{stars}
; +}; +export default Rating;