diff --git a/src/app/tools/tankopedia/[id]/components/Model/ModulesSection.tsx b/src/app/tools/tankopedia/[id]/components/Model/ModulesSection.tsx index 26bde0dc9..8a60d112a 100644 --- a/src/app/tools/tankopedia/[id]/components/Model/ModulesSection.tsx +++ b/src/app/tools/tankopedia/[id]/components/Model/ModulesSection.tsx @@ -1,4 +1,10 @@ -import { Flex, Heading, IconButton, Text } from '@radix-ui/themes'; +import { + ChevronDownIcon, + Flex, + Heading, + IconButton, + Text, +} from '@radix-ui/themes'; import Link from 'next/link'; import { use } from 'react'; import PageWrapper from '../../../../../../components/PageWrapper'; @@ -14,7 +20,6 @@ import { import { TIER_ROMAN_NUMERALS } from '../../../../../../core/blitzkit/tankDefinitions/constants'; import { tankIcon } from '../../../../../../core/blitzkit/tankIcon'; import { mutateDuel, useDuel } from '../../../../../../stores/duel'; -import { TreeArrow } from './TechTreeSection'; function ModuleButton({ tier, @@ -162,12 +167,11 @@ export function ModulesSection() { function tree(type: ModuleType, unlocks: Unlock[]) { return ( - - {unlocks.map((unlock) => { + + {unlocks.map((unlock, index) => { + const direction = index < Math.floor(unlocks.length / 2) ? -1 : 1; let module: ModuleDefinition | TankDefinition | undefined = undefined; - console.log(unlock.type); - if (unlock.type === 'chassis') { module = tank.tracks.find((track) => track.id === unlock.id)!; } else if (unlock.type === 'engine') { @@ -187,7 +191,53 @@ export function ModulesSection() { if (module === undefined) return null; return ( - + + {unlock.cost.value > 0 && ( + <> + {unlocks.length > 1 && ( +
0 ? 0 : undefined, + transform: `translateX(${direction * -4}px)`, + }} + /> + )} + + +
+ + + + )} + setByUnlock(unlock)} /> - {(module as ModuleDefinition).unlocks && ( - <> - - {tree(type, (module as ModuleDefinition).unlocks!)} - - )} + {(module as ModuleDefinition).unlocks && + (module as ModuleDefinition).unlocks!.length > 1 && ( +
+ )} + + {(module as ModuleDefinition).unlocks && + tree(type, (module as ModuleDefinition).unlocks!)} ); })} @@ -222,110 +280,35 @@ export function ModulesSection() { Modules - - - - setByUnlock({ - id: turret0.id, - type: 'turret', - cost: { type: 'xp', value: 0 }, - }) - } - /> - - {turret0.unlocks && ( - <> - - {tree('turret', turret0.unlocks)} - - )} - - - - - setByUnlock({ - id: gun0.id, - type: 'gun', - cost: { type: 'xp', value: 0 }, - }) - } - /> - - {gun0.unlocks && ( - <> - - {tree('gun', gun0.unlocks)} - - )} - - - - - setByUnlock({ - id: engine0.id, - type: 'engine', - cost: { type: 'xp', value: 0 }, - }) - } - /> - - {engine0.unlocks && ( - <> - - {tree('engine', engine0.unlocks)} - - )} - - - - - setByUnlock({ - id: track0.id, - type: 'chassis', - cost: { type: 'xp', value: 0 }, - }) - } - /> - - {track0.unlocks && ( - <> - - {tree('chassis', track0.unlocks)} - - )} - + + {tree('turret', [ + { + cost: { type: 'xp', value: 0 }, + id: turret0.id, + type: 'turret', + }, + ])} + {tree('gun', [ + { + cost: { type: 'xp', value: 0 }, + id: gun0.id, + type: 'gun', + }, + ])} + {tree('engine', [ + { + cost: { type: 'xp', value: 0 }, + id: engine0.id, + type: 'engine', + }, + ])} + {tree('chassis', [ + { + cost: { type: 'xp', value: 0 }, + id: track0.id, + type: 'chassis', + }, + ])} ); diff --git a/src/app/tools/tankopedia/[id]/components/Model/TechTreeSection.tsx b/src/app/tools/tankopedia/[id]/components/Model/TechTreeSection.tsx index 2c7401638..5f8d456e0 100644 --- a/src/app/tools/tankopedia/[id]/components/Model/TechTreeSection.tsx +++ b/src/app/tools/tankopedia/[id]/components/Model/TechTreeSection.tsx @@ -1,5 +1,5 @@ import { ChevronRightIcon } from '@radix-ui/react-icons'; -import { Flex, Heading, Text } from '@radix-ui/themes'; +import { ChevronDownIcon, Flex, Heading, Text } from '@radix-ui/themes'; import Link from 'next/link'; import { ComponentProps, use } from 'react'; import PageWrapper from '../../../../../../components/PageWrapper'; @@ -8,7 +8,13 @@ import { tankDefinitions } from '../../../../../../core/blitzkit/tankDefinitions import { TIER_ROMAN_NUMERALS } from '../../../../../../core/blitzkit/tankDefinitions/constants'; import { useDuel } from '../../../../../../stores/duel'; -export function TreeArrow({ style, ...props }: ComponentProps) { +export function TreeArrow({ + style, + down = false, + ...props +}: ComponentProps & { down?: boolean }) { + const Icon = down ? ChevronDownIcon : ChevronRightIcon; + return ( ) { -