Files
blitzkit/src/components/ModuleButtons/TankComponentButton.tsx
T

88 lines
2.1 KiB
TypeScript
Raw Normal View History

2024-02-12 19:24:34 -06:00
import { Button, Text } from '@radix-ui/themes';
import { ComponentProps, ReactNode } from 'react';
export interface TankComponentButtonProps
extends ComponentProps<typeof Button> {
selected?: boolean;
first?: boolean;
last?: boolean;
rowChild?: boolean;
children?: ReactNode;
discriminator?: ReactNode;
disabled?: boolean;
2024-02-13 19:46:34 -06:00
banner?: string;
2024-03-31 19:27:37 -05:00
special?: boolean;
2024-02-12 19:24:34 -06:00
}
export function TankComponentButton({
2024-04-01 19:05:55 -05:00
variant,
2024-02-12 19:24:34 -06:00
selected,
first = false,
last = false,
rowChild,
discriminator,
2024-03-31 19:27:37 -05:00
special,
2024-02-12 19:24:34 -06:00
children,
2024-02-13 19:46:34 -06:00
banner,
2024-04-01 19:05:55 -05:00
disabled,
style,
2024-02-12 19:24:34 -06:00
...props
}: TankComponentButtonProps) {
return (
<Button
radius="medium"
2024-03-31 19:27:37 -05:00
color={selected ? (special ? 'amber' : undefined) : 'gray'}
2024-04-01 19:05:55 -05:00
variant={variant ?? (selected ? 'surface' : 'soft')}
2024-02-12 19:24:34 -06:00
style={{
padding: 0,
2024-02-13 09:40:00 -06:00
minWidth: 48,
2024-02-12 19:24:34 -06:00
height: 40,
position: 'relative',
borderTopLeftRadius: first ? undefined : 0,
borderTopRightRadius: last ? undefined : 0,
borderBottomLeftRadius: first ? undefined : 0,
borderBottomRightRadius: last ? undefined : 0,
margin: rowChild ? -0.5 : 'unset',
2024-02-13 19:46:34 -06:00
overflow: 'hidden',
2024-04-01 19:05:55 -05:00
cursor: 'unset',
pointerEvents: variant === 'ghost' ? 'none' : undefined,
...style,
2024-02-12 19:24:34 -06:00
}}
2024-04-01 19:05:55 -05:00
disabled={variant === 'ghost' || disabled}
2024-02-13 09:40:00 -06:00
{...props}
2024-02-12 19:24:34 -06:00
>
2024-02-13 19:46:34 -06:00
{banner !== undefined && (
<div
style={{
position: 'absolute',
width: '200%',
height: 12,
backgroundColor: banner,
top: '50%',
left: '-50%',
transform: 'translateY(-50%) rotate(-22.5deg)',
}}
/>
)}
2024-02-12 19:24:34 -06:00
{discriminator !== undefined && (
<Text
size="1"
style={{
textShadow: '0 0 4px black',
zIndex: 1,
position: 'absolute',
top: '50%',
right: 8,
textAlign: 'right',
}}
2024-04-01 19:05:55 -05:00
color={variant === 'ghost' ? 'gray' : undefined}
2024-02-12 19:24:34 -06:00
>
{discriminator}
</Text>
)}
2024-02-13 09:40:00 -06:00
{children}
2024-02-12 19:24:34 -06:00
</Button>
);
}