diff --git a/src/app/tools/tankopedia/[id]/components/Model/TechTreeSection.tsx b/src/app/tools/tankopedia/[id]/components/Model/TechTreeSection.tsx index ba181b169..4fa1834f7 100644 --- a/src/app/tools/tankopedia/[id]/components/Model/TechTreeSection.tsx +++ b/src/app/tools/tankopedia/[id]/components/Model/TechTreeSection.tsx @@ -1,13 +1,7 @@ -import { CaretRightIcon, ChevronRightIcon } from '@radix-ui/react-icons'; -import { - ChevronDownIcon, - Flex, - Heading, - ScrollArea, - Text, -} from '@radix-ui/themes'; +import { CaretRightIcon, PlusIcon } from '@radix-ui/react-icons'; +import { Flex, Heading, ScrollArea, Text } from '@radix-ui/themes'; import Link from 'next/link'; -import { ComponentProps, use, useMemo } from 'react'; +import { use, useEffect, useMemo, useRef } from 'react'; import { asset } from '../../../../../../core/blitzkit/asset'; import { TankDefinition, @@ -17,48 +11,7 @@ import { TIER_ROMAN_NUMERALS } from '../../../../../../core/blitzkit/tankDefinit import { formatCompact } from '../../../../../../core/math/formatCompact'; import * as Duel from '../../../../../../stores/duel'; -export function TreeArrow({ - style, - down = false, - ...props -}: ComponentProps & { down?: boolean }) { - const Icon = down ? ChevronDownIcon : ChevronRightIcon; - - return ( - - - - - - ); -} - -function Card({ id }: { id: number }) { +function Card({ id, highlight }: { id: number; highlight?: boolean }) { const awaitedTankDefinitions = use(tankDefinitions); const ancestor = awaitedTankDefinitions[id]; @@ -72,7 +25,20 @@ function Card({ id }: { id: number }) { position: 'relative', }} > - + {ancestor.name} - - XP - - {ancestor.xp === undefined ? 0 : formatCompact(ancestor.xp!)} - - + + + XP + {ancestor.xp === undefined || ancestor.tier === 1 + ? 0 + : formatCompact(ancestor.xp!)} + + - - Silver - + + + Silver {formatCompact(ancestor.price.value)} - - + + @@ -128,9 +98,18 @@ function Card({ id }: { id: number }) { ); } +function Arrow() { + return ( + + + + ); +} + export function TechTreeSection() { const tank = Duel.use((state) => state.protagonist.tank); const awaitedTankDefinitions = use(tankDefinitions); + const container = useRef(null); if ( tank.treeType !== 'researchable' || @@ -145,7 +124,11 @@ export function TechTreeSection() { let ancestor: TankDefinition | undefined = tank; while (ancestor !== undefined) { - if (ancestor.ancestors === undefined || ancestor.ancestors.length === 0) { + if ( + ancestor.tier === 1 || + ancestor.ancestors === undefined || + ancestor.ancestors.length === 0 + ) { ancestor = undefined; break; } else if (ancestor.ancestors.length === 1) { @@ -170,33 +153,54 @@ export function TechTreeSection() { return treeBackwards.reverse(); }, []); - console.log(ancestors); + useEffect(() => { + if (!container.current) return; + + container.current.scrollLeft = container.current.scrollWidth; + }); return ( - Tech tree + + Tech tree + - - + + {ancestors.map((id, index) => ( <> - {index > 0 && ( - - - - )} + {index > 0 && } ))} + + + + + {tank.tier < 10 && ( + <> + + {tank.successors!.map((id, index) => ( + <> + {index > 0 && ( + + + + )} + + + ))} + + )}