mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 11:39:50 +02:00
feat: significant change colors
This commit is contained in:
1 parent
49294d1906
commit
4669fa6ec5
1 file changed
+38
-22
@@ -20,10 +20,13 @@ import { tankCharacteristics } from '../../../core/blitzkrieg/tankCharacteristic
|
|||||||
import { tankDefinitions } from '../../../core/blitzkrieg/tankDefinitions';
|
import { tankDefinitions } from '../../../core/blitzkrieg/tankDefinitions';
|
||||||
import { tankIcon } from '../../../core/blitzkrieg/tankIcon';
|
import { tankIcon } from '../../../core/blitzkrieg/tankIcon';
|
||||||
import { tankToCompareMember } from '../../../core/blitzkrieg/tankToCompareMember';
|
import { tankToCompareMember } from '../../../core/blitzkrieg/tankToCompareMember';
|
||||||
|
import { theme } from '../../../stitches.config';
|
||||||
import mutateCompare, { useCompare } from '../../../stores/compare';
|
import mutateCompare, { useCompare } from '../../../stores/compare';
|
||||||
import { TankSearch } from '../tankopedia/components/TankSearch';
|
import { TankSearch } from '../tankopedia/components/TankSearch';
|
||||||
import { TankControl } from './components/TankControl';
|
import { TankControl } from './components/TankControl';
|
||||||
|
|
||||||
|
const SIGNIFICANT_CHANGE_THRESHOLD = 0.15;
|
||||||
|
|
||||||
export default function Page() {
|
export default function Page() {
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -131,21 +134,16 @@ export default function Page() {
|
|||||||
</Flex>
|
</Flex>
|
||||||
</Table.RowHeaderCell>
|
</Table.RowHeaderCell>
|
||||||
|
|
||||||
{values.map((value, index) => (
|
{values.map((value, index) => {
|
||||||
<Table.Cell key={index}>
|
const deltaPercentage = (value ?? 1) / (values[0] ?? 1) - 1;
|
||||||
<Flex
|
const significantChange =
|
||||||
align="center"
|
Math.abs(deltaPercentage) >= SIGNIFICANT_CHANGE_THRESHOLD;
|
||||||
justify="center"
|
|
||||||
|
return (
|
||||||
|
<Table.Cell
|
||||||
|
key={index}
|
||||||
style={{
|
style={{
|
||||||
width: '100%',
|
backgroundColor:
|
||||||
height: '100%',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Text
|
|
||||||
style={{
|
|
||||||
textAlign: 'center',
|
|
||||||
}}
|
|
||||||
color={
|
|
||||||
index === 0 ||
|
index === 0 ||
|
||||||
value === undefined ||
|
value === undefined ||
|
||||||
values[0] === undefined ||
|
values[0] === undefined ||
|
||||||
@@ -156,15 +154,33 @@ export default function Page() {
|
|||||||
? value > values[0]
|
? value > values[0]
|
||||||
: value < values[0]
|
: value < values[0]
|
||||||
)
|
)
|
||||||
? 'green'
|
? significantChange
|
||||||
: 'red'
|
? theme.colors.componentInteractiveActive_green
|
||||||
}
|
: theme.colors.componentInteractive_green
|
||||||
|
: significantChange
|
||||||
|
? theme.colors.componentInteractiveActive_red
|
||||||
|
: theme.colors.componentInteractive_red,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Flex
|
||||||
|
align="center"
|
||||||
|
justify="center"
|
||||||
|
style={{
|
||||||
|
width: '100%',
|
||||||
|
height: '100%',
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{display ? display(stats[index]) : value}
|
<Text
|
||||||
</Text>
|
style={{
|
||||||
</Flex>
|
textAlign: 'center',
|
||||||
</Table.Cell>
|
}}
|
||||||
))}
|
>
|
||||||
|
{display ? display(stats[index]) : value}
|
||||||
|
</Text>
|
||||||
|
</Flex>
|
||||||
|
</Table.Cell>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</Table.Row>
|
</Table.Row>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user