Skip to content

Commit 7bd01b5

Browse files
webui: make model selector more subtle and integrated into ChatForm
1 parent 4d74c5b commit 7bd01b5

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

tools/server/webui/src/lib/components/app/chat/ChatForm/ChatFormActions.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
</script>
3131

3232
<div class="flex w-full items-center gap-2 {className}">
33-
<ChatFormActionFileAttachments {disabled} {onFileUpload} />
33+
<ChatFormActionFileAttachments class="mr-auto" {disabled} {onFileUpload} />
3434

35-
<ChatFormModelSelector class="min-w-[140px] flex-1" />
35+
<ChatFormModelSelector class="shrink-0" />
3636

3737
{#if isLoading}
3838
<Button

tools/server/webui/src/lib/components/app/chat/ChatForm/ChatFormModelSelector.svelte

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
}
6464
</script>
6565

66-
<div class={cn('flex min-w-0 flex-col gap-1', className)}>
66+
<div class={cn('flex max-w-[200px] min-w-[120px] flex-col items-end gap-1', className)}>
6767
{#if loading && options.length === 0 && !isMounted}
6868
<div class="flex items-center gap-2 text-xs text-muted-foreground">
6969
<Loader2 class="h-4 w-4 animate-spin" />
@@ -80,13 +80,13 @@
8080
onValueChange={handleSelect}
8181
disabled={loading || updating}
8282
>
83-
<Select.Trigger
84-
class="h-9 w-full min-w-[140px] justify-between rounded-full border border-input bg-background/80 px-3 text-left text-sm sm:min-w-[200px]"
85-
>
86-
<span class="truncate font-medium">{selectedOption?.name || 'Select model'}</span>
83+
<Select.Trigger variant="plain" size="sm" class="hover:text-foreground">
84+
<span class="max-w-[160px] truncate text-right"
85+
>{selectedOption?.name || 'Select model'}</span
86+
>
8787

8888
{#if updating}
89-
<Loader2 class="h-4 w-4 animate-spin text-muted-foreground" />
89+
<Loader2 class="h-3.5 w-3.5 animate-spin text-muted-foreground" />
9090
{/if}
9191
</Select.Trigger>
9292

tools/server/webui/src/lib/components/ui/select/select-trigger.svelte

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,33 @@
88
class: className,
99
children,
1010
size = 'default',
11+
variant = 'default',
1112
...restProps
1213
}: WithoutChild<SelectPrimitive.TriggerProps> & {
1314
size?: 'sm' | 'default';
15+
variant?: 'default' | 'plain';
1416
} = $props();
17+
18+
const baseClasses = $derived(
19+
variant === 'plain'
20+
? "group inline-flex w-full items-center justify-end gap-2 whitespace-nowrap px-0 py-0 text-sm font-medium text-muted-foreground transition-colors focus-visible:outline-none focus-visible:ring-0 focus-visible:ring-offset-0 disabled:cursor-not-allowed disabled:opacity-50 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3 [&_svg:not([class*='text-'])]:text-muted-foreground"
21+
: "flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none select-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground"
22+
);
23+
24+
const chevronClasses = $derived(
25+
variant === 'plain'
26+
? 'size-3 opacity-60 transition-transform group-data-[state=open]:-rotate-180'
27+
: 'size-4 opacity-50'
28+
);
1529
</script>
1630

1731
<SelectPrimitive.Trigger
1832
bind:ref
1933
data-slot="select-trigger"
2034
data-size={size}
21-
class={cn(
22-
"flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none select-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",
23-
className
24-
)}
35+
class={cn(baseClasses, className)}
2536
{...restProps}
2637
>
2738
{@render children?.()}
28-
<ChevronDownIcon class="size-4 opacity-50" />
39+
<ChevronDownIcon class={chevronClasses} />
2940
</SelectPrimitive.Trigger>

0 commit comments

Comments
 (0)