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-08-07 12:03:45 -05:00
|
|
|
import { BreakdownEmbedState } from '../app/tools/embed/customize/breakdown/page';
|
2024-08-05 14:25:12 -05:00
|
|
|
import {
|
|
|
|
|
toColorVar,
|
|
|
|
|
toRadiusVar,
|
|
|
|
|
toWidthVar,
|
|
|
|
|
} from '../app/tools/embed/utilities';
|
2024-08-05 12:52:40 -05:00
|
|
|
import { TankDefinition } from '../core/blitzkit/tankDefinitions';
|
2024-08-06 13:33:39 -05:00
|
|
|
import { ClassHeavy } from './ClassIcon/components/ClassHeavy';
|
|
|
|
|
import { ClassLight } from './ClassIcon/components/ClassLight';
|
|
|
|
|
import { ClassMedium } from './ClassIcon/components/ClassMedium';
|
|
|
|
|
import { ClassTankDestroyer } from './ClassIcon/components/ClassTankDestroyer';
|
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
|
|
|
state: BreakdownEmbedState;
|
2024-08-05 12:52:40 -05:00
|
|
|
}
|
|
|
|
|
|
2024-08-07 12:03:45 -05:00
|
|
|
export function BreakdownEmbedWrapper({
|
|
|
|
|
children,
|
|
|
|
|
state,
|
|
|
|
|
}: BreakdownEmbedWrapperProps) {
|
2024-08-05 12:52:40 -05:00
|
|
|
return (
|
2024-08-05 14:25:12 -05:00
|
|
|
<Flex
|
|
|
|
|
direction="column"
|
|
|
|
|
gap={state.listGap}
|
|
|
|
|
width={toWidthVar(state.listWidth)}
|
|
|
|
|
>
|
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-07 12:03:45 -05:00
|
|
|
state: BreakdownEmbedState;
|
2024-08-05 12:52:40 -05:00
|
|
|
}
|
|
|
|
|
|
2024-08-07 12:03:45 -05:00
|
|
|
export function BreakdownEmbedCard({ tank, state }: BreakdownEmbedCardProps) {
|
2024-08-06 13:33:39 -05:00
|
|
|
const { color: cardTitleColor, ...restCardTitleProps } = state.cardTitle;
|
2024-08-05 12:52:40 -05:00
|
|
|
return (
|
|
|
|
|
<Flex
|
|
|
|
|
direction="column"
|
|
|
|
|
style={{
|
2024-08-05 14:25:12 -05:00
|
|
|
borderRadius: toRadiusVar(state.cardRadius),
|
2024-08-05 12:52:40 -05:00
|
|
|
overflow: 'hidden',
|
2024-08-05 14:25:12 -05:00
|
|
|
backgroundColor: toColorVar(state.cardBodyBackgroundColor),
|
2024-08-05 12:52:40 -05:00
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Flex
|
|
|
|
|
justify="center"
|
|
|
|
|
style={{
|
2024-08-05 14:25:12 -05:00
|
|
|
backgroundColor: toColorVar(state.cardHeaderBackgroundColor),
|
2024-08-05 12:52:40 -05:00
|
|
|
}}
|
|
|
|
|
p={state.cardHeaderPadding}
|
|
|
|
|
>
|
2024-08-06 13:33:39 -05:00
|
|
|
<Text
|
|
|
|
|
color={
|
2024-08-06 14:14:48 -05:00
|
|
|
state.cardTitleTypeColor
|
2024-08-06 13:33:39 -05:00
|
|
|
? tank === null
|
|
|
|
|
? cardTitleColor
|
|
|
|
|
: tank.treeType === 'collector'
|
|
|
|
|
? 'blue'
|
|
|
|
|
: tank.treeType === 'premium'
|
|
|
|
|
? 'amber'
|
|
|
|
|
: cardTitleColor
|
|
|
|
|
: cardTitleColor
|
|
|
|
|
}
|
|
|
|
|
{...restCardTitleProps}
|
|
|
|
|
>
|
|
|
|
|
<Flex align="center" gap="1">
|
2024-08-06 14:14:48 -05:00
|
|
|
{tank !== null && state.cardTitleClassIcon && (
|
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
|
|
|
|
|
|
|
|
<Flex p={state.cardBodyPadding}>
|
|
|
|
|
{times(4, (index) => {
|
|
|
|
|
const column = (index + 1) as 1 | 2 | 3 | 4;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Flex
|
|
|
|
|
direction="column"
|
|
|
|
|
align="center"
|
|
|
|
|
gap={state.columnGap}
|
|
|
|
|
flexGrow="1"
|
|
|
|
|
>
|
2024-08-06 13:33:39 -05:00
|
|
|
<Text {...state.columnValue}>
|
2024-08-05 14:25:12 -05:00
|
|
|
70{state[`column${column}Unit`]}
|
|
|
|
|
</Text>
|
2024-08-06 13:33:39 -05:00
|
|
|
<Text {...state.columnLabel}>
|
2024-08-05 14:25:12 -05:00
|
|
|
{state[`column${column}Label`]}
|
|
|
|
|
</Text>
|
|
|
|
|
</Flex>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</Flex>
|
2024-08-05 12:52:40 -05:00
|
|
|
</Flex>
|
|
|
|
|
);
|
|
|
|
|
}
|