2021-08-19 12:27:01 +00:00
|
|
|
import * as SliderPrimitive from "@radix-ui/react-slider";
|
2021-09-22 19:52:38 +00:00
|
|
|
import React from "react";
|
2021-08-13 07:59:48 +00:00
|
|
|
|
2021-10-16 10:42:28 +00:00
|
|
|
const Slider = ({
|
|
|
|
value,
|
|
|
|
label,
|
|
|
|
changeHandler,
|
|
|
|
...props
|
|
|
|
}: Omit<SliderPrimitive.SliderProps, "value"> & {
|
|
|
|
value: number;
|
|
|
|
label: string;
|
|
|
|
changeHandler: (value: number) => void;
|
|
|
|
}) => (
|
2021-08-19 12:27:01 +00:00
|
|
|
<SliderPrimitive.Root
|
2021-10-16 10:42:28 +00:00
|
|
|
className="mt-2 slider"
|
2021-08-19 12:27:01 +00:00
|
|
|
value={[value]}
|
2021-08-13 07:59:48 +00:00
|
|
|
aria-label={label}
|
2021-10-16 10:42:28 +00:00
|
|
|
onValueChange={(value: number[]) => changeHandler(value[0] ?? value)}
|
|
|
|
{...props}>
|
2021-08-19 12:27:01 +00:00
|
|
|
<SliderPrimitive.Track className="slider-track">
|
|
|
|
<SliderPrimitive.Range className="slider-range" />
|
|
|
|
</SliderPrimitive.Track>
|
|
|
|
<SliderPrimitive.Thumb className="slider-thumb" />
|
2021-08-13 07:59:48 +00:00
|
|
|
</SliderPrimitive.Root>
|
|
|
|
);
|
|
|
|
|
|
|
|
export default Slider;
|