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:
@@ -8,7 +8,7 @@
|
||||
import { showActionMenu } from '$lib/ui/managedActionMenu';
|
||||
import { saveBackgroundImage, removeBackgroundImage } from './backgroundImages';
|
||||
import { onSettingsChange } from '$lib/settings/store';
|
||||
import { DEFAULT_APPEARANCE, BUILTIN_THEMES, themeModes, BACKGROUND_POSITIONS, BACKGROUND_SIZES, readAppearance, normalizeAppearance, saveAppearance, exportAppearanceTheme, type Appearance, type ThemeName } from './appearance';
|
||||
import { DEFAULT_APPEARANCE, BUILTIN_THEMES, themeModes, themeNotice, BACKGROUND_POSITIONS, BACKGROUND_SIZES, readAppearance, normalizeAppearance, saveAppearance, exportAppearanceTheme, type Appearance, type ThemeName } from './appearance';
|
||||
let appearance = $state<Appearance>({ ...DEFAULT_APPEARANCE });
|
||||
let error = $state('');
|
||||
let status = $state('');
|
||||
@@ -22,6 +22,7 @@
|
||||
themeModes(theme.id).map(mode => ({
|
||||
theme: theme.id, mode, name: themeModes(theme.id).length === 1 ? theme.name : `${theme.name} ${mode === 'light' ? $t('Light') : $t('Dark')}`,
|
||||
}))));
|
||||
const notice = $derived(themeNotice(appearance.theme));
|
||||
onDestroy(() => closePicker());
|
||||
function picker(event: MouseEvent) {
|
||||
closePicker();
|
||||
@@ -131,7 +132,7 @@
|
||||
}} />{/if}
|
||||
</div>
|
||||
<p>{$t("Edit the exported JSON colors and fonts, then choose Install theme. The template contains one color palette and font families.")}</p>
|
||||
{#if appearance.theme === 'sakura'}<p>{$t("Sakura uses a light appearance.")}</p>{/if}
|
||||
{#if notice}<p>{$t(notice)}</p>{/if}
|
||||
<h3>{$t("Transparency")}</h3>
|
||||
<div class="card">
|
||||
<label><span>{$t("Transparent surfaces")}</span><input type="checkbox" role="switch" checked={appearance.transparency?.enabled !== false} onchange={event => change({ ...appearance, transparency: { amount: appearance.transparency?.amount ?? 18, enabled: event.currentTarget.checked } })} /></label>
|
||||
@@ -165,7 +166,7 @@
|
||||
.setting-row+.setting-row{border-top:1px solid var(--rs-border)}
|
||||
.picker{display:flex;align-items:center;gap:8px;min-height:var(--rs-settings-control-height);max-width:100%;padding:4px 8px;background:var(--rs-bg);color:var(--rs-text);border:1px solid var(--rs-border);border-radius:var(--rs-control-radius)}
|
||||
.picker :global(svg){width:14px;height:14px;flex-shrink:0}
|
||||
.picker:focus-visible{outline:2px solid var(--rs-accent);outline-offset:2px}
|
||||
.picker:focus-visible{outline:2px solid var(--rs-focus);outline-offset:2px}
|
||||
.theme-preview{display:flex;gap:var(--rs-settings-gap);margin-top:var(--rs-settings-gap);padding:var(--rs-settings-row-padding);border:1px solid var(--rs-border);border-radius:var(--rs-control-radius);background:var(--rs-bg);min-height:100px}
|
||||
.preview-sidebar{display:flex;flex-direction:column;gap:var(--rs-settings-gap);width:22%;padding:var(--rs-settings-row-padding);background:var(--rs-bg-elevated);border-radius:var(--rs-control-radius)}
|
||||
.preview-sidebar span{height:6px;background:var(--rs-text-dim);opacity:.5;border-radius:var(--rs-control-radius)}
|
||||
@@ -174,7 +175,7 @@
|
||||
.preview-document strong{color:var(--rs-text-strong);font-family:var(--rs-font-heading)}
|
||||
.preview-prose{font-family:var(--rs-font-prose);color:var(--rs-text)}
|
||||
.preview-selection{background:var(--rs-selection);color:var(--rs-text);padding:2px 4px;border-radius:var(--rs-item-selection-radius)}
|
||||
.preview-link{color:var(--rs-accent);font-size:var(--rs-settings-description-size)}
|
||||
.preview-link{color:var(--rs-link);font-size:var(--rs-settings-description-size)}
|
||||
.preview-code{font-family:var(--rs-font-mono);font-size:var(--rs-settings-description-size);line-height:1.6;overflow-wrap:anywhere;white-space:normal}
|
||||
.preview-keyword{color:var(--rs-syntax-keyword)}
|
||||
.preview-string{color:var(--rs-syntax-string,var(--rs-ok))}
|
||||
@@ -189,13 +190,13 @@
|
||||
.overlay-controls input[type=range]::-webkit-slider-thumb{appearance:none;width:18px;height:18px;margin-top:-7px;background:var(--rs-accent);border:2px solid var(--rs-text-strong);border-radius:50%}
|
||||
.overlay-controls input[type=range]::-moz-range-track{height:4px;background:var(--rs-bg-active);border:1px solid var(--rs-text-dim);border-radius:var(--rs-control-radius)}
|
||||
.overlay-controls input[type=range]::-moz-range-thumb{width:14px;height:14px;background:var(--rs-accent);border:2px solid var(--rs-text-strong);border-radius:50%}
|
||||
.overlay-controls input[type=range]:focus-visible{outline:2px solid var(--rs-accent);outline-offset:2px;border-radius:var(--rs-control-radius)}
|
||||
.overlay-controls input[type=range]:focus-visible{outline:2px solid var(--rs-focus);outline-offset:2px;border-radius:var(--rs-control-radius)}
|
||||
.overlay-controls input[type=range]:disabled{cursor:default}
|
||||
.overlay-controls input[type=range]:disabled::-webkit-slider-thumb{background:var(--rs-text-dim)}
|
||||
.overlay-controls input[type=range]:disabled::-moz-range-thumb{background:var(--rs-text-dim)}
|
||||
.overlay-value{padding:0;gap:4px;flex-wrap:nowrap}
|
||||
.overlay-value input{width:64px;min-height:var(--rs-settings-control-height);box-sizing:border-box;padding:4px 6px;background:var(--rs-bg);color:var(--rs-text);border:1px solid var(--rs-border);border-radius:var(--rs-control-radius);font:inherit}
|
||||
.overlay-value input:focus-visible{outline:2px solid var(--rs-accent);outline-offset:2px}
|
||||
.overlay-value input:focus-visible{outline:2px solid var(--rs-focus);outline-offset:2px}
|
||||
[role=alert]{color:var(--rs-error)}
|
||||
.theme-actions{display:flex;gap:var(--rs-settings-gap);flex-wrap:wrap;margin-top:var(--rs-settings-gap)}
|
||||
.theme-actions button{min-height:var(--rs-settings-control-height);border:1px solid var(--rs-border);border-radius:var(--rs-control-radius);background:var(--rs-bg-elevated);color:var(--rs-text);padding:4px 8px}
|
||||
|
||||
Reference in New Issue
Block a user