diff --git a/src/App.jsx b/src/App.jsx index 98d0f49..7667c58 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,9 +1,43 @@ 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

+

LAB | React Training

+ + + + + + Ludwig + François + María + John + + + + + + +
); } diff --git a/src/components/BoxColor.jsx b/src/components/BoxColor.jsx new file mode 100644 index 0000000..31330ca --- /dev/null +++ b/src/components/BoxColor.jsx @@ -0,0 +1,23 @@ +import React from "react"; + +function BoxColor({ r, g, b }) { + const luminance = 0.299 * r + 0.587 * g + 0.114 * b; + const textColor = luminance > 186 ? "black" : "white"; + + const divStyle = { + backgroundColor: `rgb(${r}, ${g}, ${b})`, + color: textColor, + padding: "20px", + margin: "10px 0", + borderRadius: "5px", + textAlign: "center" + }; + + return ( +
+ rgb({r}, {g}, {b}) +
+ ); +} + +export default BoxColor; diff --git a/src/components/Greetings.jsx b/src/components/Greetings.jsx new file mode 100644 index 0000000..137a0b9 --- /dev/null +++ b/src/components/Greetings.jsx @@ -0,0 +1,16 @@ +import React from "react"; + +function Greetings({ lang, children }) { + const greetings = { + de: "Hallo", + en: "Hello", + es: "Hola", + fr: "Bonjour", + }; + + const greetingText = greetings[lang] || "Hello"; + + return
{greetingText} {children}
; +} + +export default Greetings; diff --git a/src/components/IdCard.css b/src/components/IdCard.css new file mode 100644 index 0000000..926338e --- /dev/null +++ b/src/components/IdCard.css @@ -0,0 +1,50 @@ +.IdCard { + display: flex; + align-items: center; + border: 1px solid #e0e0e0; + border-radius: 10px; + padding: 16px 20px; + margin: 16px auto; + max-width: 500px; + background-color: #ffffff; + box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); + font-family: Arial, sans-serif; +} + +.IdCard img { + width: 120px; + height: 120px; + border-radius: 10px; + object-fit: cover; + margin-right: 20px; + border: 2px solid #ccc; +} + +.IdCard-info { + display: flex; + flex-direction: column; +} + +.IdCard-info p { + margin: 4px 0; + font-size: 16px; + color: #333; +} + +.IdCard-info strong { + font-weight: bold; + margin-right: 5px; +} + +/* Responsivo */ +@media (max-width: 400px) { + .IdCard { + flex-direction: column; + align-items: center; + } + + .IdCard img { + margin-right: 0; + margin-bottom: 10px; + } +} diff --git a/src/components/IdCard.jsx b/src/components/IdCard.jsx new file mode 100644 index 0000000..f8b56da --- /dev/null +++ b/src/components/IdCard.jsx @@ -0,0 +1,19 @@ +import React from "react"; +import "./IdCard.css"; + +function IdCard({ firstName, lastName, gender, height, birth, picture }) { + return ( +
+ {`${firstName} +
+

Nombre: {firstName}

+

Apellido: {lastName}

+

Género: {gender}

+

Altura: {height} cm

+

Fecha de nacimiento: {birth.toLocaleDateString("es-ES")}

+
+
+ ); +} + +export default IdCard; diff --git a/src/components/random.jsx b/src/components/random.jsx new file mode 100644 index 0000000..5bd0a58 --- /dev/null +++ b/src/components/random.jsx @@ -0,0 +1,13 @@ +import React from "react"; + +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;