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:
parent
8ddfe58369
commit
ea09f325a0
1 changed files with 3 additions and 8 deletions
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue