mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 03:29:51 +02:00
33 lines
865 B
TypeScript
33 lines
865 B
TypeScript
import { Slider as RadixSlider } from '@radix-ui/themes';
|
|
import type { EmbedPreviewControllerProps } from '../../pages/[...locale]/tools/embed/[embed]/_index';
|
|
import { EmbedState, type RadixSize } from '../../stores/embedState';
|
|
import type {
|
|
EmbedConfigItemType,
|
|
EmbedItemType,
|
|
} from '../../stores/embedState/constants';
|
|
|
|
export function Slider({
|
|
configKey,
|
|
config,
|
|
}: EmbedPreviewControllerProps & {
|
|
config: EmbedConfigItemType<EmbedItemType.Slider>;
|
|
}) {
|
|
const mutateEmbedState = EmbedState.useMutation();
|
|
|
|
return (
|
|
<RadixSlider
|
|
variant="soft"
|
|
min={config.min}
|
|
max={config.max}
|
|
value={[
|
|
EmbedState.use((state) => parseInt(state[configKey] as RadixSize)),
|
|
]}
|
|
onValueChange={([value]) => {
|
|
mutateEmbedState((draft) => {
|
|
draft[configKey] = value;
|
|
});
|
|
}}
|
|
/>
|
|
);
|
|
}
|