mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-20 20:35:43 +01:00
feat: better hero
This commit is contained in:
1 parent
cd0769675e
commit
c3e449745e
8 files changed
+176
-206
No files matched your search
@@ -1,16 +1,16 @@
|
||||
import { ChevronLeftIcon, MixIcon } from '@radix-ui/react-icons';
|
||||
import { Box, Button, Flex, Heading } from '@radix-ui/themes';
|
||||
import Link from 'next/link';
|
||||
import { Box, Flex, Heading, Text } from '@radix-ui/themes';
|
||||
import { Suspense, use, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { ThicknessRange } from '../../../../../../components/Armor/components/StaticArmor';
|
||||
import { classIcons } from '../../../../../../components/ClassIcon';
|
||||
import { NAVBAR_HEIGHT } from '../../../../../../components/Navbar/index.css';
|
||||
import { resolveNearPenetration } from '../../../../../../core/blitz/resolveNearPenetration';
|
||||
import { tankDefinitions } from '../../../../../../core/blitzkit/tankDefinitions';
|
||||
import { Var } from '../../../../../../core/blitzkit/var';
|
||||
import { useFullScreen } from '../../../../../../hooks/useFullScreen';
|
||||
import * as Duel from '../../../../../../stores/duel';
|
||||
import { Options } from './components/Options';
|
||||
import { TankSandbox } from './TankSandbox';
|
||||
import { TankSandboxLoader } from './TankSandboxLoader';
|
||||
import { Options } from './components/Options';
|
||||
|
||||
interface HeroSectionProps {
|
||||
id: number;
|
||||
@@ -18,13 +18,8 @@ interface HeroSectionProps {
|
||||
|
||||
export function HeroSection({ id }: HeroSectionProps) {
|
||||
const canvas = useRef<HTMLCanvasElement>(null);
|
||||
const protagonist = Duel.use((state) => state.protagonist.tank);
|
||||
const antagonist = Duel.use((state) => state.antagonist.tank);
|
||||
const compareTanks =
|
||||
protagonist.id === antagonist.id
|
||||
? [protagonist.id]
|
||||
: [protagonist.id, antagonist.id];
|
||||
const isFullScreen = useFullScreen();
|
||||
const protagonist = Duel.use((state) => state.protagonist.tank);
|
||||
const Icon = classIcons[protagonist.class];
|
||||
const [dummyLoader, setDummyLoader] = useState(true);
|
||||
const treeColor =
|
||||
@@ -58,102 +53,72 @@ export function HeroSection({ id }: HeroSectionProps) {
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Flex
|
||||
justify="center"
|
||||
pt={{ initial: '6', md: '0' }}
|
||||
style={{ background: 'var(--color-surface)', position: 'relative' }}
|
||||
height={{ initial: 'calc(75vh - 4rem)', md: undefined }}
|
||||
minHeight={{ initial: '40rem' }}
|
||||
gap="4"
|
||||
<Box
|
||||
style={{
|
||||
background: isFullScreen
|
||||
? Var('color-background')
|
||||
: Var('color-surface'),
|
||||
zIndex: isFullScreen ? 2 : undefined,
|
||||
}}
|
||||
height={
|
||||
isFullScreen ? '100vh' : `calc(100vh - ${NAVBAR_HEIGHT}px - 8rem)`
|
||||
}
|
||||
width={isFullScreen ? '100vw' : undefined}
|
||||
position={isFullScreen ? 'fixed' : 'relative'}
|
||||
top={isFullScreen ? '0' : undefined}
|
||||
left={isFullScreen ? '0' : undefined}
|
||||
>
|
||||
<Flex
|
||||
direction={{ initial: 'column', md: 'row' }}
|
||||
style={{ maxWidth: '140rem', flex: 1 }}
|
||||
gap={{ initial: '0', md: '6' }}
|
||||
position="absolute"
|
||||
width="100%"
|
||||
height="100%"
|
||||
align="center"
|
||||
direction="column"
|
||||
mt="7"
|
||||
>
|
||||
<Flex
|
||||
align="center"
|
||||
justify="center"
|
||||
flexGrow={{ initial: undefined, md: '1' }}
|
||||
flexBasis="0"
|
||||
<Heading
|
||||
weight="bold"
|
||||
size={{ initial: '8', xs: '9' }}
|
||||
color={treeColor}
|
||||
>
|
||||
<Flex
|
||||
gap="2"
|
||||
direction="column"
|
||||
ml={{ initial: '0', md: '8' }}
|
||||
align={{ initial: 'center', md: 'start' }}
|
||||
justify="center"
|
||||
style={{ height: '100%', userSelect: 'none' }}
|
||||
>
|
||||
<Flex gap="4">
|
||||
<Heading size={{ initial: '8', sm: '9' }} color={treeColor}>
|
||||
<Icon style={{ width: '0.75em', height: '0.75em' }} />{' '}
|
||||
</Heading>
|
||||
|
||||
<Heading
|
||||
size={{ initial: '8', sm: '9' }}
|
||||
align={{ initial: 'center', md: 'left' }}
|
||||
color={treeColor}
|
||||
>
|
||||
{protagonist.name}
|
||||
</Heading>
|
||||
</Flex>
|
||||
|
||||
<Flex gap="4" mt="2" pl="8">
|
||||
<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>
|
||||
<Flex align="center" gap="3">
|
||||
<Icon width="0.75em" height="0.75em" />
|
||||
{tank.name}
|
||||
</Flex>
|
||||
</Flex>
|
||||
|
||||
<Box
|
||||
className="tank-sandbox-container"
|
||||
height={{ initial: undefined, md: '512px' }}
|
||||
style={{
|
||||
flex: 2,
|
||||
position: isFullScreen ? 'fixed' : 'relative',
|
||||
top: isFullScreen ? 0 : undefined,
|
||||
left: isFullScreen ? 0 : undefined,
|
||||
width: isFullScreen ? '100vw' : undefined,
|
||||
height: isFullScreen ? '100vh' : 'auto',
|
||||
zIndex: isFullScreen ? 3 : undefined,
|
||||
background: isFullScreen ? 'var(--color-background)' : undefined,
|
||||
}}
|
||||
>
|
||||
<Box width="100%" height="100%" position="absolute">
|
||||
<Box width="100%" height="100%">
|
||||
<TankSandboxLoader
|
||||
id={id}
|
||||
display={dummyLoader ? 'flex' : 'none'}
|
||||
/>
|
||||
|
||||
<Suspense
|
||||
fallback={
|
||||
<TankSandboxLoader
|
||||
id={id}
|
||||
display={dummyLoader ? 'none' : 'flex'}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<TankSandbox ref={canvas} thicknessRange={thicknessRange} />
|
||||
</Suspense>
|
||||
</Box>
|
||||
|
||||
<Options canvas={canvas} thicknessRange={thicknessRange} />
|
||||
</Box>
|
||||
</Box>
|
||||
</Heading>
|
||||
<Text color="gray" weight="light" mt="1">
|
||||
BlitzKit Tankopedia
|
||||
</Text>
|
||||
</Flex>
|
||||
</Flex>
|
||||
|
||||
<Box
|
||||
position="absolute"
|
||||
width="100%"
|
||||
height="100%"
|
||||
className="tank-sandbox-container"
|
||||
>
|
||||
<Box width="100%" height="100%" position="absolute">
|
||||
<Box width="100%" height="100%">
|
||||
<TankSandboxLoader
|
||||
id={id}
|
||||
display={dummyLoader ? 'flex' : 'none'}
|
||||
/>
|
||||
|
||||
<Suspense
|
||||
fallback={
|
||||
<TankSandboxLoader
|
||||
id={id}
|
||||
display={dummyLoader ? 'none' : 'flex'}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<TankSandbox ref={canvas} thicknessRange={thicknessRange} />
|
||||
</Suspense>
|
||||
</Box>
|
||||
|
||||
<Options canvas={canvas} thicknessRange={thicknessRange} />
|
||||
</Box>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user