diff --git a/src/components/ChevronIcon.astro b/src/components/ChevronIcon.astro new file mode 100644 index 000000000..049798b74 --- /dev/null +++ b/src/components/ChevronIcon.astro @@ -0,0 +1,18 @@ +--- +import type { HTMLAttributes } from "astro/types" + +type Props = HTMLAttributes<"svg"> +--- + + + + + + diff --git a/src/components/CombatCarousel.astro b/src/components/CombatCarousel.astro new file mode 100644 index 000000000..8acd24458 --- /dev/null +++ b/src/components/CombatCarousel.astro @@ -0,0 +1,95 @@ +--- +import CombatSlideCarousel from "@/components/CombatSlideCarousel.astro" +import ChevronIcon from "@/components/ChevronIcon.astro" +import LVDALogo from "@/components/LVDALogo.astro" +import { BOXERS, type Boxer } from "@/consts/boxers" +import { COMBATS } from "@/consts/combats" +--- + + + + + + diff --git a/src/components/CombatSlideCarousel.astro b/src/components/CombatSlideCarousel.astro new file mode 100644 index 000000000..1f86efb31 --- /dev/null +++ b/src/components/CombatSlideCarousel.astro @@ -0,0 +1,183 @@ +--- +import { BOXERS } from "@/consts/boxers" +import type { Combat } from "@/consts/combats" +import type { Boxer } from "@/types/Boxer" + +interface Props { + combat: Combat +} + +const { combat } = Astro.props + +const boxers = BOXERS.filter((boxer) => combat.boxers.includes(boxer.id)) + +const groupAllies = (boxers: Boxer[]): Boxer[][] => { + const teams: Boxer[][] = [] + const boxersClone = [...boxers] + + while (boxersClone.length > 0) { + const boxer = boxersClone.pop() + if (boxer) { + const allies: Boxer[] = [boxer] + + for (let i = boxersClone.length - 1; i >= 0; i--) { + const otherBoxer = boxersClone[i] + if (boxer.allies?.includes(otherBoxer.id)) { + allies.push(otherBoxer) + boxersClone.splice(i, 1) + } + } + + teams.push(allies) // Add the formed team to the list of teams + } + } + + return teams +} + +const teams = groupAllies(boxers) +--- + +
+ { + boxers.length === 2 || boxers.length === 4 ? ( + <> +
+
+ {boxers.length === 2 + ? boxers.map((boxer, key) => ( + + + {boxer.name} + + )) + : boxers.length === 4 && ( + <> + {teams.map((team, key1) => ( +
+ {team.map((boxer, key2) => ( + + + {boxer.name} + + ))} +
+ ))} + + )} +
+
+
+ {boxers.length === 2 ? ( + <> + + {boxers[0].name.toLowerCase()} + +
+ + versus + + + {boxers[1].name.toLowerCase()} + +
+ + ) : ( + boxers.length === 4 && ( +
+ + {teams[0].map((boxer) => boxer.name.toLowerCase()).join(" y ")} + + + versus + + + {teams[1].map((boxer) => boxer.name.toLowerCase()).join(" y ")} + +
+ ) + )} +
+
+
+ + ) : boxers.length > 4 ? ( +
+
+
+
+ {boxers.map((boxer) => ( + + + {boxer.name} + + ))} +
+ el rey de la pista +
+
+
+
+
+ ) : ( + <> + ) + } +
+ + diff --git a/src/components/LVDALogo.astro b/src/components/LVDALogo.astro new file mode 100644 index 000000000..87a4e4d96 --- /dev/null +++ b/src/components/LVDALogo.astro @@ -0,0 +1,16 @@ +--- +import type { HTMLAttributes } from "astro/types" + +type Props = { + className?: string +} & HTMLAttributes<"img"> + +const { className, ...props } = Astro.props +--- + +lvda logo diff --git a/src/pages/combates/index.astro b/src/pages/combates/index.astro index fc3f03e52..7607b959a 100644 --- a/src/pages/combates/index.astro +++ b/src/pages/combates/index.astro @@ -4,6 +4,7 @@ import { Image } from "astro:assets" import Typography from "@/components/Typography.astro" import { BOXERS } from "@/consts/boxers" import { COMBATS, REY_DE_LA_PISTA_ID } from "@/consts/combats" +import CombatCarousel from "@/components/CombatCarousel.astro" import Layout from "@/layouts/Layout.astro" import type { BoxerGender } from "@/types/Boxer" @@ -173,6 +174,9 @@ export const prerender = true } +
+ +
diff --git a/tsconfig.json b/tsconfig.json index d430bf9f9..cf7b7d966 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,14 +1,14 @@ { - "extends": "astro/tsconfigs/strict", - "compilerOptions": { - "baseUrl": ".", - "paths": { - "@/*": [ - "./src/*" - ] - } - }, - "exclude": [ - "public" - ] + "extends": "astro/tsconfigs/strict", + "compilerOptions": { + "baseUrl": ".", + "paths": { + "@/*": [ + "./src/*" + ] + } + }, + "exclude": [ + "public" + ] } \ No newline at end of file