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
This commit is contained in:
1 parent
d8714fe664
commit
743d40bbba
4 files changed
+65
-3
No files matched your search
@@ -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(<TooltipProvider>
|
||||
? <ClientProvider client={railClient} token="fixture"><AppsFixture /></ClientProvider>
|
||||
: parameters.get("case") === "rail"
|
||||
? <ClientProvider client={railClient} token="fixture" webuiCapabilities={["webui.prompt-navigation.v1"]}><RailFixture /></ClientProvider>
|
||||
: parameters.get("case") === "settings-icon"
|
||||
? <Button variant="icon" size="icon" aria-label="Settings"><SettingsIcon className="h-4 w-4" /></Button>
|
||||
: parameters.get("case") === "history"
|
||||
? <HistoryFixture />
|
||||
: <TallDialogFixture placement={parameters.get("placement") === "bottom" ? "bottom" : "center"} />}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user