diff --git a/src/App.js b/src/App.js index 3784575..e553735 100644 --- a/src/App.js +++ b/src/App.js @@ -1,6 +1,13 @@ import logo from './logo.svg'; 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 LikeButton from "./components/LikeButton"; +import ClickablePicture from "./components/ClickablePicture"; +import Dice from "./components/Dice"; function App() { return (
@@ -18,6 +25,74 @@ function App() { Learn React + + + + Ludwig + + François + + + + + + + + + + + + + + + + + +
); } diff --git a/src/Components/Boxcolour.js b/src/Components/Boxcolour.js new file mode 100644 index 0000000..acf7516 --- /dev/null +++ b/src/Components/Boxcolour.js @@ -0,0 +1,17 @@ +import React from 'react' + +const BoxColor = ({r,g,b}) => { + const divStyle ={ + backgroundColor:`rgb(${r},${g},${b})`, + height:'40px', + border:'1px solid black' + } + return ( +
+

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

+ +
+ ) +} + +export default BoxColor diff --git a/src/Components/CC.js b/src/Components/CC.js new file mode 100644 index 0000000..6071a50 --- /dev/null +++ b/src/Components/CC.js @@ -0,0 +1,30 @@ +import React from 'react' + +const CreditCard = (props) => { + const num = 'XXXX XXXX XXXX ' + const divstyle ={ + backgroundColor:`${props.bgColor}`, + color:`${props.color}`, + display:'flex', + flexDirection: 'column', + borderRadius: '10px', + justifyContent: 'space-around', + width:'300px', + height:'130px', + alignItems:'center' + + + } + return ( +
+ {props.type} +
{num}{props.number.substr(-4)}
+
Expires {props.expirationMonth}/{props.expirationYear}
+
{props.bank}
+
{props.owner}
+ +
+ ) +} + +export default CreditCard diff --git a/src/Components/Clickpic.js b/src/Components/Clickpic.js new file mode 100644 index 0000000..60cc6ae --- /dev/null +++ b/src/Components/Clickpic.js @@ -0,0 +1,26 @@ +import React, { useState } from 'react' + + +const ClickablePicture = (props) => { + const [image, setImage] = useState(true); + + function handleClick(){ + setImage(!image); + } + + return ( +
+ {image ? image:image clicked } + +
+ + ) +} + +export default ClickablePicture diff --git a/src/Components/Greetings.js b/src/Components/Greetings.js new file mode 100644 index 0000000..faea370 --- /dev/null +++ b/src/Components/Greetings.js @@ -0,0 +1,25 @@ +mport React from "react"; + +const Greetings = (props) => { + + + return ( +
+

+ {" "} + {props.lang === "de" + ? "Hallo" + : props.lang === "en" + ? "Hello" + : props.lang === "fr" + ? "Bonjour" + : props.lang === "es" + ? "Hii" + : ""}{" "} + {props.children} +

+
+ ); +}; + +export default Greetings; diff --git a/src/Components/IDCard.js b/src/Components/IDCard.js new file mode 100644 index 0000000..f2c3f76 --- /dev/null +++ b/src/Components/IDCard.js @@ -0,0 +1,26 @@ +import React from 'react' +import '../components/IDcard.css' + +const IDcard = ({firstName,lastName,gender,picture,height,birth}) => { + + return ( +
+
+ + +
+
+
First Name: {firstName}
+
Last Name: {lastName}
+
Gender: {gender}
+
Height: {height}
+
Birth: {birth.toLocaleDateString()}
+ + +
+ +
+ ) +} + +export default IDcard diff --git a/src/Components/IDCrad.css b/src/Components/IDCrad.css new file mode 100644 index 0000000..553a15e --- /dev/null +++ b/src/Components/IDCrad.css @@ -0,0 +1,10 @@ +.card{ + display: flex; + align-items: flex-start; + margin: 5px; + border: 1px solid black; +} +.details{ + margin-left: 5px; + margin-top: 0; +} diff --git a/src/Components/Likebutton.js b/src/Components/Likebutton.js new file mode 100644 index 0000000..a05962e --- /dev/null +++ b/src/Components/Likebutton.js @@ -0,0 +1,30 @@ + +import React, { useState } from 'react' + +const LikeButton = () => { + + const colors = ['purple','blue','green','yellow','orange','red'] + const[likes, setLikes] = useState(0); + const[bgcolor, setBgColor] = useState(colors[0]) + + let randomColor = Math.floor(Math.random()*(1+5)+1) ; + + + const handleLikes=()=>{ + setLikes((s)=> s+1); + setBgColor((c)=>{ + c = colors[randomColor]; + return c; + }) + + } + + + return ( +
+ +
+ ) +} + +export default LikeButton diff --git a/src/Components/Rand.js b/src/Components/Rand.js new file mode 100644 index 0000000..7489c5b --- /dev/null +++ b/src/Components/Rand.js @@ -0,0 +1,12 @@ + +import React from 'react' + +const Random = ({min,max}) => { + return ( +
+

Random value between {min} and {max} = {Math.floor(Math.random() * (max - min + 1) + min)}

+
+ ) +} + +export default Random diff --git a/src/Components/dice.js b/src/Components/dice.js new file mode 100644 index 0000000..b655920 --- /dev/null +++ b/src/Components/dice.js @@ -0,0 +1,22 @@ +import React, { useState } from 'react' +import dice3 from '../assets/images/dice3.png' +import dice_em from '../assets/images/dice-empty.png' +import dice6 from '../assets/images/dice6.png' + +const Dice = () => { + const [dice, setDice] = useState(dice3); + + function handleClick(){ + setDice(dice_em) + setTimeout(()=>{ + setDice(dice6) + },1000) + } + return ( +
+ +
+ ) +} + +export default Dice