From b078391204162709628cea03a1013db345086592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Calcagno=20Lo=C3=AFc?= <98493858+CalcagnoLoic@users.noreply.github.com> Date: Tue, 16 Jul 2024 13:21:36 +0200 Subject: [PATCH] adding rating --- app/breed/[slug]/page.tsx | 2 +- app/lib/data.ts | 16 +- app/lib/definitions.ts | 11 +- .../Breed/Slug/CatCaracteristics.tsx | 151 ++++-------------- tailwind.config.ts | 1 + 5 files changed, 53 insertions(+), 128 deletions(-) diff --git a/app/breed/[slug]/page.tsx b/app/breed/[slug]/page.tsx index 3e2fa1a..7fb88ab 100644 --- a/app/breed/[slug]/page.tsx +++ b/app/breed/[slug]/page.tsx @@ -68,7 +68,7 @@ const Page: React.FC = ({ params }) => {
{otherImageSrc.map((catImage) => (
( - <> -
- - Temperament: {breed.temperament} - - } - /> -
-
- - Origin: - {breed.origin} - - } - /> -
-
- - Life Span: {breed.life_span} years - - } - /> -
-
- - Adaptability: - {breed.adaptability} - - } - /> -
-
- - Affection Level: - {breed.affection_level} - - } - /> -
-
- - Child Friendly: - {breed.child_friendly} - - } - /> -
-
- - Grooming: - {breed.grooming} - - } - /> -
-
- - Intelligence: - {breed.intelligence} - - } - /> -
-
- - Health issues: - {breed.health_issues} - - } - /> -
-
- - Social needs: - {breed.social_needs} - - } - /> -
-
- - Stranger friendly: - {breed.stranger_friendly} - - } - /> -
- -); +const CatCaracteristics = ({ breed }: { breed: Cat }) => { + const stars = Array(5).fill(0); + + return ( + <> + {catCaracteristics.map((caracteristic) => ( +
+
+ {caracteristic.name}: + {caracteristic.rating === false && breed[caracteristic.data]} + {caracteristic.rating === true && + stars.map((_, index) => ( +
+
index ? "bg-cioccolato" : "bg-alto"}`} + >
+
+ ))} + {caracteristic.name === "Life Span" && " years"} +
+
+ ))} + + ); +}; export default CatCaracteristics; diff --git a/tailwind.config.ts b/tailwind.config.ts index dabf306..f703992 100644 --- a/tailwind.config.ts +++ b/tailwind.config.ts @@ -17,6 +17,7 @@ const config: Config = { westar: "#E3E1DC", cioccolato: "#4D270C", calico: "#DEC68B", + alto: "#E0E0E0", }, keyframes: { shimmer: {