Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,40 @@
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 (
<div className="App">
<h1> LAB | React Training</h1>
<IdCard
lastName="Smith"
firsttName="Alice"
gender="female"
height={160}
birth={new Date("1990-12-28")}
picture="https://randomuser.me/api/portraits/women/44.jpg"
/>

<IdCard
lastName="Doe"
firsttName="John"
gender="male"
height={178}
birth={new Date("1990-12-28")}
picture="https://randomuser.me/api/portraits/men/44.jpg"
/>

<Greetings lang="es">Raul</Greetings>

<Random min={1} max={6} />

<BoxColor r={255} g={0} b={0} />
<BoxColor r={128} g={255} b={0} />

</div>
);
}
Expand Down
24 changes: 24 additions & 0 deletions src/components/BoxColor.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@


function BoxColor(props) {

const bgColor = `rgb(${props.r}, ${props.g}, ${props.b})`;


const boxStyle = {
backgroundColor: bgColor,
border: "1px solid black",
padding: "20px",
margin: "10px 0",
textAlign: "center",
color: "black",
};

return (
<div style={boxStyle}>
{bgColor}
</div>
);
}

export default BoxColor;
5 changes: 5 additions & 0 deletions src/components/CreditCard.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@


function CreditCard(props) {

}
23 changes: 23 additions & 0 deletions src/components/Greetings.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

function Greetings(props) {
let greetings = "Hello";

if (props.lang === "de") {
greetings = "Hallo";
}

if (props.lang === "es") {
greetings = "Hola";
}

if (props.lang === "fr") {
greetings = "Bonjour"
}

return (
<div>
{greetings} {props.children}
</div>
);
}
export default Greetings;
18 changes: 18 additions & 0 deletions src/components/Idcard.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

function IdCard(props) {

return (
<div>
<img src={props.picture} alt={props.firstName}/>
<div>
<p><strong>First name:</strong> {props.firstName}</p>
<p><strong>Last name:</strong> {props.lastName}</p>
<p><strong>Gender:</strong> {props.gender}</p>
<p><strong>Height:</strong> {props.height} cm</p>
<p><strong>Birth:</strong> {props.birth.toDateString()}</p>
</div>
</div>
)
}

export default IdCard;
14 changes: 14 additions & 0 deletions src/components/Random.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@


function Random(props) {
const randomNumber = Math.floor(Math.random()* (props.max - props.min + 1)) + props.min;


return (
<div>
Random value between {props.min} and {props.max} {"=>"} {randomNumber}
</div>
);
}

export default Random;
1 change: 1 addition & 0 deletions src/main.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import IdCard from './components/idcard';
import App from './App';

const root = ReactDOM.createRoot(document.getElementById('root'));
Expand Down