Add the theme editor tab and theme preview cards
Phase 5a-5. - Settings → Appearance shows a preview card for each theme. The cards are one radio group. The arrow keys move and select, and the current card has the selection outline and a check mark (UI-047). - Edit theme opens the theme editor as a workbench tab in the window that opened Settings. The window shows each change at once. - The editor shows all 51 color roles in seven groups. Each role has a color picker, a hex field, its lowest readability result, and a reset button. A failure shows a warning icon and its ratio, or "Too close". - Save writes a short schema 3 theme with the built-in theme as its base. A built-in theme does not change. Discard returns to the saved colors, and Duplicate saves a copy. - The editor is a built-in package, like the browser, so it uses the editor tab code of plugins. - 23 new catalog rows with French, Japanese, and Simplified Chinese. - The smoke harness sends emit to every page and emit_to to the pages with the target window label. - Docs: UI-047, ui-design.md, and "Edit a theme" in guides/themes.md. New tests: appearance/themeEditor and tests/unit/theme/themeEditor.spec.ts. Six smoke tests use the cards instead of the theme menu.
This commit is contained in:
@@ -51,14 +51,15 @@ await runSmoke("appearance/palettes", async ({ browser }) => {
|
||||
}
|
||||
const themeName = (theme, mode) => theme === "sakura" ? "Sakura" : `${({ default: "RuneStone", claude: "Claude" })[theme]} ${mode === "light" ? "Light" : "Dark"}`;
|
||||
const picker = (page, name) => page.locator(".picker").filter({ has: page.locator("svg") }).and(page.getByRole("button", { name, exact: true }));
|
||||
// The Color theme cards are one radio group (src/lib/theme/ThemePicker.svelte).
|
||||
const card = (page, name) => page.getByRole("radiogroup", { name: "Color theme", exact: true }).getByRole("radio", { name, exact: true });
|
||||
async function choose(page, theme, mode) {
|
||||
await picker(page, "Color theme").click();
|
||||
await page.getByRole("menuitemradio", { name: themeName(theme, mode), exact: true }).click();
|
||||
await card(page, themeName(theme, mode)).click();
|
||||
}
|
||||
async function openAppearance(page) {
|
||||
await page.goto(`${smokeUrl}/?settingsWindow=true`);
|
||||
await page.getByRole("button", { name: "Appearance", exact: true }).click();
|
||||
await picker(page, "Color theme").waitFor();
|
||||
await page.getByRole("radiogroup", { name: "Color theme", exact: true }).waitFor();
|
||||
}
|
||||
await openCode(0);
|
||||
await openAppearance(settings);
|
||||
@@ -68,7 +69,7 @@ await runSmoke("appearance/palettes", async ({ browser }) => {
|
||||
await page.waitForFunction(({ theme, mode }) => document.documentElement.dataset.palette === theme && document.documentElement.dataset.theme === mode, { theme, mode });
|
||||
assert.equal(await page.evaluate(() => getComputedStyle(document.documentElement).colorScheme), mode);
|
||||
}
|
||||
assert.equal((await picker(secondSettings, "Color theme").textContent()).trim(), themeName(theme, mode));
|
||||
assert.equal(await card(secondSettings, themeName(theme, mode)).getAttribute("aria-checked"), "true");
|
||||
await main.waitForFunction(() => {
|
||||
const root = document.documentElement;
|
||||
const probe = document.createElement("i");
|
||||
@@ -121,9 +122,7 @@ await runSmoke("appearance/palettes", async ({ browser }) => {
|
||||
}
|
||||
}
|
||||
assert.equal(backgrounds.size, 5, "All supported combinations have distinct backgrounds");
|
||||
await picker(settings, "Color theme").click();
|
||||
assert.deepEqual(await settings.getByRole("menuitemradio").allTextContents(), ["RuneStone Light", "RuneStone Dark", "Claude Light", "Claude Dark", "Sakura", "Harvest Moon", "Crimson Pilot", "Silver Serpent"]);
|
||||
await settings.keyboard.press("Escape");
|
||||
assert.deepEqual((await settings.getByRole("radiogroup", { name: "Color theme", exact: true }).getByRole("radio").allTextContents()).map(name => name.trim()), ["RuneStone Light", "RuneStone Dark", "Claude Light", "Claude Dark", "Sakura", "Harvest Moon", "Crimson Pilot", "Silver Serpent"]);
|
||||
assert.equal(await picker(settings, "Appearance").count(), 0);
|
||||
assert.equal(await picker(secondSettings, "Appearance").count(), 0);
|
||||
const sakura = await settings.evaluate(() => {
|
||||
@@ -151,10 +150,10 @@ await runSmoke("appearance/palettes", async ({ browser }) => {
|
||||
await settings.setViewportSize({ width: 360, height: 480 });
|
||||
assert(await settings.evaluate(() => document.documentElement.scrollWidth <= innerWidth), "Narrow settings do not overflow the viewport");
|
||||
assert(await settings.locator("dialog .content").evaluate(node => node.scrollWidth <= node.clientWidth), "Appearance controls do not overflow the content area");
|
||||
const control = picker(settings, "Color theme");
|
||||
const control = card(settings, themeName(theme, mode));
|
||||
await control.scrollIntoViewIfNeeded();
|
||||
const bounds = await control.boundingBox();
|
||||
assert(bounds.x >= 0 && bounds.x + bounds.width <= 360 && bounds.height >= 28, "Color theme remains reachable at 360px");
|
||||
assert(bounds.x >= 0 && bounds.x + bounds.width <= 360 && bounds.height >= 28, "The current theme card remains reachable at 360px");
|
||||
await settings.screenshot({ path: path.join(output, `appearance-${theme}-${mode}-360.png`) });
|
||||
}
|
||||
assert.deepEqual(pages.flatMap(page => page.errors), []);
|
||||
|
||||
Reference in New Issue
Block a user