Files
blitzkit/packages/website/src/components/Embeds/Radius.tsx
T

26 lines
773 B
TypeScript
Raw Normal View History

2024-10-26 14:33:04 -05:00
import { Slider } from '@radix-ui/themes';
import type { EmbedPreviewControllerProps } from '../../pages/[...locale]/embed/[embed]/_index';
2024-10-26 14:33:04 -05:00
import { EmbedState, type RadixRadius } from '../../stores/embedState';
export function Radius({ configKey }: EmbedPreviewControllerProps) {
const mutateEmbedState = EmbedState.useMutation();
return (
<Slider
2025-04-21 17:01:32 -05:00
variant="classic"
2024-10-26 14:33:04 -05:00
min={0}
max={5}
value={[
EmbedState.use((state) => {
const radius = state[configKey] as RadixRadius;
return radius === 'full' ? 5 : parseInt(radius);
}),
]}
onValueChange={([value]) => {
mutateEmbedState((draft) => {
draft[configKey] = value === 5 ? 'full' : `${value}`;
});
}}
/>
);
}