Files
blitzkit/src/app/tools/tankopedia/[id]/components/Model/HeroSection.tsx
T

129 lines
4.1 KiB
TypeScript
Raw Normal View History

2024-05-04 16:53:26 -05:00
import { ChevronLeftIcon, MixIcon } from '@radix-ui/react-icons';
2024-07-09 20:53:00 -05:00
import { Box, Button, Flex, Heading, Text } from '@radix-ui/themes';
2024-05-03 21:17:31 -05:00
import Link from 'next/link';
2024-06-29 12:12:10 -05:00
import { classIcons } from '../../../../../../components/ClassIcon';
2024-05-03 12:57:04 -05:00
import { TIER_ROMAN_NUMERALS } from '../../../../../../core/blitzkit/tankDefinitions/constants';
2024-05-04 17:02:03 -05:00
import { useFullScreen } from '../../../../../../hooks/useFullScreen';
2024-05-03 12:57:04 -05:00
import strings from '../../../../../../lang/en-US.json';
2024-07-09 20:35:36 -05:00
import * as Duel from '../../../../../../stores/duel';
2024-05-03 12:57:04 -05:00
import { TankSandbox } from './TankSandbox';
2024-05-03 17:07:27 -05:00
import { Options } from './components/Options';
2024-05-03 12:57:04 -05:00
export function HeroSection() {
2024-07-09 20:35:36 -05:00
const protagonist = Duel.use((state) => state.protagonist!.tank);
const antagonist = Duel.use((state) => state.antagonist!.tank);
2024-05-03 21:17:31 -05:00
const compareTanks =
2024-06-29 12:12:10 -05:00
protagonist.id === antagonist.id
? [protagonist.id]
: [protagonist.id, antagonist.id];
2024-05-04 17:02:03 -05:00
const isFullScreen = useFullScreen();
2024-06-29 12:12:10 -05:00
const Icon = classIcons[protagonist.class];
2024-05-03 12:57:04 -05:00
return (
<Flex
justify="center"
2024-07-09 20:53:00 -05:00
pt={{ initial: '6', md: '0' }}
style={{ background: 'var(--color-surface)', position: 'relative' }}
height={{ initial: 'calc(75vh - 64px)', md: undefined }}
2024-05-03 20:49:05 -05:00
gap="4"
2024-05-03 12:57:04 -05:00
>
<Flex
2024-07-09 20:53:00 -05:00
direction={{ initial: 'column', md: 'row' }}
style={{ maxWidth: 1600, flex: 1 }}
2024-05-03 12:57:04 -05:00
>
<Flex
2024-05-03 17:26:14 -05:00
align="center"
2024-05-03 12:57:04 -05:00
justify="center"
2024-07-09 20:53:00 -05:00
flexGrow={{ initial: undefined, md: '1' }}
flexBasis="0"
2024-05-03 12:57:04 -05:00
>
2024-05-03 19:03:25 -05:00
<Flex
2024-07-09 20:53:00 -05:00
gap={{ initial: '2', md: '4' }}
2024-05-03 19:03:25 -05:00
direction="column"
2024-07-09 20:53:00 -05:00
ml={{ initial: '0', md: '8' }}
2024-07-09 21:01:09 -05:00
align={{ initial: 'center', md: 'start' }}
2024-05-04 16:53:26 -05:00
justify="center"
style={{
height: '100%',
}}
2024-05-03 19:03:25 -05:00
>
2024-06-18 20:43:21 -05:00
<Heading
2024-07-09 20:53:00 -05:00
size={{ initial: '8', md: '9' }}
2024-07-09 21:01:09 -05:00
align={{ initial: 'center', md: 'left' }}
2024-06-29 12:12:10 -05:00
color={
protagonist.treeType === 'collector'
? 'blue'
: protagonist.treeType === 'premium'
? 'amber'
: undefined
}
2024-06-18 20:43:21 -05:00
>
2024-06-29 12:12:10 -05:00
<Icon style={{ width: '0.75em', height: '0.75em' }} />{' '}
2024-07-09 21:01:09 -05:00
{protagonist.name}
2024-05-03 21:17:31 -05:00
</Heading>
2024-05-04 16:53:26 -05:00
2024-07-09 21:01:09 -05:00
<Text color="gray" ml={{ initial: '0', md: '9' }}>
2024-06-29 12:12:10 -05:00
Tier {TIER_ROMAN_NUMERALS[protagonist.tier]}{' '}
2024-05-03 17:42:28 -05:00
{
(strings.common.nations_adjectives as Record<string, string>)[
2024-06-29 12:12:10 -05:00
protagonist.nation
2024-05-03 17:42:28 -05:00
]
}{' '}
2024-06-29 12:12:10 -05:00
{strings.common.tank_class_short[protagonist.class]}
2024-05-03 17:26:14 -05:00
</Text>
2024-05-03 21:17:31 -05:00
2024-07-09 21:01:09 -05:00
<Flex gap="4" ml={{ initial: '0', md: '9' }} mt="-1">
2024-05-04 16:53:26 -05:00
<Link href="/tools/tankopedia">
<Button variant="ghost" size="1" ml="-1">
<ChevronLeftIcon />
Back
</Button>
</Link>
<Link href={`/tools/compare?tanks=${compareTanks.join('%2C')}`}>
<Button variant="ghost" size="1">
<MixIcon />
Compare
</Button>
</Link>
</Flex>
2024-05-03 17:26:14 -05:00
</Flex>
2024-05-03 12:57:04 -05:00
</Flex>
2024-07-09 20:53:00 -05:00
<Box
2024-05-04 17:14:08 -05:00
className="tank-sandbox-container"
2024-07-09 20:53:00 -05:00
height={{ initial: undefined, md: '512px' }}
2024-05-03 12:57:04 -05:00
style={{
2024-05-03 20:49:05 -05:00
flex: 2,
2024-05-04 17:02:03 -05:00
position: isFullScreen ? 'fixed' : 'relative',
top: isFullScreen ? 0 : undefined,
left: isFullScreen ? 0 : undefined,
width: isFullScreen ? '100vw' : undefined,
2024-07-09 20:53:00 -05:00
height: isFullScreen ? '100vh' : 'auto',
2024-05-04 17:02:03 -05:00
zIndex: isFullScreen ? 3 : undefined,
2024-07-09 20:53:00 -05:00
background: isFullScreen ? 'var(--color-background)' : undefined,
2024-05-03 12:57:04 -05:00
}}
>
<div
style={{
width: '100%',
height: '100%',
position: 'absolute',
}}
>
2024-05-03 17:35:59 -05:00
<div
style={{
width: '100%',
height: '100%',
}}
>
<TankSandbox />
</div>
2024-05-03 17:52:45 -05:00
<Options />
2024-05-03 17:35:59 -05:00
</div>
2024-07-09 20:53:00 -05:00
</Box>
2024-05-03 12:57:04 -05:00
</Flex>
</Flex>
);
}