'use client'; import { InputLayout } from '../input-layout/input-layout'; import React, { forwardRef, InputHTMLAttributes, useId, useState } from 'react'; interface SliderProps extends InputHTMLAttributes { options?: number[]; } export const Slider = forwardRef( ({ options, ...props }, ref) => { const sliderId = useId(); const [progress, setProgress] = useState(0); return (
) => { setProgress( (parseInt(event.target.value) / parseInt(event.target.max)) * 100, ); }} ref={ref} style={{ ...props.style, background: `linear-gradient(to right, var(--md-sys-color-primary) ${progress}%, var(--md-sys-color-surface-container-highest) ${progress}%)`, }} type={'range'} typeInput={'slider'} /> {options && ( {options.map((option, index) => ( )}
); }, );