2024-06-23 20:45:56 -05:00
|
|
|
import { Flex, Text } from '@radix-ui/themes';
|
|
|
|
|
import { Icon } from '@radix-ui/themes/dist/cjs/components/callout';
|
|
|
|
|
import { assignInlineVars } from '@vanilla-extract/dynamic';
|
|
|
|
|
import { Link } from '../../../../components/Link';
|
2024-06-21 14:03:20 -05:00
|
|
|
import { asset } from '../../../../core/blitzkit/asset';
|
|
|
|
|
import { TankDefinition } from '../../../../core/blitzkit/tankDefinitions';
|
|
|
|
|
import { tankIcon } from '../../../../core/blitzkit/tankIcon';
|
2024-06-23 20:45:56 -05:00
|
|
|
import * as styles from './TankCard.css';
|
2024-06-21 14:03:20 -05:00
|
|
|
|
|
|
|
|
interface TankCardProps {
|
|
|
|
|
tank: TankDefinition;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function TankCard({ tank }: TankCardProps) {
|
2024-06-23 20:45:56 -05:00
|
|
|
// const awaitedModelDefinitions = use(modelDefinitions);
|
|
|
|
|
// const Icon = classIcons[tank.class];
|
2024-06-24 13:54:08 -05:00
|
|
|
// const link = useRef<HTMLAnchorElement>(null);
|
2024-06-23 20:45:56 -05:00
|
|
|
// const sortBy = useTankopediaFilters((state) => state.sort.by);
|
|
|
|
|
// const discriminator = useMemo(() => {
|
|
|
|
|
// if (sortBy.startsWith('meta')) return undefined;
|
2024-06-22 16:39:31 -05:00
|
|
|
|
2024-06-23 20:45:56 -05:00
|
|
|
// const turret = tank.turrets.at(-1)!;
|
|
|
|
|
// const gun = turret.guns.at(-1)!;
|
|
|
|
|
// const shell = gun.shells[0];
|
|
|
|
|
// const tracks = tank.tracks.at(-1)!;
|
|
|
|
|
// const tankModelDefinition = awaitedModelDefinitions[tank.id];
|
2024-06-22 16:39:31 -05:00
|
|
|
|
2024-06-23 20:45:56 -05:00
|
|
|
// switch (sortBy) {
|
|
|
|
|
// case 'fire.aimTime':
|
|
|
|
|
// return `${gun.aimTime.toFixed(2)}s`;
|
|
|
|
|
// case 'fire.caliber':
|
|
|
|
|
// return `${shell.caliber.toFixed(0)}mm`;
|
|
|
|
|
// case 'fire.damage':
|
|
|
|
|
// return `${shell.damage.armor.toFixed(0)}hp`;
|
|
|
|
|
// case 'fire.dispersionMoving':
|
|
|
|
|
// return `+ ${tracks.dispersion.move.toFixed(3)}`;
|
|
|
|
|
// case 'fire.dispersionStill':
|
|
|
|
|
// return gun.dispersion.base.toFixed(3);
|
|
|
|
|
// case 'fire.dpm':
|
|
|
|
|
// return resolveDpm(gun, shell).toFixed(0);
|
|
|
|
|
// case 'fire.gunDepression':
|
|
|
|
|
// return awaitedModelDefinitions;
|
|
|
|
|
// }
|
|
|
|
|
// }, [sortBy]);
|
2024-06-21 14:03:20 -05:00
|
|
|
|
2024-06-24 13:54:08 -05:00
|
|
|
// useEffect(() => {
|
|
|
|
|
// const unsubscribe = useTankopediaFilters.subscribe((filters) => {
|
|
|
|
|
// if (!link.current) return;
|
2024-06-21 14:03:20 -05:00
|
|
|
|
2024-06-24 13:54:08 -05:00
|
|
|
// const visible = tankopediaFilterTank(filters, tank);
|
|
|
|
|
// link.current.style.display = visible ? 'flex' : 'none';
|
|
|
|
|
// });
|
2024-06-21 14:03:20 -05:00
|
|
|
|
2024-06-24 13:54:08 -05:00
|
|
|
// return unsubscribe;
|
|
|
|
|
// }, []);
|
2024-06-21 14:03:20 -05:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Link
|
2024-06-24 13:54:08 -05:00
|
|
|
// ref={link}
|
2024-06-21 14:03:20 -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-23 20:45:56 -05:00
|
|
|
className={styles.card}
|
|
|
|
|
style={assignInlineVars({
|
|
|
|
|
[styles.cardBackgroundVar]: `top left / contain no-repeat url(${asset(`flags/scratched/${tank.nation}.webp`)})`,
|
|
|
|
|
})}
|
2024-06-21 14:03:20 -05:00
|
|
|
>
|
2024-06-23 20:45:56 -05:00
|
|
|
<img alt={tank.name} src={tankIcon(tank.id)} className={styles.image} />
|
2024-06-21 14:03:20 -05:00
|
|
|
|
|
|
|
|
<Flex
|
|
|
|
|
justify="center"
|
|
|
|
|
gap="1"
|
|
|
|
|
align="center"
|
|
|
|
|
overflow="hidden"
|
|
|
|
|
width="100%"
|
|
|
|
|
maxWidth="100%"
|
|
|
|
|
>
|
2024-06-23 20:45:56 -05:00
|
|
|
<Icon className={styles.classIcon} />
|
|
|
|
|
<Text align="center" className={styles.name}>
|
2024-06-21 14:03:20 -05:00
|
|
|
{tank.name}
|
|
|
|
|
</Text>
|
|
|
|
|
</Flex>
|
2024-06-22 16:39:31 -05:00
|
|
|
|
2024-06-23 20:45:56 -05:00
|
|
|
{/* {discriminator && (
|
2024-06-22 16:39:31 -05:00
|
|
|
<Text
|
|
|
|
|
mt="-2"
|
|
|
|
|
color="gray"
|
|
|
|
|
align="center"
|
|
|
|
|
style={{
|
|
|
|
|
whiteSpace: 'nowrap',
|
|
|
|
|
overflow: 'hidden',
|
|
|
|
|
textOverflow: 'ellipsis',
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{discriminator}
|
|
|
|
|
</Text>
|
2024-06-23 20:45:56 -05:00
|
|
|
)} */}
|
2024-06-21 14:03:20 -05:00
|
|
|
</Link>
|
|
|
|
|
);
|
|
|
|
|
}
|