fix(webui): share control layout for preset alignment

This commit is contained in:
chengyongru authored and chengyongru committed 2026-10-10 01:33:02 +08:00
1 parent 55ff1d8d1f
commit 763ae9c2ae
7 files changed
+49 -18

No files matched your search

@@ -80,7 +80,7 @@ export function ModelAPIControl({
</SelectContent>
</Select>
) : (
<span className="block pe-3 text-[13px] text-muted-foreground sm:text-right">{fixedLabel}</span>
<span className="control-layout w-full justify-start border-transparent text-[13px] text-muted-foreground sm:justify-end">{fixedLabel}</span>
)}
</SettingsRow>
{configurable && selectedAPI === "responses" && (!requestAPIs || requestAPIs.includes("chat_completions")) ? (
@@ -6,7 +6,6 @@ import { useAutoSave } from "@/components/settings/shared/useAutoSave";
import { useEffect, useId, useRef, useState, type Dispatch, type SetStateAction } from "react";
import { DisclosureContent } from "@/components/ui/disclosure";
import {
ChevronDown,
GripVertical,
ListOrdered,
Loader2,
@@ -34,6 +33,7 @@ import {
StatusPill,
} from "@/components/settings/shared/SettingsControls";
import { Button } from "@/components/ui/button";
import { ControlChevron } from "@/components/ui/control-chevron";
import {
Dialog,
DialogContent,
@@ -530,9 +530,9 @@ export function ModelsSettings({
aria-expanded={advancedOpen}
aria-controls={advancedId}
onClick={() => setAdvancedOpen((value) => !value)}
className="flex min-h-[62px] w-full items-center justify-between gap-4 px-4 py-3.5 text-left transition-colors settings-hover sm:px-5"
className="settings-disclosure-row w-full text-left transition-colors settings-hover"
>
<span>
<span className="min-w-0">
<span className="block text-[14px] font-medium text-foreground">
{tx("settings.models.advancedOptions", "Advanced options")}
</span>
@@ -545,13 +545,16 @@ export function ModelsSettings({
})}</span>
</span>
</span>
<ChevronDown
className={cn(
"me-3 h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200 motion-reduce:transition-none",
advancedOpen && "rotate-180",
)}
aria-hidden
/>
<span className="settings-control">
<span className="control-layout justify-end border-transparent">
<ControlChevron
className={cn(
"transition-transform duration-200 motion-reduce:transition-none",
advancedOpen && "rotate-180",
)}
/>
</span>
</span>
</button>
<DisclosureContent id={advancedId} open={advancedOpen}>
<div className="bg-muted/12 px-4 py-4 sm:px-5">
@@ -3,7 +3,6 @@ import {
Bot,
Brain,
Check,
ChevronDown,
CircleAlert,
Cloud,
Cpu,
@@ -26,6 +25,7 @@ import {
import { useTranslation } from "react-i18next";
import { Button } from "@/components/ui/button";
import { ControlChevron } from "@/components/ui/control-chevron";
import { ComboboxOption, useComboboxNavigation } from "@/components/ui/combobox";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
import { Input } from "@/components/ui/input";
@@ -126,7 +126,7 @@ export function ProviderPicker({
type="button"
disabled={disabled}
className={cn(
"h-9 w-full justify-between rounded-full border-input bg-background px-3 text-[13px] font-normal shadow-none",
"w-full justify-between rounded-full border-input bg-background text-[13px] font-normal shadow-none",
"settings-hover focus-visible:ring-2 focus-visible:ring-ring",
disabled && "text-muted-foreground",
)}
@@ -364,8 +364,9 @@ export function ModelIdPicker({
<Button
type="button"
variant="outline"
size="control"
className={cn(
"h-9 w-full justify-between rounded-full border-input bg-background px-3 text-[13px] font-normal shadow-none",
"w-full justify-between rounded-full border-input bg-background text-[13px] font-normal shadow-none",
"settings-hover focus-visible:ring-2 focus-visible:ring-ring",
)}
>
@@ -384,7 +385,7 @@ export function ModelIdPicker({
{value || emptyLabel || tx("settings.models.selectModel", "Select model")}
</span>
</span>
<ChevronDown className="ml-2 h-3.5 w-3.5 shrink-0 text-muted-foreground" aria-hidden />
<ControlChevron />
</Button>
</PopoverTrigger>
<PopoverContent
+1
View File
@@ -23,6 +23,7 @@ const buttonVariants = cva(
size: {
default: "h-10 px-4 py-2",
sm: "h-9 px-3",
control: "control-layout",
lg: "h-11 px-8",
icon: "h-9 w-9",
},
@@ -0,0 +1,16 @@
import { ChevronDown } from "lucide-react";
import { cn } from "@/lib/utils";
export function ControlChevron({ className }: { className?: string }) {
return (
<ChevronDown
// Keep the horizontal viewBox around the artwork, including its stroke.
viewBox="5 0 14 24"
width={14}
height={24}
className={cn("h-3.5 w-auto shrink-0 text-muted-foreground", className)}
aria-hidden
/>
);
}
+3 -2
View File
@@ -5,6 +5,7 @@ import { Check, ChevronDown, ChevronUp } from "lucide-react";
import { floatingSurfaceElevationClassName, floatingItemClassName } from "@/components/ui/floating-surface";
import { useFloatingPortal } from "@/components/ui/floating-portal";
import { cn } from "@/lib/utils";
import { ControlChevron } from "@/components/ui/control-chevron";
export const Select = SelectPrimitive.Root;
export const SelectValue = SelectPrimitive.Value;
@@ -14,9 +15,9 @@ export const SelectTrigger = React.forwardRef<
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>
>(({ className, children, ...props }, ref) => (
<SelectPrimitive.Trigger ref={ref} {...props}
className={cn("flex h-9 items-center justify-between gap-2 rounded-control border border-input bg-background px-3 text-[13px] outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 [&>span:first-child]:truncate", className)}>
className={cn("control-layout justify-between rounded-control border-input bg-background text-[13px] outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 [&>span:first-child]:truncate", className)}>
{children}
<SelectPrimitive.Icon asChild><ChevronDown className="h-3.5 w-3.5 shrink-0 text-muted-foreground" aria-hidden /></SelectPrimitive.Icon>
<SelectPrimitive.Icon><ControlChevron /></SelectPrimitive.Icon>
</SelectPrimitive.Trigger>
));
SelectTrigger.displayName = "SelectTrigger";
+10 -1
View File
@@ -1398,7 +1398,15 @@
}
.settings-section-heading > .settings-section-title { margin: 0; padding: 0; }
.settings-stack > .settings-section-heading + :not([hidden]) { margin-block-start: 20px; }
.settings-row, .settings-footer {
.control-layout {
display: flex;
height: 2.25rem;
align-items: center;
gap: 0.5rem;
border-width: 1px;
padding-inline: 0.75rem;
}
.settings-row, .settings-footer, .settings-disclosure-row {
display: grid;
grid-template-columns: repeat(var(--settings-columns, 4), minmax(0, 1fr));
column-gap: var(--settings-gutter, 16px);
@@ -1408,6 +1416,7 @@
min-block-size: 60px;
}
.settings-row > *, .settings-footer > * { grid-column: 1 / -1; min-inline-size: 0; }
.settings-disclosure-row { grid-template-columns: minmax(0, 1fr) auto; }
.settings-control { display: flex; align-items: center; max-inline-size: 100%; }
.settings-control > * { max-inline-size: 100%; }
.settings-control input, .settings-control textarea { max-inline-size: 100%; text-align: start; }