From c8deb4fa44e411476e49a445500f8fcf8db78cda Mon Sep 17 00:00:00 2001 From: Daniel Martel Date: Mon, 18 Nov 2024 11:40:03 +0000 Subject: [PATCH] done + --- src/components/CreditCard.jsx | 22 ++++++++++++++++++++++ src/components/Greetings.jsx | 12 ++++++++++++ src/components/IdCard.jsx | 14 ++++++++++++++ src/components/Random.jsx | 12 ++++++++++++ src/components/Rating.jsx | 20 ++++++++++++++++++++ src/components/boxColor.jsx | 18 ++++++++++++++++++ 6 files changed, 98 insertions(+) create mode 100644 src/components/CreditCard.jsx create mode 100644 src/components/Greetings.jsx create mode 100644 src/components/IdCard.jsx create mode 100644 src/components/Random.jsx create mode 100644 src/components/Rating.jsx create mode 100644 src/components/boxColor.jsx diff --git a/src/components/CreditCard.jsx b/src/components/CreditCard.jsx new file mode 100644 index 000000000..778803c34 --- /dev/null +++ b/src/components/CreditCard.jsx @@ -0,0 +1,22 @@ +import React from 'react' +import visa from '../assets/images/visa.png' +import masterCard from '../assets/images/master-card.svg' + +/* eslint-disable react/prop-types */ +function CreditCard(props) { + const { type, number, expirationMonth, expirationYear, bank, owner, bgColor, color } = props + + + return ( +
+ +

{"•••• •••• •••• " + number.slice(-4)}

+

Expires {expirationMonth}/{expirationYear.toString().slice(-2)} + {bank} +

+

{owner}

+
+ ) +} + +export default CreditCard \ No newline at end of file diff --git a/src/components/Greetings.jsx b/src/components/Greetings.jsx new file mode 100644 index 000000000..83cef7753 --- /dev/null +++ b/src/components/Greetings.jsx @@ -0,0 +1,12 @@ +import React from 'react' + +function Greetings({ lang, children }) { + + return ( +
+

{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 000000000..038bf92f6 --- /dev/null +++ b/src/components/IdCard.jsx @@ -0,0 +1,14 @@ +function IdCard(props) { + return ( +
+ +

First name: {props.firstName}

+

Last name: {props.firstName}

+

Gender: {props.gender}

+

Height: {props.height}

+

Birth: {props.birth}

+
+ ) + } + + 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 000000000..5597bed56 --- /dev/null +++ b/src/components/Random.jsx @@ -0,0 +1,12 @@ +import React from 'react' + +function Random({ min, max }) { + const displayedRandomNumber = Math.floor(Math.random() ) + return ( +
+

{`Random value between ${min} and ${max} => ${displayedRandomNumber}`}

+
+ ) + } + + export default Random \ No newline at end of file diff --git a/src/components/Rating.jsx b/src/components/Rating.jsx new file mode 100644 index 000000000..a949d132a --- /dev/null +++ b/src/components/Rating.jsx @@ -0,0 +1,20 @@ +import React from "react"; + +function Rating(props) { + const { children } = props + + function convertToStars(rating) { + const roundedRating = Math.round(rating); + const filledStars = '★'.repeat(roundedRating); + const emptyStars = '☆'.repeat(5 - roundedRating); + return filledStars + emptyStars; + } + + return ( +
+ {convertToStars(children)} +
+ ) +} + +export default Rating diff --git a/src/components/boxColor.jsx b/src/components/boxColor.jsx new file mode 100644 index 000000000..77d9ea219 --- /dev/null +++ b/src/components/boxColor.jsx @@ -0,0 +1,18 @@ +import React from 'react' + +function BoxColor(props) { + const { r, g, b } = props + + function rgbToHex(r, g, b) { + return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1).toUpperCase(); + } + + return ( +
+ rgb({r},{g},{b})
+ {rgbToHex(r,g,b)} +
+ ) +} + +export default BoxColor \ No newline at end of file