2023-11-30 18:00:48 -06:00
|
|
|
'use client';
|
|
|
|
|
|
|
|
|
|
import { blackA, slateDark } from '@radix-ui/colors';
|
|
|
|
|
import { Card, Inset, Text } from '@radix-ui/themes';
|
|
|
|
|
import { useEffect, useState } from 'react';
|
2023-11-30 12:21:20 -06:00
|
|
|
import PageWrapper from '../../../components/PageWrapper';
|
|
|
|
|
import { tankIcon } from '../../../core/blitzkrieg/tankIcon';
|
2023-11-30 18:00:48 -06:00
|
|
|
import {
|
|
|
|
|
BlitzkriegTankopediaEntry,
|
|
|
|
|
tanks,
|
|
|
|
|
} from '../../../core/blitzkrieg/tankopedia';
|
2023-11-30 12:21:20 -06:00
|
|
|
|
|
|
|
|
const sortedTanks = tanks.then((tanks) =>
|
|
|
|
|
tanks.sort((a, b) => b.tier - a.tier),
|
|
|
|
|
);
|
|
|
|
|
|
2023-11-30 18:00:48 -06:00
|
|
|
export default function Page() {
|
|
|
|
|
const [tanks, setTanks] = useState<BlitzkriegTankopediaEntry[]>([]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
(async () => setTanks(await sortedTanks))();
|
|
|
|
|
}, []);
|
2023-11-30 12:21:20 -06:00
|
|
|
|
|
|
|
|
return (
|
2023-11-30 18:00:48 -06:00
|
|
|
<PageWrapper
|
|
|
|
|
style={{
|
|
|
|
|
flexWrap: 'wrap',
|
|
|
|
|
flexDirection: 'row',
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{tanks.map((tank) => (
|
2023-11-30 12:21:20 -06:00
|
|
|
<Card
|
2023-11-30 18:00:48 -06:00
|
|
|
key={tank.id}
|
2023-11-30 12:21:20 -06:00
|
|
|
style={{
|
2023-11-30 18:00:48 -06:00
|
|
|
height: 128,
|
|
|
|
|
width: 256,
|
2023-11-30 12:21:20 -06:00
|
|
|
}}
|
|
|
|
|
>
|
2023-11-30 18:00:48 -06:00
|
|
|
<Inset>
|
|
|
|
|
<a
|
|
|
|
|
href={`/tools/tankopedia/${tank.id}`}
|
2023-11-30 12:21:20 -06:00
|
|
|
style={{
|
2023-11-30 18:00:48 -06:00
|
|
|
// backgroundColor: 'rgba(255, 0, 0, 0.25)',
|
2023-11-30 12:59:37 -06:00
|
|
|
backgroundImage: 'url(https://i.imgur.com/biJPgpm.png)',
|
2023-11-30 18:00:48 -06:00
|
|
|
backgroundSize: '151%',
|
|
|
|
|
width: '100%',
|
|
|
|
|
height: '100%',
|
2023-11-30 12:59:37 -06:00
|
|
|
position: 'relative',
|
2023-11-30 18:00:48 -06:00
|
|
|
display: 'flex',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
justifyContent: 'center',
|
2023-11-30 12:21:20 -06:00
|
|
|
}}
|
2023-11-30 12:59:37 -06:00
|
|
|
>
|
|
|
|
|
<img
|
|
|
|
|
src={tankIcon(tank.id)}
|
|
|
|
|
style={{
|
|
|
|
|
objectFit: 'contain',
|
|
|
|
|
objectPosition: 'left center',
|
|
|
|
|
}}
|
2023-11-30 18:00:48 -06:00
|
|
|
onLoad={(event) => {
|
|
|
|
|
// get image width
|
|
|
|
|
const target = event.target as HTMLImageElement;
|
|
|
|
|
const { naturalWidth } = target;
|
|
|
|
|
|
|
|
|
|
if (naturalWidth === 256) {
|
|
|
|
|
target.style.transform = 'translateX(25%)';
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
style={{
|
|
|
|
|
width: '100%',
|
|
|
|
|
height: '100%',
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
// gradiant with darkest at the bottom
|
|
|
|
|
background: `linear-gradient(#00000000, ${blackA.blackA5})`,
|
|
|
|
|
}}
|
2023-11-30 12:59:37 -06:00
|
|
|
/>
|
2023-11-30 12:21:20 -06:00
|
|
|
|
2023-11-30 12:59:37 -06:00
|
|
|
<Text
|
2023-11-30 18:00:48 -06:00
|
|
|
size="4"
|
|
|
|
|
color={
|
|
|
|
|
tank.tree_type === 'collector'
|
|
|
|
|
? 'cyan'
|
|
|
|
|
: tank.tree_type === 'premium'
|
|
|
|
|
? 'amber'
|
|
|
|
|
: undefined
|
|
|
|
|
}
|
|
|
|
|
weight="medium"
|
2023-11-30 12:59:37 -06:00
|
|
|
style={{
|
2023-11-30 18:00:48 -06:00
|
|
|
color:
|
|
|
|
|
tank.tree_type === 'tech-tree'
|
|
|
|
|
? slateDark.slate11
|
|
|
|
|
: undefined,
|
2023-11-30 12:59:37 -06:00
|
|
|
position: 'absolute',
|
|
|
|
|
bottom: 8,
|
2023-11-30 18:00:48 -06:00
|
|
|
left: 12,
|
2023-11-30 12:59:37 -06:00
|
|
|
}}
|
|
|
|
|
>
|
2023-11-30 12:21:20 -06:00
|
|
|
{tank.name_short ?? tank.name ?? `Unknown tank ${tank.id}`}
|
|
|
|
|
</Text>
|
2023-11-30 18:00:48 -06:00
|
|
|
</a>
|
|
|
|
|
</Inset>
|
2023-11-30 12:21:20 -06:00
|
|
|
</Card>
|
|
|
|
|
))}
|
|
|
|
|
</PageWrapper>
|
|
|
|
|
);
|
|
|
|
|
}
|
2023-11-30 18:00:48 -06:00
|
|
|
|
|
|
|
|
{
|
|
|
|
|
/* <Flex direction="column" justify="center" align="end" gap="2">
|
|
|
|
|
<Flex justify="end" align="center" gap="1">
|
|
|
|
|
{tank.tree_type !== 'tech-tree' && (
|
|
|
|
|
<Badge
|
|
|
|
|
color={tank.tree_type === 'collector' ? 'blue' : 'amber'}
|
|
|
|
|
>
|
|
|
|
|
{tank.tree_type === 'collector' ? 'Collector' : 'Premium'}
|
|
|
|
|
</Badge>
|
|
|
|
|
)}
|
|
|
|
|
<Badge color="indigo">
|
|
|
|
|
{(() => {
|
|
|
|
|
if (tank.type === 'AT-SPG') return 'Tank Destroyer';
|
|
|
|
|
if (tank.type === 'lightTank') return 'Light Tank';
|
|
|
|
|
if (tank.type === 'mediumTank') return 'Medium Tank';
|
|
|
|
|
if (tank.type === 'heavyTank') return 'Heavy Tank';
|
|
|
|
|
})()}
|
|
|
|
|
</Badge>
|
|
|
|
|
</Flex>
|
|
|
|
|
</Flex> */
|
|
|
|
|
}
|