diff --git a/web/components/widgets/slider.tsx b/web/components/widgets/slider.tsx index aebef90a..8a8d3fef 100644 --- a/web/components/widgets/slider.tsx +++ b/web/components/widgets/slider.tsx @@ -1,6 +1,6 @@ import clsx from 'clsx' import * as RxSlider from '@radix-ui/react-slider' -import { ReactNode } from 'react' +import {ReactNode, useState} from 'react' const colors = { green: ['bg-teal-400', 'focus:outline-teal-600/30 bg-teal-600'], @@ -58,10 +58,10 @@ export function Slider(props: { >
- {marks?.map(({ value, label }) => ( + {marks?.map(({value, label}) => (
- + ) } @@ -109,6 +109,7 @@ export function RangeSlider(props: { } = props const [trackClasses, thumbClasses] = colors[color] + const [dragValues, setDragValues] = useState<[number, number]>([lowValue, highValue]) return ( setValues(low, high)} + onValueChange={(vals: number[]) => setDragValues([vals[0], vals[1]])} // update continuously for UI feedback + onValueCommit={([low, high]) => setValues(low, high)} // update only on release min={min} max={max} disabled={disabled} >
- {marks?.map(({ value, label }) => ( + {marks?.map(({value, label}) => (
- - {label} - + + {label} +
))}
- - + +
) } const Track = (props: { className: string; children?: ReactNode }) => { - const { className, children } = props + const {className, children} = props return ( {children}