summaryrefslogtreecommitdiffhomepage
path: root/packages/ui/src/components/select.tsx
diff options
context:
space:
mode:
authorAaron Iker <[email protected]>2026-01-30 18:57:49 +0100
committerGitHub <[email protected]>2026-01-30 17:57:49 +0000
commit20619a6a26ec0cfc2707b7ed13387715e9f9cdaa (patch)
tree50b8aa69da65642789c3fa92f65034a9dd1361df /packages/ui/src/components/select.tsx
parent1bbe84ed8d0eceb96af06b971690ebd0b0213580 (diff)
downloadopencode-20619a6a26ec0cfc2707b7ed13387715e9f9cdaa.tar.gz
opencode-20619a6a26ec0cfc2707b7ed13387715e9f9cdaa.zip
feat: Transitions, spacing, scroll fade, prompt area update (#11168)
Co-authored-by: Github Action <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: aaroniker <[email protected]>
Diffstat (limited to 'packages/ui/src/components/select.tsx')
-rw-r--r--packages/ui/src/components/select.tsx18
1 files changed, 14 insertions, 4 deletions
diff --git a/packages/ui/src/components/select.tsx b/packages/ui/src/components/select.tsx
index 0386c329e..fef00500a 100644
--- a/packages/ui/src/components/select.tsx
+++ b/packages/ui/src/components/select.tsx
@@ -1,8 +1,10 @@
import { Select as Kobalte } from "@kobalte/core/select"
-import { createMemo, onCleanup, splitProps, type ComponentProps, type JSX } from "solid-js"
+import { createMemo, createSignal, onCleanup, splitProps, type ComponentProps, type JSX } from "solid-js"
import { pipe, groupBy, entries, map } from "remeda"
+import { Show } from "solid-js"
import { Button, ButtonProps } from "./button"
import { Icon } from "./icon"
+import { MorphChevron } from "./morph-chevron"
export type SelectProps<T> = Omit<ComponentProps<typeof Kobalte<T>>, "value" | "onSelect" | "children"> & {
placeholder?: string
@@ -38,6 +40,8 @@ export function Select<T>(props: SelectProps<T> & Omit<ButtonProps, "children">)
"triggerVariant",
])
+ const [isOpen, setIsOpen] = createSignal(false)
+
const state = {
key: undefined as string | undefined,
cleanup: undefined as (() => void) | void,
@@ -85,7 +89,7 @@ export function Select<T>(props: SelectProps<T> & Omit<ButtonProps, "children">)
data-component="select"
data-trigger-style={local.triggerVariant}
placement={local.triggerVariant === "settings" ? "bottom-end" : "bottom-start"}
- gutter={4}
+ gutter={8}
value={local.current}
options={grouped()}
optionValue={(x) => (local.value ? local.value(x) : (x as string))}
@@ -115,7 +119,7 @@ export function Select<T>(props: SelectProps<T> & Omit<ButtonProps, "children">)
: (itemProps.item.rawValue as string)}
</Kobalte.ItemLabel>
<Kobalte.ItemIndicator data-slot="select-select-item-indicator">
- <Icon name="check-small" size="small" />
+ <Icon name="check" size="small" />
</Kobalte.ItemIndicator>
</Kobalte.Item>
)}
@@ -124,6 +128,7 @@ export function Select<T>(props: SelectProps<T> & Omit<ButtonProps, "children">)
stop()
}}
onOpenChange={(open) => {
+ setIsOpen(open)
local.onOpenChange?.(open)
if (!open) stop()
}}
@@ -149,7 +154,12 @@ export function Select<T>(props: SelectProps<T> & Omit<ButtonProps, "children">)
}}
</Kobalte.Value>
<Kobalte.Icon data-slot="select-select-trigger-icon">
- <Icon name={local.triggerVariant === "settings" ? "selector" : "chevron-down"} size="small" />
+ <Show when={local.triggerVariant === "settings"}>
+ <Icon name="selector" size="small" />
+ </Show>
+ <Show when={local.triggerVariant !== "settings"}>
+ <MorphChevron expanded={isOpen()} />
+ </Show>
</Kobalte.Icon>
</Kobalte.Trigger>
<Kobalte.Portal>