import { useDebouncedCallback, useMeasure } from '@react-hookz/web'; import { useState } from 'react'; import ReactSlider from 'react-slider'; import styles from './SlicingSlider.module.css'; const MIN_HEIGHT_PER_MARK = 25; interface Props { dimension: number; maxIndex: number; initialValue: number; onChange: (value: number) => void; } function SlicingSlider(props: Props) { const { dimension, maxIndex, initialValue, onChange } = props; const [value, setValue] = useState(initialValue); const onDebouncedChange = useDebouncedCallback(onChange, [onChange], 250); const [containerSize, containerRef] = useMeasure(); return (
D{dimension} 0:{maxIndex} {maxIndex > 0 ? ( = MIN_HEIGHT_PER_MARK } markClassName={styles.mark} orientation="vertical" invert value={value} onChange={(newValue) => { setValue(newValue); onDebouncedChange(newValue); }} renderThumb={(thumbProps, state) => (
{state.valueNow}
)} renderTrack={({ key }, { index }) => index === 0 ?
: null } /> ) : null}
); } export default SlicingSlider;