2024-08-08 14:22:04 -05:00
|
|
|
import { amberDark, blueDark } from '@radix-ui/colors';
|
2024-08-05 14:25:12 -05:00
|
|
|
import { Flex, Text } from '@radix-ui/themes';
|
|
|
|
|
import { times } from 'lodash';
|
2024-08-05 12:52:40 -05:00
|
|
|
import { ReactNode } from 'react';
|
2024-09-06 22:05:06 -05:00
|
|
|
import { ClassHeavy } from '../../packages/website/src/components/ClassIcon/components/ClassHeavy';
|
|
|
|
|
import { ClassLight } from '../../packages/website/src/components/ClassIcon/components/ClassLight';
|
|
|
|
|
import { ClassMedium } from '../../packages/website/src/components/ClassIcon/components/ClassMedium';
|
|
|
|
|
import { ClassTankDestroyer } from '../../packages/website/src/components/ClassIcon/components/ClassTankDestroyer';
|
2024-09-06 21:45:58 -05:00
|
|
|
import { useEmbedStateCurry } from '../../packages/website/src/stores/embedState/utilities';
|
2024-08-08 14:18:22 -05:00
|
|
|
import { breakdownConfig } from '../app/tools/embed/configurations/breakdown';
|
|
|
|
|
import { toRadiusVar } from '../app/tools/embed/utilities';
|
2024-08-05 12:52:40 -05:00
|
|
|
import { TankDefinition } from '../core/blitzkit/tankDefinitions';
|
2024-08-10 13:29:10 -05:00
|
|
|
import { previewCompositeStat } from '../core/statistics/compositeStats';
|
|
|
|
|
import { CompositeStatsKey } from '../core/statistics/compositeStats/constants';
|
|
|
|
|
import strings from '../lang/en-US.json';
|
2024-08-05 12:52:40 -05:00
|
|
|
|
2024-08-07 12:03:45 -05:00
|
|
|
interface BreakdownEmbedWrapperProps {
|
2024-08-05 12:52:40 -05:00
|
|
|
children: ReactNode;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-07 12:03:45 -05:00
|
|
|
export function BreakdownEmbedWrapper({
|
|
|
|
|
children,
|
|
|
|
|
}: BreakdownEmbedWrapperProps) {
|
2024-08-08 14:18:22 -05:00
|
|
|
const { useState } = useEmbedStateCurry<typeof breakdownConfig>();
|
|
|
|
|
|
2024-08-05 12:52:40 -05:00
|
|
|
return (
|
2024-08-11 13:05:11 -05:00
|
|
|
<Flex direction="column" gap={useState('listGap')} height="100%">
|
2024-08-05 12:52:40 -05:00
|
|
|
{children}
|
|
|
|
|
</Flex>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-07 12:03:45 -05:00
|
|
|
interface BreakdownEmbedCardProps {
|
2024-08-06 13:33:39 -05:00
|
|
|
tank: TankDefinition | null;
|
2024-08-05 12:52:40 -05:00
|
|
|
}
|
|
|
|
|
|
2024-08-08 14:18:22 -05:00
|
|
|
export function BreakdownEmbedCard({ tank }: BreakdownEmbedCardProps) {
|
|
|
|
|
const { useState, useRichText } =
|
|
|
|
|
useEmbedStateCurry<typeof breakdownConfig>();
|
|
|
|
|
|
2024-08-05 12:52:40 -05:00
|
|
|
return (
|
|
|
|
|
<Flex
|
2024-08-11 13:05:11 -05:00
|
|
|
flexShrink="0"
|
2024-08-05 12:52:40 -05:00
|
|
|
direction="column"
|
|
|
|
|
style={{
|
2024-08-08 14:18:22 -05:00
|
|
|
borderRadius: toRadiusVar(useState('cardRadius')),
|
2024-08-05 12:52:40 -05:00
|
|
|
overflow: 'hidden',
|
2024-08-08 14:18:22 -05:00
|
|
|
backgroundColor: useState('cardBodyBackgroundColor'),
|
2024-08-05 12:52:40 -05:00
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Flex
|
|
|
|
|
justify="center"
|
|
|
|
|
style={{
|
2024-08-08 14:18:22 -05:00
|
|
|
backgroundColor: useState('cardHeaderBackgroundColor'),
|
2024-08-05 12:52:40 -05:00
|
|
|
}}
|
2024-08-08 14:18:22 -05:00
|
|
|
p={useState('cardHeaderPadding')}
|
2024-08-05 12:52:40 -05:00
|
|
|
>
|
2024-08-06 13:33:39 -05:00
|
|
|
<Text
|
2024-08-08 14:22:04 -05:00
|
|
|
{...{
|
|
|
|
|
...useRichText('cardTitle'),
|
|
|
|
|
style:
|
|
|
|
|
tank === null
|
|
|
|
|
? undefined
|
|
|
|
|
: tank.treeType === 'researchable' ||
|
2024-09-06 22:05:06 -05:00
|
|
|
!useState('cardTitleTypeColor')
|
|
|
|
|
? undefined
|
|
|
|
|
: {
|
|
|
|
|
color:
|
|
|
|
|
tank.treeType === 'premium'
|
|
|
|
|
? amberDark.amber11
|
|
|
|
|
: blueDark.blue11,
|
|
|
|
|
},
|
2024-08-08 14:18:22 -05:00
|
|
|
}}
|
2024-08-06 13:33:39 -05:00
|
|
|
>
|
|
|
|
|
<Flex align="center" gap="1">
|
2024-08-08 14:18:22 -05:00
|
|
|
{useState('cardTitleClassIcon') && tank !== null && (
|
2024-08-06 13:33:39 -05:00
|
|
|
<>
|
|
|
|
|
{tank.class === 'lightTank' && (
|
|
|
|
|
<ClassLight width="1em" height="1em" />
|
|
|
|
|
)}
|
|
|
|
|
{tank.class === 'mediumTank' && (
|
|
|
|
|
<ClassMedium width="1em" height="1em" />
|
|
|
|
|
)}
|
|
|
|
|
{tank.class === 'heavyTank' && (
|
|
|
|
|
<ClassHeavy width="1em" height="1em" />
|
|
|
|
|
)}
|
|
|
|
|
{tank.class === 'AT-SPG' && (
|
|
|
|
|
<ClassTankDestroyer width="1em" height="1em" />
|
|
|
|
|
)}
|
|
|
|
|
</>
|
|
|
|
|
)}{' '}
|
|
|
|
|
{tank === null ? 'Total' : tank.name}
|
|
|
|
|
</Flex>
|
|
|
|
|
</Text>
|
2024-08-05 12:52:40 -05:00
|
|
|
</Flex>
|
2024-08-05 14:25:12 -05:00
|
|
|
|
2024-08-08 14:18:22 -05:00
|
|
|
<Flex p={useState('cardBodyPadding')}>
|
2024-08-05 14:25:12 -05:00
|
|
|
{times(4, (index) => {
|
|
|
|
|
const column = (index + 1) as 1 | 2 | 3 | 4;
|
2024-08-10 13:29:10 -05:00
|
|
|
const columnState = useState(`column${column}`) as CompositeStatsKey;
|
|
|
|
|
const customLabel = useState(`column${column}CustomLabel`);
|
2024-08-05 14:25:12 -05:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Flex
|
|
|
|
|
direction="column"
|
|
|
|
|
align="center"
|
2024-08-08 14:18:22 -05:00
|
|
|
gap={useState('columnGap')}
|
2024-08-05 14:25:12 -05:00
|
|
|
flexGrow="1"
|
|
|
|
|
>
|
2024-08-08 14:18:22 -05:00
|
|
|
<Text {...useRichText('columnValue')}>
|
2024-08-10 13:29:10 -05:00
|
|
|
{previewCompositeStat(columnState)}
|
2024-08-05 14:25:12 -05:00
|
|
|
</Text>
|
2024-08-08 14:18:22 -05:00
|
|
|
<Text {...useRichText('columnLabel')}>
|
2024-08-10 13:29:10 -05:00
|
|
|
{customLabel.length === 0
|
|
|
|
|
? strings.common.composite_stats[columnState]
|
|
|
|
|
: customLabel}
|
2024-08-05 14:25:12 -05:00
|
|
|
</Text>
|
|
|
|
|
</Flex>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</Flex>
|
2024-08-05 12:52:40 -05:00
|
|
|
</Flex>
|
|
|
|
|
);
|
|
|
|
|
}
|