M1.10: light theme, live theme switching, editor tokens
- theme::LIGHT next to DARK with the 10 new tokens (editor selection, active line, cursor, gutter, match, font size, tab active/modified, notice); light fg-muted, accent and error darkened for WCAG AA - theme.list, theme.systemPreference, themeChanged event when the resolved theme changes (settings.set/reset appearance.theme, or the OS preference in system mode) - desktop init script and window background from the stored setting; system mode uses a prefers-color-scheme media query for the first frame - ui/src/theme.ts applies tokens to :root and color-scheme live; editor, tabs and notice drop their var() fallbacks - Vitest WCAG AA contrast check against a Rust-maintained snapshot, DOM tests, headless control-channel test - docs: architecture Themes, parity rows, ui-parity, gaps, roadmaps Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
1ab448de4d
commit
cde6e119c6
29 changed files with 1192 additions and 72 deletions
|
|
@ -5,6 +5,7 @@ use serde::Deserialize;
|
|||
use serde_json::{Map, Value, json};
|
||||
|
||||
use crate::cmd::params::parse;
|
||||
use crate::cmd::theme;
|
||||
use crate::settings::{self, DEFS, SetError};
|
||||
use crate::{Command, CommandSpec, EngineError, Event, Outcome, State};
|
||||
|
||||
|
|
@ -96,11 +97,12 @@ impl Command for Set {
|
|||
fn run(&self, state: &mut State, params: Value) -> Result<Outcome, EngineError> {
|
||||
let id = self.spec().id;
|
||||
let p: SetParams = parse(id, params)?;
|
||||
let before = theme::resolved(state);
|
||||
let changed = state
|
||||
.settings
|
||||
.set(&p.key, p.value)
|
||||
.map_err(|e| set_error(id, e))?;
|
||||
finish(state, &p.key, changed)
|
||||
finish(state, &p.key, changed, before)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -129,8 +131,9 @@ impl Command for Reset {
|
|||
fn run(&self, state: &mut State, params: Value) -> Result<Outcome, EngineError> {
|
||||
let id = self.spec().id;
|
||||
let p: ResetParams = parse(id, params)?;
|
||||
let before = theme::resolved(state);
|
||||
let changed = state.settings.reset(&p.key).map_err(|e| set_error(id, e))?;
|
||||
finish(state, &p.key, changed)
|
||||
finish(state, &p.key, changed, before)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -144,12 +147,19 @@ fn set_error(command: &str, error: SetError) -> EngineError {
|
|||
}
|
||||
}
|
||||
|
||||
/// Emits `settingsChanged` if the value changed and returns `{ value }`.
|
||||
fn finish(state: &mut State, key: &str, changed: bool) -> Result<Outcome, EngineError> {
|
||||
/// Emits `settingsChanged` if the value changed, then `themeChanged` if the
|
||||
/// resolved theme is no longer `before`, and returns `{ value }`.
|
||||
fn finish(
|
||||
state: &mut State,
|
||||
key: &str,
|
||||
changed: bool,
|
||||
before: crate::theme::Theme,
|
||||
) -> Result<Outcome, EngineError> {
|
||||
if changed {
|
||||
state.emit(Event::SettingsChanged {
|
||||
keys: vec![key.to_string()],
|
||||
});
|
||||
theme::emit_if_changed(state, before);
|
||||
}
|
||||
let value = state
|
||||
.settings
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue