From 743d40bbba04f16ace9421ceeaf9245e1043c87b Mon Sep 17 00:00:00 2001 From: chengyongru <61816729+chengyongru@users.noreply.github.com> Date: Mon, 19 Oct 2026 10:43:23 +0800 Subject: [PATCH] fix(webui): restore symmetry of the settings gear (#6298) * fix(webui): restore symmetry of the settings gear Fixes NAN-276 * fix(webui): keep settings hub out of hover rotation --- webui/browser/fixture.tsx | 4 ++ webui/browser/product-icons.spec.ts | 56 ++++++++++++++++++++ webui/src/components/icons/product-icons.tsx | 2 +- webui/src/globals.css | 6 ++- 4 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 webui/browser/product-icons.spec.ts diff --git a/webui/browser/fixture.tsx b/webui/browser/fixture.tsx index 9e559966e..ffa30e12f 100644 --- a/webui/browser/fixture.tsx +++ b/webui/browser/fixture.tsx @@ -13,6 +13,8 @@ import { fetchWebuiThread } from "@/lib/api"; import { projectThreadEvents } from "@/lib/thread-event-projection"; import { Dialog, DialogClose, DialogContent, DialogDescription, DialogTitle, DialogTrigger } from "@/components/ui/dialog"; import { TooltipProvider } from "@/components/ui/tooltip"; +import { Button } from "@/components/ui/button"; +import { SettingsIcon } from "@/components/icons/product-icons"; import { initializeI18n } from "@/i18n"; import type { McpPresetInfo, UIMessage } from "@/lib/types"; import "../src/globals.css"; @@ -140,6 +142,8 @@ createRoot(document.getElementById("root")!).render( ? : parameters.get("case") === "rail" ? + : parameters.get("case") === "settings-icon" + ? : parameters.get("case") === "history" ? : } diff --git a/webui/browser/product-icons.spec.ts b/webui/browser/product-icons.spec.ts new file mode 100644 index 000000000..ff9aaf963 --- /dev/null +++ b/webui/browser/product-icons.spec.ts @@ -0,0 +1,56 @@ +import { expect, test } from "@playwright/test"; + +test("settings gear outline is symmetric about its circular hub", async ({ page }) => { + await page.goto("/browser/fixture.html?case=settings-icon"); + const icon = page.getByRole("button", { name: "Settings", exact: true }).locator("svg"); + const error = await icon.evaluate((element) => { + const outline = element.querySelector("path")!; + const hub = element.querySelector("circle")!; + const length = outline.getTotalLength(); + let maximum = 0; + for (let index = 0; index < 64; index++) { + const distance = length * index / 128; + const point = outline.getPointAtLength(distance); + const opposite = outline.getPointAtLength(distance + length / 2); + maximum = Math.max(maximum, Math.hypot( + point.x + opposite.x - 2 * hub.cx.baseVal.value, + point.y + opposite.y - 2 * hub.cy.baseVal.value, + )); + } + return maximum; + }); + expect(error).toBeLessThan(0.001); +}); + +test("settings hover rotates the outline without transforming the hub", async ({ page }) => { + await page.emulateMedia({ reducedMotion: "no-preference" }); + await page.goto("/browser/fixture.html?case=settings-icon"); + const button = page.getByRole("button", { name: "Settings", exact: true }); + const icon = button.locator("svg"); + for (const hovered of [true, false]) { + const sample = icon.evaluate((element) => new Promise<{ hubChange: number; rotatingFrames: number }>((resolve) => { + const hub = element.querySelector("circle")!; + const outline = element.querySelector("path")!; + const initial = hub.getScreenCTM()!; + const started = performance.now(); + let hubChange = 0; + let rotatingFrames = 0; + function read() { + const matrix = hub.getScreenCTM()!; + for (const key of ["a", "b", "c", "d", "e", "f"] as const) { + hubChange = Math.max(hubChange, Math.abs(matrix[key] - initial[key])); + } + const rotation = outline.getScreenCTM()!; + if (rotation.a > 0.01 && rotation.b > 0.01) rotatingFrames++; + if (performance.now() - started < 450) requestAnimationFrame(read); + else resolve({ hubChange, rotatingFrames }); + } + read(); + })); + if (hovered) await button.hover(); + else await page.mouse.move(0, 0); + const result = await sample; + expect(result.rotatingFrames).toBeGreaterThan(0); + expect(result.hubChange).toBeLessThan(0.0001); + } +}); diff --git a/webui/src/components/icons/product-icons.tsx b/webui/src/components/icons/product-icons.tsx index dd6bcdd33..0ec1949f6 100644 --- a/webui/src/components/icons/product-icons.tsx +++ b/webui/src/components/icons/product-icons.tsx @@ -24,7 +24,7 @@ export const SkillsIcon = productIcon("skills", <>); export const ChannelsIcon = productIcon("channels", <>); export const ArchiveIcon = productIcon("archive", <>); -export const SettingsIcon = productIcon("settings", <>); +export const SettingsIcon = productIcon("settings", <>); export const OverviewIcon = productIcon("overview", <>); export const AppearanceIcon = productIcon("appearance", <>); export const ModelsIcon = productIcon("models", <>); diff --git a/webui/src/globals.css b/webui/src/globals.css index 321aab481..570c6f9d9 100644 --- a/webui/src/globals.css +++ b/webui/src/globals.css @@ -1487,11 +1487,13 @@ transform-origin: center; } @media (hover: hover) and (prefers-reduced-motion: no-preference) { - .icon-action [data-product-icon="settings"] { + .icon-action [data-product-icon="settings"] > path { + transform-box: view-box; + transform-origin: center; transform: rotate(0deg); transition: transform 300ms cubic-bezier(0.2, 0.8, 0.2, 1); } - .icon-action:not(:disabled):hover [data-product-icon="settings"] { + .icon-action:not(:disabled):hover [data-product-icon="settings"] > path { transform: rotate(90deg); } }