From 7c25a6376a7295af11b6895968d1b84cc96495c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Bail=C3=B3n?= Date: Wed, 11 Mar 2026 08:33:53 +0100 Subject: [PATCH] Solved lab --- src/App.css | 33 +++++++++++++++++++++++++++ src/App.jsx | 43 ++++++++++++++++++++++++++++++++---- src/components/BoxColor.jsx | 16 ++++++++++++++ src/components/Greetings.jsx | 23 +++++++++++++++++++ src/components/IdCard.jsx | 21 ++++++++++++++++++ src/components/Random.jsx | 15 +++++++++++++ 6 files changed, 147 insertions(+), 4 deletions(-) create mode 100644 src/components/BoxColor.jsx create mode 100644 src/components/Greetings.jsx create mode 100644 src/components/IdCard.jsx create mode 100644 src/components/Random.jsx diff --git a/src/App.css b/src/App.css index e69de29..bfe8d92 100644 --- a/src/App.css +++ b/src/App.css @@ -0,0 +1,33 @@ +.userDiv { + display: flex; + align-items: center; + border: 1px solid black; + padding: 10px; + margin: 10px; + width: 100% +} + +.greetings { + border: 1px solid black; + padding: 10px; + margin: 10px; + font-family: Arial, sans-serif; +} + +.random { + border: 1px solid black; + padding: 10px; + margin: 10px; + font-family: Arial, sans-serif; +} + +.box-color { + width: 400px; + height: 100px; + border: 1px solid black; + margin: 10px; + display: flex; + align-items: center; + justify-content: center; + font-family: Arial, sans-serif; +} diff --git a/src/App.jsx b/src/App.jsx index 98d0f49..8db3b5d 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,11 +1,46 @@ -import "./App.css"; +import "./App.css" +import IdCard from "./components/IdCard"; +import Greetings from "./components/Greetings"; +import Random from "./components/Random"; +import BoxColor from "./components/BoxColor"; function App() { return ( -
-

LAB | React Training

+
+ + + + + + + Ludwig + François + + + + + + + + +
+ ); } -export default App; +export default App; \ No newline at end of file diff --git a/src/components/BoxColor.jsx b/src/components/BoxColor.jsx new file mode 100644 index 0000000..5b8a68a --- /dev/null +++ b/src/components/BoxColor.jsx @@ -0,0 +1,16 @@ +import "../App.css"; + +function BoxColor({ r, g, b }) { + + const boxStyle = { + backgroundColor: `rgb(${r}, ${g}, ${b})` + }; + + return ( +
+ rgb({r}, {g}, {b}) +
+ ); +} + +export default BoxColor; \ No newline at end of file diff --git a/src/components/Greetings.jsx b/src/components/Greetings.jsx new file mode 100644 index 0000000..e0cced9 --- /dev/null +++ b/src/components/Greetings.jsx @@ -0,0 +1,23 @@ +import "../App.css" + +function Greetings({ lang, children }) { + let greeting = ""; + + if (lang === "de") { + greeting = "Hallo"; + } else if (lang === "en") { + greeting = "Hello"; + } else if (lang === "es") { + greeting = "Hola"; + } else if (lang === "fr") { + greeting = "Bonjour"; + } + + return ( +

+ {greeting} {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..23b36f9 --- /dev/null +++ b/src/components/IdCard.jsx @@ -0,0 +1,21 @@ +import "../App.css" + +function IdCard(props) { + return ( +
+ + + +
+

First name: {props.firstName}

+

Last name: {props.lastName}

+

Gender: {props.gender}

+

Height: {props.height / 100}m

+

Birth: {props.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..5289a15 --- /dev/null +++ b/src/components/Random.jsx @@ -0,0 +1,15 @@ +import "../App.css"; + +function Random({ min, max }) { + + const randomNumber = + Math.floor(Math.random() * (max - min + 1)) + min; + + return ( +

+ Random value between {min} and {max} => {randomNumber} +

+ ); +} + +export default Random; \ No newline at end of file