diff --git a/packages/website-ue/src/components/TankopediaCharacteristics/index.tsx b/packages/website-ue/src/components/TankopediaCharacteristics/index.tsx index 4eb88fa35..6af504f42 100644 --- a/packages/website-ue/src/components/TankopediaCharacteristics/index.tsx +++ b/packages/website-ue/src/components/TankopediaCharacteristics/index.tsx @@ -1,27 +1,41 @@ import { CaretDownIcon, CaretRightIcon } from "@radix-ui/react-icons"; +import { useCharacteristicRenderer } from "../../hooks/useCharacteristicRenderer"; import { useStrings } from "../../hooks/useStrings"; import { Tankopedia } from "../../stores/tankopedia"; +import type { CharacteristicOutput } from "../../tankopedia/characteristics"; import { characteristicsOrder, type CharacteristicRenderConfig, type CharacteristicsGroup, } from "../../tankopedia/characteristicsOrder"; +import type { ComputedCharacteristics } from "../../tankopedia/computeCharacteristics"; import { Heading } from "../Heading"; import { Text } from "../Text"; import styles from "./index.module.css"; -export function TankopediaCharacteristics() { +interface TankopediaCharacteristicsProps { + characteristics: ComputedCharacteristics; +} + +export function TankopediaCharacteristics({ + characteristics, +}: TankopediaCharacteristicsProps) { return (
{characteristicsOrder.map((group) => ( - + ))}
); } -function Group({ group, order }: CharacteristicsGroup) { - const isOpen = Tankopedia.use((state) => state.groups[group]); +interface GroupProps { + group: CharacteristicsGroup; + characteristics: ComputedCharacteristics; +} + +function Group({ group, characteristics }: GroupProps) { + const isOpen = Tankopedia.use((state) => state.groups[group.group]); const strings = useStrings(); return ( @@ -32,7 +46,7 @@ function Group({ group, order }: CharacteristicsGroup) { {isOpen ? : } { (strings.tanks.characteristics.titles as Record)[ - group + group.group ] } @@ -42,20 +56,26 @@ function Group({ group, order }: CharacteristicsGroup) {
- {order.map((item) => - "toy" in item ? : , + {group.order.map((item) => + "toy" in item ? ( + + ) : ( + + ), )}
); } -interface ToyProps { - toy: string; +interface ItemProps { + config: CharacteristicRenderConfig; + value: CharacteristicOutput; } -function Item({ name }: CharacteristicRenderConfig) { +function Item({ config, value }: ItemProps) { const strings = useStrings(); + const renderCharacteristic = useCharacteristicRenderer(); return ( @@ -63,11 +83,11 @@ function Item({ name }: CharacteristicRenderConfig) { { (strings.tanks.characteristics.items as Record)[ - name + config.name ] } - 123 + {renderCharacteristic(value, config)}
@@ -83,6 +103,10 @@ function Item({ name }: CharacteristicRenderConfig) { ); } +interface ToyProps { + toy: string; +} + function Toy({ toy }: ToyProps) { return ; } diff --git a/packages/website-ue/src/pages/[...locale]/tanks/[slug]/_index.tsx b/packages/website-ue/src/pages/[...locale]/tanks/[slug]/_index.tsx index 348f89462..a3c30a4c7 100644 --- a/packages/website-ue/src/pages/[...locale]/tanks/[slug]/_index.tsx +++ b/packages/website-ue/src/pages/[...locale]/tanks/[slug]/_index.tsx @@ -44,7 +44,7 @@ export const Page = withErrorWrapper(
- +
);