From 47bcca1bdc23edf889a4953fb6c30af4d1a528f9 Mon Sep 17 00:00:00 2001 From: pheralb Date: Fri, 29 Aug 2025 12:42:00 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Add=20select=20UI=20component?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ui/select/index.ts | 25 ++++++++++++ .../ui/select/select-content.svelte | 38 ++++++++++++++++++ src/components/ui/select/select-group.svelte | 8 ++++ src/components/ui/select/select-item.svelte | 40 +++++++++++++++++++ src/components/ui/select/select-label.svelte | 24 +++++++++++ .../ui/select/select-trigger.svelte | 28 +++++++++++++ src/components/ui/tabs/tabs-trigger.svelte | 2 +- 7 files changed, 164 insertions(+), 1 deletion(-) create mode 100644 src/components/ui/select/index.ts create mode 100644 src/components/ui/select/select-content.svelte create mode 100644 src/components/ui/select/select-group.svelte create mode 100644 src/components/ui/select/select-item.svelte create mode 100644 src/components/ui/select/select-label.svelte create mode 100644 src/components/ui/select/select-trigger.svelte diff --git a/src/components/ui/select/index.ts b/src/components/ui/select/index.ts new file mode 100644 index 0000000..5bf44e7 --- /dev/null +++ b/src/components/ui/select/index.ts @@ -0,0 +1,25 @@ +import { Select as SelectPrimitive } from "bits-ui"; + +import Group from "./select-group.svelte"; +import Label from "./select-label.svelte"; +import Item from "./select-item.svelte"; +import Content from "./select-content.svelte"; +import Trigger from "./select-trigger.svelte"; + +const Root = SelectPrimitive.Root; + +export { + Root, + Group, + Label, + Item, + Content, + Trigger, + // + Root as Select, + Group as SelectGroup, + Label as SelectLabel, + Item as SelectItem, + Content as SelectContent, + Trigger as SelectTrigger, +}; diff --git a/src/components/ui/select/select-content.svelte b/src/components/ui/select/select-content.svelte new file mode 100644 index 0000000..d3ee61e --- /dev/null +++ b/src/components/ui/select/select-content.svelte @@ -0,0 +1,38 @@ + + + + + + {@render children?.()} + + + diff --git a/src/components/ui/select/select-group.svelte b/src/components/ui/select/select-group.svelte new file mode 100644 index 0000000..ac75b86 --- /dev/null +++ b/src/components/ui/select/select-group.svelte @@ -0,0 +1,8 @@ + + + diff --git a/src/components/ui/select/select-item.svelte b/src/components/ui/select/select-item.svelte new file mode 100644 index 0000000..9b95ae4 --- /dev/null +++ b/src/components/ui/select/select-item.svelte @@ -0,0 +1,40 @@ + + + + {#snippet children({ selected, highlighted })} + + {#if selected} + + {/if} + + {#if childrenProp} + {@render childrenProp({ selected, highlighted })} + {:else} + {label || value} + {/if} + {/snippet} + diff --git a/src/components/ui/select/select-label.svelte b/src/components/ui/select/select-label.svelte new file mode 100644 index 0000000..58a7efe --- /dev/null +++ b/src/components/ui/select/select-label.svelte @@ -0,0 +1,24 @@ + + +
+ {@render children?.()} +
diff --git a/src/components/ui/select/select-trigger.svelte b/src/components/ui/select/select-trigger.svelte new file mode 100644 index 0000000..241bac0 --- /dev/null +++ b/src/components/ui/select/select-trigger.svelte @@ -0,0 +1,28 @@ + + + + {@render children?.()} + + diff --git a/src/components/ui/tabs/tabs-trigger.svelte b/src/components/ui/tabs/tabs-trigger.svelte index 6082852..076544d 100644 --- a/src/components/ui/tabs/tabs-trigger.svelte +++ b/src/components/ui/tabs/tabs-trigger.svelte @@ -13,7 +13,7 @@ bind:ref data-slot="tabs-trigger" class={cn( - "inline-flex items-center justify-center rounded-md px-3 py-1 text-sm font-medium whitespace-nowrap ring-offset-white transition-all focus-visible:ring-2 focus-visible:ring-neutral-950 focus-visible:ring-offset-2 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-neutral-200 data-[state=active]:text-neutral-950 data-[state=active]:shadow dark:ring-offset-neutral-950 dark:focus-visible:ring-neutral-300 dark:data-[state=active]:bg-neutral-800 dark:data-[state=active]:text-neutral-50", + "inline-flex cursor-pointer items-center justify-center rounded-md px-3 py-1 text-sm font-medium whitespace-nowrap ring-offset-white transition-all hover:text-black focus-visible:ring-2 focus-visible:ring-neutral-950 focus-visible:ring-offset-2 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-neutral-200 data-[state=active]:text-neutral-950 data-[state=active]:shadow dark:ring-offset-neutral-950 dark:hover:text-white dark:focus-visible:ring-neutral-300 dark:data-[state=active]:bg-neutral-800 dark:data-[state=active]:text-neutral-50", className, )} {...restProps}