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