Skip to content

Commit

Permalink
vertical styles + parity
Browse files Browse the repository at this point in the history
  • Loading branch information
ieedan committed Feb 19, 2025
1 parent fac8178 commit f3ab021
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
18 changes: 14 additions & 4 deletions sites/docs/src/lib/registry/default/ui/slider/slider.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
let {
ref = $bindable(null),
value = $bindable(),
orientation = "horizontal",
class: className,
...restProps
}: WithoutChildrenOrChild<SliderPrimitive.RootProps> = $props();
Expand All @@ -15,14 +16,23 @@ Discriminated Unions + Destructing (required for bindable) do not
get along, so we shut typescript up by casting `value` to `never`.
-->
<SliderPrimitive.Root
bind:value={value as never}
bind:ref
class={cn("relative flex w-full touch-none select-none items-center", className)}
bind:value={value as never}
{orientation}
class={cn(
"relative flex touch-none select-none items-center data-[orientation='vertical']:h-full data-[orientation='vertical']:min-h-44 data-[orientation='horizontal']:w-full data-[orientation='vertical']:w-auto data-[orientation='vertical']:flex-col",
className
)}
{...restProps}
>
{#snippet children({ thumbs })}
<span class="bg-secondary relative h-2 w-full grow overflow-hidden rounded-full">
<SliderPrimitive.Range class="bg-primary absolute h-full" />
<span
data-orientation={orientation}
class="bg-secondary relative grow overflow-hidden rounded-full data-[orientation='horizontal']:h-2 data-[orientation='vertical']:h-full data-[orientation='horizontal']:w-full data-[orientation='vertical']:w-2"
>
<SliderPrimitive.Range
class="bg-primary absolute data-[orientation='horizontal']:h-full data-[orientation='vertical']:w-full"
/>
</span>
{#each thumbs as thumb}
<SliderPrimitive.Thumb
Expand Down
20 changes: 14 additions & 6 deletions sites/docs/src/lib/registry/new-york/ui/slider/slider.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
let {
ref = $bindable(null),
class: className,
value = $bindable(),
orientation = "horizontal",
class: className,
...restProps
}: WithoutChildrenOrChild<SliderPrimitive.RootProps> = $props();
export { className as class };
</script>

<!--
Expand All @@ -19,12 +18,21 @@ get along, so we shut typescript up by casting `value` to `never`.
<SliderPrimitive.Root
bind:ref
bind:value={value as never}
class={cn("relative flex w-full touch-none select-none items-center", className)}
{orientation}
class={cn(
"relative flex touch-none select-none items-center data-[orientation='vertical']:h-full data-[orientation='vertical']:min-h-44 data-[orientation='horizontal']:w-full data-[orientation='vertical']:w-auto data-[orientation='vertical']:flex-col",
className
)}
{...restProps}
>
{#snippet children({ thumbs })}
<span class="bg-primary/20 relative h-1.5 w-full grow overflow-hidden rounded-full">
<SliderPrimitive.Range class="bg-primary absolute h-full" />
<span
data-orientation={orientation}
class="bg-primary/20 relative grow overflow-hidden rounded-full data-[orientation='horizontal']:h-1.5 data-[orientation='vertical']:h-full data-[orientation='horizontal']:w-full data-[orientation='vertical']:w-1.5"
>
<SliderPrimitive.Range
class="bg-primary absolute data-[orientation='horizontal']:h-full data-[orientation='vertical']:w-full"
/>
</span>
{#each thumbs as thumb}
<SliderPrimitive.Thumb
Expand Down

0 comments on commit f3ab021

Please sign in to comment.