Files
blitzkit/src/app/tools/tankopedia/page.tsx
T

277 lines
9.4 KiB
TypeScript
Raw Normal View History

2024-06-19 13:58:37 -05:00
import {
Button,
Flex,
Grid,
Heading,
IconButton,
RadioGroup,
Separator,
Text,
} from '@radix-ui/themes';
import { range, times } from 'lodash';
2024-06-18 14:28:20 -05:00
import { use } from 'react';
import { classIcons } from '../../../components/ClassIcon';
import { Link } from '../../../components/Link';
2023-11-30 12:21:20 -06:00
import PageWrapper from '../../../components/PageWrapper';
2024-06-18 14:28:20 -05:00
import { TANK_CLASSES } from '../../../components/Tanks/components/Item/constants';
import { asset } from '../../../core/blitzkit/asset';
import {
NATIONS,
Tier,
tanksDefinitionsArray,
} from '../../../core/blitzkit/tankDefinitions';
import { TIER_ROMAN_NUMERALS } from '../../../core/blitzkit/tankDefinitions/constants';
import { tankIcon } from '../../../core/blitzkit/tankIcon';
2024-06-18 20:43:21 -05:00
import strings from '../../../lang/en-US.json';
2024-06-18 14:28:20 -05:00
import { treeTypeOrder } from './components/TankSearch/constants';
2023-11-30 12:21:20 -06:00
2023-11-30 18:00:48 -06:00
export default function Page() {
2024-06-18 14:28:20 -05:00
const awaitedTanksDefinitionsArray = use(tanksDefinitionsArray);
const awaitedNations = use(NATIONS);
2023-12-03 19:45:43 -06:00
2023-11-30 12:21:20 -06:00
return (
2024-06-19 13:58:37 -05:00
<PageWrapper color="purple" size={1028 + 256}>
<Flex gap="8">
<Flex direction="column" gap="4" align="start">
<Text mb="-3" weight="bold">
Class
</Text>
<Flex
direction="column"
overflow="hidden"
style={{
borderRadius: 'var(--radius-4)',
}}
>
<Flex>
{times(5, (index) => {
const tier = (index + 1) as Tier;
2024-04-19 09:26:53 -05:00
2024-06-19 13:58:37 -05:00
return (
<Button
2024-06-19 20:23:44 -05:00
key={tier}
2024-06-19 13:58:37 -05:00
variant="soft"
radius="none"
color="gray"
highContrast
style={{
width: 32,
}}
>
{TIER_ROMAN_NUMERALS[tier]}
</Button>
);
})}
</Flex>
<Flex>
{times(5, (index) => {
const tier = (index + 6) as Tier;
2024-06-18 14:28:20 -05:00
2024-06-19 13:58:37 -05:00
return (
<Button
2024-06-19 20:23:44 -05:00
key={tier}
2024-06-19 13:58:37 -05:00
variant="soft"
radius="none"
color="gray"
highContrast
style={{
width: 32,
}}
>
{TIER_ROMAN_NUMERALS[tier]}
</Button>
);
})}
</Flex>
</Flex>
2024-06-18 14:28:20 -05:00
2024-06-19 13:58:37 -05:00
<Text mb="-3" weight="bold">
Type
</Text>
<Flex
overflow="hidden"
style={{
borderRadius: 'var(--radius-full)',
}}
>
{TANK_CLASSES.map((tankClass) => {
const Icon = classIcons[tankClass];
2024-06-18 14:28:20 -05:00
2024-06-19 13:58:37 -05:00
return (
<IconButton
2024-06-19 20:23:44 -05:00
key={tankClass}
2024-06-19 13:58:37 -05:00
variant="soft"
radius="none"
color="gray"
highContrast
>
<Icon style={{ width: '1em', height: '1em' }} />
</IconButton>
);
})}
</Flex>
2024-06-18 14:28:20 -05:00
2024-06-19 13:58:37 -05:00
<Text mb="-3" weight="bold">
Nation
</Text>
<Flex>
{awaitedNations.map((nation) => (
<IconButton
variant="soft"
color="gray"
highContrast
radius="none"
>
{/* TODO: trim icons */}
<img src={asset(`flags/circle/${nation}.webp`)} />
</IconButton>
))}
</Flex>
2024-06-18 14:28:20 -05:00
2024-06-19 13:58:37 -05:00
<Text mb="-3" weight="bold">
Test tanks
</Text>
<RadioGroup.Root defaultValue="include">
<RadioGroup.Item value="include">Include</RadioGroup.Item>
<RadioGroup.Item value="exclude">Exclude</RadioGroup.Item>
<RadioGroup.Item value="only">Only</RadioGroup.Item>
</RadioGroup.Root>
</Flex>
2024-06-18 14:28:20 -05:00
2024-06-19 13:58:37 -05:00
<Flex direction="column" gap="8" mt="4" flexGrow="1">
{range(10, 0).map((tierUntyped) => {
const tier = tierUntyped as Tier;
const tierTanks = awaitedTanksDefinitionsArray.filter(
(tank) => tank.tier === tier,
);
2024-06-18 14:28:20 -05:00
2024-06-19 13:58:37 -05:00
return (
<Flex key={tier} direction="column" gap="4">
<Heading color="gray" mb="4">
Tier {TIER_ROMAN_NUMERALS[tier]}
</Heading>
2024-06-18 20:43:21 -05:00
2024-06-19 13:58:37 -05:00
<Flex direction="column" gap="8">
{awaitedNations.map((nation, nationIndex) => {
const nationTanks = tierTanks
.filter((tank) => tank.nation === nation)
.sort(
(a, b) =>
treeTypeOrder.indexOf(a.treeType) -
treeTypeOrder.indexOf(b.treeType),
)
.sort(
(a, b) =>
TANK_CLASSES.indexOf(a.class) -
TANK_CLASSES.indexOf(b.class),
);
2024-06-18 20:43:21 -05:00
2024-06-19 13:58:37 -05:00
if (nationTanks.length === 0) return null;
return (
2024-06-19 20:23:44 -05:00
<Flex key={nation} direction="column" gap="4">
2024-06-19 13:58:37 -05:00
<Flex align="center">
<img
src={asset(`flags/scratched/${nation}.webp`)}
style={{
height: 64,
aspectRatio: '2 / 1',
}}
/>
<Heading size="5" ml="-8" mr="4" wrap="nowrap">
{
strings.common.nations[
nation as keyof typeof strings.common.nations
]
}
</Heading>
<Separator size="4" />
</Flex>
<Grid
flexGrow="1"
columns="repeat(auto-fill, minmax(80px, 1fr))"
gap="2"
gapY="4"
key={nation}
>
{nationTanks.map((tank) => {
const Icon = classIcons[tank.class];
return (
<Link
2024-06-19 20:23:44 -05:00
key={tank.id}
2024-06-19 13:58:37 -05:00
size="1"
color={
tank.treeType === 'collector'
? 'blue'
: tank.treeType === 'premium'
? 'amber'
: 'gray'
}
highContrast={tank.treeType === 'researchable'}
underline="hover"
href={`/tools/tankopedia/${tank.id}`}
2024-06-18 20:43:21 -05:00
style={{
2024-06-19 13:58:37 -05:00
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
gap: 'var(--space-2)',
2024-06-18 20:43:21 -05:00
}}
>
2024-06-19 13:58:37 -05:00
<img
alt={tank.name}
src={tankIcon(tank.id)}
height={64}
2024-06-18 20:43:21 -05:00
style={{
2024-06-19 13:58:37 -05:00
width: '100%',
objectPosition: 'center',
objectFit: 'contain',
2024-06-18 20:43:21 -05:00
}}
/>
2024-06-19 13:58:37 -05:00
<Flex
justify="center"
gap="1"
2024-06-18 20:43:21 -05:00
align="center"
2024-06-19 13:58:37 -05:00
overflow="hidden"
width="100%"
maxWidth="100%"
2024-06-18 20:43:21 -05:00
>
2024-06-19 13:58:37 -05:00
<Icon
style={{
width: '1em',
height: '1em',
minWidth: '1em',
minHeight: '1em',
}}
/>
<Text
align="center"
style={{
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
}}
>
{tank.name}
</Text>
</Flex>
</Link>
);
})}
</Grid>
</Flex>
);
})}
</Flex>
2024-06-18 14:28:20 -05:00
</Flex>
2024-06-19 13:58:37 -05:00
);
})}
</Flex>
2024-06-18 14:28:20 -05:00
</Flex>
2023-11-30 12:21:20 -06:00
</PageWrapper>
);
}