mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 20:19:49 +02:00
feat: add progress bar to hero section
This commit is contained in:
1 parent
d8a6cac52f
commit
ea744b673a
2 files changed
+39
-10
No files matched your search
+25
@@ -0,0 +1,25 @@
|
|||||||
|
import { Box, Progress } from '@radix-ui/themes';
|
||||||
|
import { useProgress } from '@react-three/drei';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
fontSize?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Tracker({ fontSize }: Props) {
|
||||||
|
const { loaded, total } = useProgress();
|
||||||
|
const progress = total === 0 ? 0 : (loaded / total) * 100;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
position="absolute"
|
||||||
|
left="50%"
|
||||||
|
bottom="0"
|
||||||
|
width="min(100%, 16rem)"
|
||||||
|
style={{
|
||||||
|
transform: `translate(-50%, calc(${fontSize} / 2))`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Progress color="gray" value={progress} />
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
+14
-10
@@ -1,10 +1,11 @@
|
|||||||
import { TankType } from '@blitzkit/core';
|
import { TankType } from '@blitzkit/core';
|
||||||
import { Box, Heading } from '@radix-ui/themes';
|
import { Box, Heading } from '@radix-ui/themes';
|
||||||
import { Var } from '../../../../../core/radix/var';
|
import { Var } from '../../../../../../core/radix/var';
|
||||||
import { useLocale } from '../../../../../hooks/useLocale';
|
import { useLocale } from '../../../../../../hooks/useLocale';
|
||||||
import { Duel } from '../../../../../stores/duel';
|
import { Duel } from '../../../../../../stores/duel';
|
||||||
import type { RadixColor } from '../../../../../stores/embedState';
|
import type { RadixColor } from '../../../../../../stores/embedState';
|
||||||
import { TankopediaEphemeral } from '../../../../../stores/tankopediaEphemeral';
|
import { TankopediaEphemeral } from '../../../../../../stores/tankopediaEphemeral';
|
||||||
|
import { Tracker } from './components/Tracker';
|
||||||
|
|
||||||
interface TitleProps {
|
interface TitleProps {
|
||||||
foreground?: boolean;
|
foreground?: boolean;
|
||||||
@@ -81,6 +82,11 @@ export function Title({ foreground }: TitleProps) {
|
|||||||
: `${nationColors.text}-12`,
|
: `${nationColors.text}-12`,
|
||||||
);
|
);
|
||||||
const name = unwrap(protagonist.name);
|
const name = unwrap(protagonist.name);
|
||||||
|
const fontSize = revealed
|
||||||
|
? disturbed
|
||||||
|
? '2rem'
|
||||||
|
: `min(65vh, ${125 / name.length}vw)`
|
||||||
|
: `min(48vh, ${75 / name.length}vw)`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
@@ -97,11 +103,7 @@ export function Title({ foreground }: TitleProps) {
|
|||||||
fontWeight: 900,
|
fontWeight: 900,
|
||||||
userSelect: 'none',
|
userSelect: 'none',
|
||||||
pointerEvents: 'none',
|
pointerEvents: 'none',
|
||||||
fontSize: revealed
|
fontSize,
|
||||||
? disturbed
|
|
||||||
? '2rem'
|
|
||||||
: `min(65vh, ${125 / name.length}vw)`
|
|
||||||
: `min(48vh, ${75 / name.length}vw)`,
|
|
||||||
whiteSpace: 'nowrap',
|
whiteSpace: 'nowrap',
|
||||||
color: foreground ? Var('gray-a10') : color,
|
color: foreground ? Var('gray-a10') : color,
|
||||||
opacity: foreground && disturbed ? 0 : 1,
|
opacity: foreground && disturbed ? 0 : 1,
|
||||||
@@ -117,6 +119,8 @@ export function Title({ foreground }: TitleProps) {
|
|||||||
>
|
>
|
||||||
{name}
|
{name}
|
||||||
</Heading>
|
</Heading>
|
||||||
|
|
||||||
|
{!revealed && <Tracker fontSize={fontSize} />}
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user