Give themes named color roles, theme data files, and file format 3
Phase 5a-1 and 5a-2. - roles.ts names 51 color roles. One derivation rule fills the roles that a theme does not give, for all themes. tokens.css keeps only the root defaults, without theme blocks. - Each built-in theme is one data file in src/lib/theme/themes/. No code outside the theme data names a theme ID. characterThemes.ts is gone. - New roles: link, focus, on-accent, highlight, scrim, the syntax roles, and 16 terminal (ANSI) roles. Stray colors in components use the roles. - contrast.ts checks each theme against the readability rules of docs/ui-color.md. The tests mark the known palette failures as todo, and a second test fails when a known failure starts to pass. - Theme files use schema 3 with a mode and an optional built-in base. A short file gets the missing colors and fonts from the base. Schema 1 and 2 files still import. Old syntax names convert on import. - Docs: ui-color.md, plugin-development.md (theme tokens), ui-design.md, guides/themes.md, and UI-041 and UI-042 in design-decisions.md. The applied colors stay the same for every built-in theme, except three small changes: the conflict line uses the warn color, the Write highlight uses the highlight role, and two dialog backdrops use the scrim role. pnpm check passes. pnpm test: 447 pass, 31 todo, 0 fail. Full smoke suite: 93 passed, 2 known. appearance/palettes read the old syntax names and passed 3 of 3 times after the fix. workspace/manageTemplates failed one time and passed on retry.
This commit is contained in:
@@ -65,14 +65,17 @@ await runSmoke('appearance/typography', async ({ browser }) => {
|
||||
await main.waitForFunction(theme => document.documentElement.dataset.palette === theme, theme);
|
||||
await main.getByRole('textbox', { name: 'Writing editor', exact: true }).press('Control+Home');
|
||||
await main.evaluate(() => { getSelection().removeAllRanges(); document.activeElement?.blur(); });
|
||||
// The theme sets its fonts as inline properties of the root. Put back those values after each temporary change.
|
||||
for (const page of [main, settings]) {
|
||||
await page.evaluate(font => {
|
||||
for (const role of ['ui', 'prose', 'heading']) document.documentElement.style.setProperty(`--rs-font-${role}`, `"${font}"`);
|
||||
}, oldFont);
|
||||
const saved = await page.evaluate(font => ['ui', 'prose', 'heading'].map(role => {
|
||||
const value = document.documentElement.style.getPropertyValue(`--rs-font-${role}`);
|
||||
document.documentElement.style.setProperty(`--rs-font-${role}`, `"${font}"`);
|
||||
return value;
|
||||
}), oldFont);
|
||||
await page.screenshot({ path: path.join(output, `${theme}-before-${page === main ? 'document' : 'settings'}.png`) });
|
||||
await page.evaluate(() => {
|
||||
for (const role of ['ui', 'prose', 'heading']) document.documentElement.style.removeProperty(`--rs-font-${role}`);
|
||||
});
|
||||
await page.evaluate(saved => {
|
||||
['ui', 'prose', 'heading'].forEach((role, index) => document.documentElement.style.setProperty(`--rs-font-${role}`, saved[index]));
|
||||
}, saved);
|
||||
}
|
||||
const roles = {
|
||||
ui: await rendered(settings, selectors.ui),
|
||||
@@ -118,14 +121,14 @@ await runSmoke('appearance/typography', async ({ browser }) => {
|
||||
// Drop the first family from each stack and check that the fallback still renders glyphs.
|
||||
const fallback = {};
|
||||
for (const [role, page] of [['ui', settings], ['prose', main], ['heading', main]]) {
|
||||
await page.evaluate(role => {
|
||||
const css = getComputedStyle(document.documentElement);
|
||||
const stack = css.getPropertyValue(`--rs-font-${role}`);
|
||||
const stack = await page.evaluate(role => {
|
||||
const stack = getComputedStyle(document.documentElement).getPropertyValue(`--rs-font-${role}`);
|
||||
document.documentElement.style.setProperty(`--rs-font-${role}`, stack.slice(stack.indexOf(',') + 1));
|
||||
return stack;
|
||||
}, role);
|
||||
fallback[role] = await rendered(page, selectors[role]);
|
||||
assert(fallback[role].rendered.length > 0);
|
||||
await page.evaluate(role => document.documentElement.style.removeProperty(`--rs-font-${role}`), role);
|
||||
await page.evaluate(([role, stack]) => document.documentElement.style.setProperty(`--rs-font-${role}`, stack), [role, stack]);
|
||||
}
|
||||
report.push({ theme, oldFont, roles, fallback });
|
||||
console.log(`PASS ${theme}: real UI and prose sizes, rendered fonts, shared monospace, selection, narrow settings, keyboard focus, long plugin navigation`);
|
||||
|
||||
Reference in New Issue
Block a user