fix slider value handling and track width

- Use single value instead of array for type="single" slider
- Pass onValueChange directly without array wrapping
- Use flex-grow: 1 for track width instead of width: 100%
This commit is contained in:
Justin Edmund 2025-12-03 18:50:11 -08:00
parent 8ddfe58369
commit ea09f325a0

View file

@ -32,17 +32,12 @@
element, element,
class: className = '' class: className = ''
}: Props = $props() }: Props = $props()
function handleValueChange(values: number[]) {
const newValue = values[0] ?? min
onValueChange?.(newValue)
}
</script> </script>
<SliderPrimitive.Root <SliderPrimitive.Root
type="single" type="single"
value={[value]} {value}
onValueChange={handleValueChange} {onValueChange}
{min} {min}
{max} {max}
{step} {step}
@ -78,7 +73,7 @@
:global(.slider-track) { :global(.slider-track) {
position: relative; position: relative;
width: 100%; flex-grow: 1;
height: $unit-half; height: $unit-half;
background: var(--slider-track-bg, var(--button-bg)); background: var(--slider-track-bg, var(--button-bg));
border-radius: $full-corner; border-radius: $full-corner;