fix(webui): unify settings switch styles
This commit is contained in:
1 parent
af43292f6f
commit
70bf433018
7 files changed
+105
-53
No files matched your search
@@ -31,6 +31,7 @@ import { Input } from "@/components/ui/input";
|
||||
import { SegmentedControl } from "@/components/ui/segmented-control";
|
||||
import { Sheet, SheetContent, SheetDescription, SheetTitle } from "@/components/ui/sheet";
|
||||
import { SkillsMarketplace } from "@/components/settings/SkillsMarketplace";
|
||||
import { ToggleButton } from "@/components/settings/ToggleButton";
|
||||
import { deleteSkill, fetchSkillDetail, updateSkillEnabled } from "@/lib/api";
|
||||
import { notifySkillsChanged } from "@/lib/skill-events";
|
||||
import type { SkillDetail, SkillSummary } from "@/lib/types";
|
||||
@@ -447,15 +448,13 @@ function SkillDetailSheet({
|
||||
</div>
|
||||
) : (
|
||||
<div className="mt-6 space-y-5">
|
||||
<div className="flex min-h-16 items-start justify-between gap-3 border-y border-border/45 px-1 py-3.5">
|
||||
<div className="flex min-h-16 items-center justify-between gap-3 border-y border-border/45 px-1 py-3.5">
|
||||
<p className="text-[13px] font-medium text-foreground">
|
||||
{t("settings.skills.enabledControl", { defaultValue: "Use this skill" })}
|
||||
</p>
|
||||
<button
|
||||
type="button"
|
||||
role="switch"
|
||||
aria-checked={enabled}
|
||||
aria-label={
|
||||
<ToggleButton
|
||||
checked={enabled}
|
||||
label={
|
||||
enabled
|
||||
? t("settings.skills.disableSkill", {
|
||||
name: activeSkill.name,
|
||||
@@ -467,26 +466,8 @@ function SkillDetailSheet({
|
||||
})
|
||||
}
|
||||
disabled={actionBusy}
|
||||
onClick={() => void toggleEnabled()}
|
||||
className={cn(
|
||||
"relative -mr-1 h-10 w-14 shrink-0 rounded-full",
|
||||
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
||||
"disabled:cursor-wait disabled:opacity-60",
|
||||
)}
|
||||
>
|
||||
<span
|
||||
className={cn(
|
||||
"absolute left-1.5 top-2 h-6 w-11 rounded-full transition-colors",
|
||||
enabled ? "bg-foreground" : "bg-muted-foreground/30",
|
||||
)}
|
||||
/>
|
||||
<span
|
||||
className={cn(
|
||||
"absolute left-2 top-2.5 h-5 w-5 rounded-full bg-background shadow-sm transition-transform",
|
||||
enabled ? "translate-x-5" : "translate-x-0",
|
||||
)}
|
||||
/>
|
||||
</button>
|
||||
onChange={() => void toggleEnabled()}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{actionError ? (
|
||||
|
||||
@@ -27,21 +27,21 @@ export function ToggleButton({
|
||||
if (!disabled) onChange(!checked);
|
||||
}}
|
||||
className={cn(
|
||||
"relative inline-flex h-[22px] w-[38px] shrink-0 items-center rounded-full p-[2px]",
|
||||
"transition-colors duration-200 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
||||
"relative inline-flex h-5 w-9 shrink-0 items-center rounded-full p-0.5",
|
||||
"after:absolute after:left-1/2 after:top-1/2 after:h-11 after:w-11 after:-translate-x-1/2 after:-translate-y-1/2 after:content-['']",
|
||||
"transition-colors duration-200 ease-out motion-reduce:transition-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
||||
checked
|
||||
? "bg-[#2997FF]"
|
||||
: "bg-muted-foreground/20 hover:bg-muted-foreground/25",
|
||||
? "bg-foreground"
|
||||
: "bg-muted-foreground/25 hover:bg-muted-foreground/30",
|
||||
disabled && "cursor-default opacity-60",
|
||||
disabled && checked && "hover:bg-[#2997FF]",
|
||||
disabled && !checked && "hover:bg-muted-foreground/20",
|
||||
disabled && !checked && "hover:bg-muted-foreground/25",
|
||||
)}
|
||||
>
|
||||
<span
|
||||
aria-hidden
|
||||
className={cn(
|
||||
"h-[18px] w-[18px] rounded-full bg-background",
|
||||
"transition-transform duration-200 ease-out",
|
||||
"h-4 w-4 rounded-full bg-background shadow-sm",
|
||||
"transition-transform duration-200 ease-out motion-reduce:transition-none",
|
||||
checked ? "translate-x-[16px]" : "translate-x-0",
|
||||
)}
|
||||
/>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ProviderIcon } from "@/components/settings/models/ProviderSettings";
|
||||
import { ToggleButton } from "@/components/settings/ToggleButton";
|
||||
import { useAutoSave } from "@/components/settings/shared/useAutoSave";
|
||||
import { useEffect, useId, useRef, useState, type Dispatch, type SetStateAction } from "react";
|
||||
import { DisclosureContent } from "@/components/ui/disclosure";
|
||||
@@ -794,36 +795,22 @@ export function ModelsSettings({
|
||||
) : (
|
||||
<span className="h-4 w-4 shrink-0" aria-hidden />
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
role="switch"
|
||||
aria-checked={ordered}
|
||||
aria-label={
|
||||
<ToggleButton
|
||||
checked={ordered}
|
||||
label={
|
||||
ordered
|
||||
? tx("settings.models.removeFromOrder", "Disable preset")
|
||||
: tx("settings.models.addToOrder", "Enable preset")
|
||||
}
|
||||
disabled={callOrderBusy || (ordered && callOrder.length <= 1)}
|
||||
onClick={() => {
|
||||
onChange={() => {
|
||||
if (ordered) {
|
||||
removeCallOrderItem(orderIndex);
|
||||
} else if (preset) {
|
||||
onChangeCallOrder([...callOrder, preset.name]);
|
||||
}
|
||||
}}
|
||||
className={cn(
|
||||
"relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-40",
|
||||
ordered ? "bg-foreground" : "bg-muted-foreground/25",
|
||||
)}
|
||||
>
|
||||
<span
|
||||
className={cn(
|
||||
"h-4 w-4 rounded-full bg-background shadow-sm transition-transform",
|
||||
ordered ? "translate-x-[18px]" : "translate-x-0.5",
|
||||
)}
|
||||
aria-hidden
|
||||
/>
|
||||
</button>
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
return (
|
||||
|
||||
Reference in new issue
Block a user