A local-first multi-agent app development platform, built on PenguinHarness
fix(web): refine toggle switch styling (#259)
Yaowei Zheng183104eb3b3e
diff --git a/packages/web/src/components/ui/switch.tsx b/packages/web/src/components/ui/switch.tsxindex f3a6af75..5e1fe003 100644--- a/packages/web/src/components/ui/switch.tsx+++ b/packages/web/src/components/ui/switch.tsx@@ -1,10 +1,23 @@/*** iOS-style toggle switch: a `button` with `role="switch"` + `aria-checked` (a native* button is keyboard-operable out of the box — Space/Enter activate it — and is labelable- * content, so clicking an enclosing `<label>`'s text toggles it too). Sliding knob with a- * color/transform transition; the on-state follows the theme accent variable (same source- * as Button primary), the off-state is gray; dark-mode aware; disabled dims and blocks.- * Sized for compact (sm) form rows, matching the dialogs' controls.+ * content, so clicking an enclosing `<label>`'s text toggles it too). Sliding knob with an+ * ease-out color/transform transition; the on-state follows the theme accent variable (same+ * source as Button primary), the off-state is gray.+ *+ * Geometry (all integer pixels): a 16px knob in the 36x20px track, inset 2px on every side+ * in both states (travel 2px -> 18px), and at either end concentric with the track's+ * end-cap circle (center 10px in from the edge), so the gap along the arcs matches the+ * straight runs. The track draws a 1px inset hairline; the knob's hairline is a *border* —+ * inside its own 16px — not an outer ring: an outer ring would fill the gap on the near arc+ * and stack on the track hairline as one heavier line, reading as unequal spacing. Net+ * clearance between knob edge and outline is thus a uniform 1px all around. No offset+ * shadow (it reads as vertical asymmetry at this size); the hairlines keep the edges+ * defined on any surface (the dark neutral accent is near-white, where the white knob would+ * otherwise vanish); dark-mode aware; disabled dims and blocks. The focus ring is+ * accent-tinted and `focus-visible`-only, so keyboard focus shows it but a mouse click+ * doesn't leave a lingering halo. Sized for compact (sm) form rows, matching the dialogs'+ * controls.*/import type { ButtonHTMLAttributes } from "react";@@ -26,16 +39,18 @@ export function Switch({ checked, onChange, disabled, className, ...rest }: SwitonClick={() => onChange(!checked)}className={"relative inline-flex h-5 w-9 shrink-0 items-center rounded-full " +- "transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-gray-400/30 " ++ "inset-ring inset-ring-black/10 dark:inset-ring-white/10 " ++ "transition-colors duration-200 ease-out " ++ "focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--accent-bg)]/40 " +"disabled:cursor-not-allowed disabled:opacity-60 " +- (checked ? "bg-[var(--accent-bg)]" : "bg-gray-300 dark:bg-gray-600") ++ (checked ? "bg-[var(--accent-bg)]" : "bg-gray-200 dark:bg-gray-700") +` ${className ?? ""}`}{...rest}><spanaria-hidden- className={`inline-block size-4 transform rounded-full bg-white shadow transition-transform duration-200 ${+ className={`inline-block size-4 rounded-full border border-black/10 bg-white transition-transform duration-200 ease-out ${checked ? "translate-x-[18px]" : "translate-x-0.5"}`}/>