feat: x axis

This commit is contained in:
TrèsAbhi committed 2025-07-31 20:18:36 -05:00
1 parent 1e91065033
commit 6a92b3ae80
1 file changed
+71 -34
@@ -1,5 +1,5 @@
import type { AssaultRanges } from '@blitzkit/core'; import type { AssaultRanges } from '@blitzkit/core';
import { Box, Card, Flex, Inset, Text } from '@radix-ui/themes'; import { Box, Card, Flex, Text } from '@radix-ui/themes';
import { clamp } from 'three/src/math/MathUtils.js'; import { clamp } from 'three/src/math/MathUtils.js';
import { Var } from '../../../../../../../core/radix/var'; import { Var } from '../../../../../../../core/radix/var';
@@ -7,18 +7,30 @@ interface Props {
ranges: AssaultRanges; ranges: AssaultRanges;
} }
const ASSAULT_RANGE_BAR_HEIGHT = '8rem';
export function AssaultRangesVisualizer({ ranges }: Props) { export function AssaultRangesVisualizer({ ranges }: Props) {
return ( return (
<Card variant="classic"> <Card variant="classic" style={{ aspectRatio: '1 / 1' }}>
<Inset> <Flex
<Flex pl="3" pt="4" direction="column" gap="5"> position="absolute"
<Text size="2" color="gray"> top="0"
Assault shell damage left="0"
</Text> width="100%"
height="100%"
direction="column"
>
<Text m="3" size="2" color="gray">
Assault shell damage
</Text>
<Flex> <Flex
direction="column"
p="3"
pt="5"
pr="5"
style={{ backgroundColor: Var('gray-1') }}
flexGrow="1"
>
<Flex flexGrow="1">
<Box position="relative" width={Var('space-7')}> <Box position="relative" width={Var('space-7')}>
{ranges.ranges.map((range) => ( {ranges.ranges.map((range) => (
<Text <Text
@@ -38,41 +50,66 @@ export function AssaultRangesVisualizer({ ranges }: Props) {
</Box> </Box>
<Flex flexGrow="1" align="end" position="relative"> <Flex flexGrow="1" align="end" position="relative">
{ranges.ranges.map((range, index) => ( {ranges.ranges.map((range, index) => {
<> const mix = clamp(1.5 * (range.factor - 1) + 1, 0, 1) * 100;
const color0 = `color-mix(in hsl, ${Var('tomato-9')}, ${Var('jade-9')} ${mix}%)`;
const color1 = `color-mix(in hsl, ${Var('tomato-7')}, ${Var('jade-7')} ${mix}%)`;
return (
<Box <Box
style={{ style={{
height: `calc(${ASSAULT_RANGE_BAR_HEIGHT} * ${range.factor})`, height: `${range.factor * 100}%`,
backgroundColor: `color-mix(in hsl, ${Var('tomato-9')}, ${Var('jade-9')} ${ background: `linear-gradient(45deg, ${color1}, ${color0})`,
clamp(
1.5 * (range.factor - 1) + 1,
0,
1,
) * 100
}%)`,
}} }}
flexGrow={`${range.distance}`} flexGrow={`${range.distance}`}
key={index} key={index}
/> />
);
})}
<Box {ranges.ranges.map((range, index) => (
position="absolute" <Box
left="0" key={index}
bottom={`${range.factor * 100}%`} position="absolute"
width="100%" left="0"
height="0.5px" bottom={`${range.factor * 100}%`}
style={{ width="100%"
transform: 'translateY(-50%)', height="1pt"
backgroundColor: Var('gray-12'), style={{
}} transform: 'translateY(50%)',
/> backgroundColor: Var('gray-11'),
</> }}
/>
))} ))}
</Flex> </Flex>
</Flex> </Flex>
<Flex ml="7" height={Var('space-7')}>
{ranges.ranges.map((range, index) => (
<Box
position="relative"
key={index}
height="100%"
flexGrow={`${range.distance}`}
>
<Text
size="1"
color="gray"
mt="2"
style={{
position: 'absolute',
right: 0,
transform: 'translateX(50%)',
writingMode: 'vertical-rl',
}}
>
{range.distance}m
</Text>
</Box>
))}
</Flex>
</Flex> </Flex>
</Inset> </Flex>
</Card> </Card>
); );
} }