mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: bar coloring
This commit is contained in:
1 parent
cd277fb2f1
commit
e0e5ea8995
2 files changed
+15
-8
No files matched your search
+11
-4
@@ -7,7 +7,7 @@ import {
|
|||||||
fetchTankDefinitions,
|
fetchTankDefinitions,
|
||||||
} from '@blitzkit/core';
|
} from '@blitzkit/core';
|
||||||
import { Flex, Progress, Text } from '@radix-ui/themes';
|
import { Flex, Progress, Text } from '@radix-ui/themes';
|
||||||
import { useMemo } from 'react';
|
import { useMemo, type ComponentProps } from 'react';
|
||||||
import {
|
import {
|
||||||
tankCharacteristics,
|
tankCharacteristics,
|
||||||
type TankCharacteristics,
|
type TankCharacteristics,
|
||||||
@@ -95,6 +95,13 @@ export function InfoWithDelta({
|
|||||||
? othersValue < uhWhatDoICallThisVariable
|
? othersValue < uhWhatDoICallThisVariable
|
||||||
: othersValue > uhWhatDoICallThisVariable;
|
: othersValue > uhWhatDoICallThisVariable;
|
||||||
});
|
});
|
||||||
|
const goodness = (others.length - betterTanks.length) / others.length;
|
||||||
|
let color: ComponentProps<typeof Progress>['color'];
|
||||||
|
|
||||||
|
if (goodness <= 0.25) color = 'red';
|
||||||
|
else if (goodness <= 0.5) color = 'orange';
|
||||||
|
else if (goodness <= 0.75) color = 'yellow';
|
||||||
|
else color = 'green';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex direction="column">
|
<Flex direction="column">
|
||||||
@@ -103,12 +110,12 @@ export function InfoWithDelta({
|
|||||||
</Info>
|
</Info>
|
||||||
|
|
||||||
{!noRanking && (
|
{!noRanking && (
|
||||||
<Flex pl={indent ? '2' : '0'} align="center" gap="2">
|
<Flex pl={indent ? '2' : '0'} align="center" gap="2" mb="2">
|
||||||
<Progress
|
<Progress
|
||||||
variant="soft"
|
variant="soft"
|
||||||
size="1"
|
size="1"
|
||||||
value={((betterTanks.length + 1) / others.length) * 100}
|
value={goodness * 100}
|
||||||
color="gray"
|
color={color}
|
||||||
/>
|
/>
|
||||||
<Text color="gray" size="1">
|
<Text color="gray" size="1">
|
||||||
{betterTanks.length + 1} / {others.length}
|
{betterTanks.length + 1} / {others.length}
|
||||||
|
|||||||
+4
-4
@@ -138,7 +138,7 @@ export function Characteristics() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Flex direction="column" gap="8" style={{ flex: 1 }}>
|
<Flex direction="column" gap="8" style={{ flex: 1 }}>
|
||||||
<Flex direction="column" gap="4">
|
<Flex direction="column" gap="2">
|
||||||
<Flex align="center" gap="4">
|
<Flex align="center" gap="4">
|
||||||
<Heading size="5">Firepower</Heading>
|
<Heading size="5">Firepower</Heading>
|
||||||
|
|
||||||
@@ -520,7 +520,7 @@ export function Characteristics() {
|
|||||||
)}
|
)}
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
<Flex direction="column" gap="4">
|
<Flex direction="column" gap="2">
|
||||||
<Flex gap="2" align="center">
|
<Flex gap="2" align="center">
|
||||||
<Heading size="5">Crew training</Heading>
|
<Heading size="5">Crew training</Heading>
|
||||||
|
|
||||||
@@ -598,7 +598,7 @@ export function Characteristics() {
|
|||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
<Flex direction="column" gap="8" style={{ flex: 1 }}>
|
<Flex direction="column" gap="8" style={{ flex: 1 }}>
|
||||||
<Flex direction="column" gap="4">
|
<Flex direction="column" gap="2">
|
||||||
<Heading size="5">Maneuverability</Heading>
|
<Heading size="5">Maneuverability</Heading>
|
||||||
<Info name="Speed" unit="kph" />
|
<Info name="Speed" unit="kph" />
|
||||||
<InfoWithDelta
|
<InfoWithDelta
|
||||||
@@ -735,7 +735,7 @@ export function Characteristics() {
|
|||||||
/>
|
/>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
<Flex direction="column" gap="4">
|
<Flex direction="column" gap="2">
|
||||||
<Heading size="5">Survivability</Heading>
|
<Heading size="5">Survivability</Heading>
|
||||||
<InfoWithDelta
|
<InfoWithDelta
|
||||||
value="health"
|
value="health"
|
||||||
|
|||||||
Reference in new issue
Block a user