From 2ee49b7cbd2c50171204e875bc47470cb13601bd Mon Sep 17 00:00:00 2001 From: Ilia Mashkov Date: Tue, 24 Feb 2026 17:57:40 +0300 Subject: [PATCH] feat(Slider): component redesign with complete storybook coverage --- src/shared/ui/Slider/Slider.stories.svelte | 97 +++++++- src/shared/ui/Slider/Slider.svelte | 243 +++++++++++---------- 2 files changed, 212 insertions(+), 128 deletions(-) diff --git a/src/shared/ui/Slider/Slider.stories.svelte b/src/shared/ui/Slider/Slider.stories.svelte index 062fa7f..c0fa835 100644 --- a/src/shared/ui/Slider/Slider.stories.svelte +++ b/src/shared/ui/Slider/Slider.stories.svelte @@ -9,7 +9,8 @@ const { Story } = defineMeta({ parameters: { docs: { description: { - component: 'Styled bits-ui slider component for selecting a value within a range.', + component: + 'Styled bits-ui slider component with red accent (#ff3b30). Thumb is a 45° rotated square with hover/active scale animations.', }, story: { inline: false }, // Render stories in iframe for state isolation }, @@ -31,32 +32,110 @@ const { Story } = defineMeta({ control: 'number', description: 'Step size for value increments', }, - label: { - control: 'text', - description: 'Optional label displayed inline on the track', - }, }, }); {#snippet template(args)} - +
+ +

Value: {args.value}

+

+ Hover over thumb to see scale effect, click and drag to interact +

+
{/snippet}
{#snippet template(args)} - +
+ +
+

Value: {args.value}

+

Vertical orientation with same red accent

+
+
{/snippet}
- + {#snippet template(args)} - +
+ +

Slider with inline label

+
+ {/snippet} +
+ + + {#snippet template(args)} +
+ +

Value: {args.value}

+

Dark mode: track uses neutral-800

+
+ {/snippet} +
+ + + {#snippet template(args)} +
+
+

Thumb: 45° rotated square

+ +
+
+

Hover State (scale-125)

+ +
+
+

Different Values

+
+ + + +
+
+
+

Focus State (ring-2 ring-[#ff3b30]/20)

+

Tab to the thumb to see focus ring

+ +
+
+ {/snippet} +
+ + + {#snippet template(args)} +
+
+

Step: 1 (default)

+ +
+
+

Step: 10

+ +
+
+

Step: 25

+ +
+
{/snippet}
diff --git a/src/shared/ui/Slider/Slider.svelte b/src/shared/ui/Slider/Slider.svelte index 20e68bb..c0d02b5 100644 --- a/src/shared/ui/Slider/Slider.svelte +++ b/src/shared/ui/Slider/Slider.svelte @@ -1,137 +1,142 @@ - - {#snippet children(props)} - {#if label && orientation === 'horizontal'} - - {label} - - {/if} - - +{#if isVertical} +
+ + {format(value)} + - -
onValueChange?.(v))} + class=" + relative flex flex-col items-center select-none touch-none + w-5 h-full grow cursor-row-resize + disabled:opacity-50 disabled:cursor-not-allowed + " + > + {#snippet children({ thumbItems })} + -
- - - {value} + -
+ + {#each thumbItems as thumb (thumb)} + + {/each} + {/snippet} + +
+{:else} +
+ onValueChange?.(v))} + class=" + relative flex items-center select-none touch-none + w-full h-5 cursor-col-resize + disabled:opacity-50 disabled:cursor-not-allowed + " + > + {#snippet children({ thumbItems })} + + + + + {#each thumbItems as thumb (thumb)} + + {/each} + {/snippet} + + + + + {format(value)} - {/snippet} - +
+{/if}