PM: merge M1.10 themes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
6d976ed03e
29 changed files with 1192 additions and 72 deletions
|
|
@ -26,7 +26,7 @@ Dimension hours overlap: language, framework and tooling hours are part of the f
|
||||||
| Dimension | % | One agent (h) | Doc |
|
| Dimension | % | One agent (h) | Doc |
|
||||||
|---|---:|---:|---|
|
|---|---:|---:|---|
|
||||||
| Features (depth) | ~1.4% | ~2,920 | [target-app-parity.md](docs/target-app-parity.md) |
|
| Features (depth) | ~1.4% | ~2,920 | [target-app-parity.md](docs/target-app-parity.md) |
|
||||||
| UI/UX fidelity | 0% | ~150 on top of features | [ui-parity.md](docs/ui-parity.md) |
|
| UI/UX fidelity | 1% (est.) | ~150 on top of features | [ui-parity.md](docs/ui-parity.md) |
|
||||||
| PHP language support | 0% | ~920 (in features) | [language-parity.md](docs/language-parity.md) |
|
| PHP language support | 0% | ~920 (in features) | [language-parity.md](docs/language-parity.md) |
|
||||||
| Frameworks (Symfony, Laravel, Shopware, WordPress) | 0% | ~300 (in features) | [framework-parity.md](docs/framework-parity.md) |
|
| Frameworks (Symfony, Laravel, Shopware, WordPress) | 0% | ~300 (in features) | [framework-parity.md](docs/framework-parity.md) |
|
||||||
| Tooling (Git, terminal, debugger, tests, Composer, DB) | 0% | ~730 (in features) | [tooling-parity.md](docs/tooling-parity.md) |
|
| Tooling (Git, terminal, debugger, tests, Composer, DB) | 0% | ~730 (in features) | [tooling-parity.md](docs/tooling-parity.md) |
|
||||||
|
|
@ -35,7 +35,7 @@ Dimension hours overlap: language, framework and tooling hours are part of the f
|
||||||
| Stability | 5% | ~100 | [gaps.md › G11](docs/gaps.md) |
|
| Stability | 5% | ~100 | [gaps.md › G11](docs/gaps.md) |
|
||||||
| Agent automation | 10% | ~60 | AGENTS.md |
|
| Agent automation | 10% | ~60 | AGENTS.md |
|
||||||
|
|
||||||
Stability 5%: no-panic lints, the engine guard and a fuzzed control protocol exist; the recovery journal does not. Agent automation 10%: the control channel (ping, execute, listCommands, screenshot) works; MCP and the CLI do not exist yet. Both are estimated. Localization 5% (estimated): every UI string comes from an English catalog enforced by lint; engine messages, the language switch and German are missing.
|
Stability 5%: no-panic lints, the engine guard and a fuzzed control protocol exist; the recovery journal does not. Agent automation 10%: the control channel (ping, execute, listCommands, screenshot) works; MCP and the CLI do not exist yet. Both are estimated. Localization 5% (estimated): every UI string comes from an English catalog enforced by lint; engine messages, the language switch and German are missing. UI/UX fidelity 1% (estimated): light and dark themes switch live and pass a WCAG AA contrast test; the rest of the ui-parity checklist is open.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
|
|
@ -60,7 +60,7 @@ Stability 5%: no-panic lints, the engine guard and a fuzzed control protocol exi
|
||||||
| HTTP client | 0% | ~60 |
|
| HTTP client | 0% | ~60 |
|
||||||
| Web languages (JS/TS, Vue, CSS, Twig, Blade) | 0% | ~200 |
|
| Web languages (JS/TS, Vue, CSS, Twig, Blade) | 0% | ~200 |
|
||||||
| Docker and remote | 0% | ~120 |
|
| Docker and remote | 0% | ~120 |
|
||||||
| Settings, keymaps, themes | 0% | ~60 |
|
| Settings, keymaps, themes | 4% (est.) | ~60 |
|
||||||
| Plug-ins and ecosystem | 0% | ~120 |
|
| Plug-ins and ecosystem | 0% | ~120 |
|
||||||
| AI features | 0% | ~60 |
|
| AI features | 0% | ~60 |
|
||||||
|
|
||||||
|
|
@ -77,6 +77,7 @@ All hours estimated. Weights, evidence and the missing items per area: [target-a
|
||||||
|
|
||||||
| Date | What landed |
|
| Date | What landed |
|
||||||
|---|---|
|
|---|---|
|
||||||
|
| 2026-10-16 | M1.10: Lutra Light next to Lutra Dark, switched live through the `appearance.theme` setting or following the OS (`system`); the window starts in the stored theme; the editor, tabs and notices get their own tokens; both themes pass a WCAG AA contrast test. |
|
||||||
| 2026-10-15 | M1.11: every interface string comes from an English message catalog (`ui/src/i18n/en.json`), enforced by a lint rule and a catalog test; the groundwork for German. |
|
| 2026-10-15 | M1.11: every interface string comes from an English message catalog (`ui/src/i18n/en.json`), enforced by a lint rule and a catalog test; the groundwork for German. |
|
||||||
| 2026-10-15 | M1.6: files open in tabs with a CodeMirror editor synced to the engine; save, save all, close with a Save / Don't Save / Cancel question, a notice when a file with unsaved changes changes on disk; a 1 MB file opens in about 90 ms. |
|
| 2026-10-15 | M1.6: files open in tabs with a CodeMirror editor synced to the engine; save, save all, close with a Save / Don't Save / Cancel question, a notice when a file with unsaved changes changes on disk; a 1 MB file opens in about 90 ms. |
|
||||||
| 2026-10-15 | M1 so far: text buffer, VFS with native watching, engine workspace (files, buffers, edit protocol, events), desktop bridge: open a folder by picker or command line, browse it in the project tree with live updates from disk. |
|
| 2026-10-15 | M1 so far: text buffer, VFS with native watching, engine workspace (files, buffers, edit protocol, events), desktop bridge: open a folder by picker or command line, browse it in the project tree with live updates from disk. |
|
||||||
|
|
@ -87,6 +88,7 @@ All hours estimated. Weights, evidence and the missing items per area: [target-a
|
||||||
|
|
||||||
| Date | Change | Summary |
|
| Date | Change | Summary |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
|
| 2026-10-16 | minor | M1.10: UI/UX fidelity 1%, Settings row 4% (estimates), progress log |
|
||||||
| 2026-10-15 | minor | M1.11: localization 5% (English UI catalog), progress log |
|
| 2026-10-15 | minor | M1.11: localization 5% (English UI catalog), progress log |
|
||||||
| 2026-10-15 | minor | Cycle C1 review: stage line, breadth estimate, hours recalibrated ×0.1 |
|
| 2026-10-15 | minor | Cycle C1 review: stage line, breadth estimate, hours recalibrated ×0.1 |
|
||||||
| 2026-10-15 | minor | Feature depth ~1.4%: tabs and editor (M1.6) |
|
| 2026-10-15 | minor | Feature depth ~1.4%: tabs and editor (M1.6) |
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
//! The Lutra desktop app (layer L6): a Tauri 2 shell around the engine.
|
//! The Lutra desktop app (layer L6): a Tauri 2 shell around the engine.
|
||||||
//!
|
//!
|
||||||
//! Builds the main window with the theme tokens injected before first paint,
|
//! Builds the main window with the stored theme's tokens injected before
|
||||||
|
//! first paint,
|
||||||
//! bridges frontend IPC to engine commands and engine events to the window
|
//! bridges frontend IPC to engine commands and engine events to the window
|
||||||
//! (see [`host`]), opens the project given on the command line, and
|
//! (see [`host`]), opens the project given on the command line, and
|
||||||
//! optionally serves the JSON control channel (`--control PORT`).
|
//! optionally serves the JSON control channel (`--control PORT`).
|
||||||
|
|
@ -59,7 +60,6 @@ fn main() -> ExitCode {
|
||||||
fn run(args: &args::Args) -> Result<(), String> {
|
fn run(args: &args::Args) -> Result<(), String> {
|
||||||
let slot: Arc<OnceLock<Arc<Host>>> = Arc::new(OnceLock::new());
|
let slot: Arc<OnceLock<Arc<Host>>> = Arc::new(OnceLock::new());
|
||||||
let setup_slot = slot.clone();
|
let setup_slot = slot.clone();
|
||||||
let theme = theme::DARK;
|
|
||||||
let initial_path = args.path.clone();
|
let initial_path = args.path.clone();
|
||||||
let app = tauri::Builder::default()
|
let app = tauri::Builder::default()
|
||||||
.plugin(tauri_plugin_dialog::init())
|
.plugin(tauri_plugin_dialog::init())
|
||||||
|
|
@ -71,15 +71,19 @@ fn run(args: &args::Args) -> Result<(), String> {
|
||||||
.setup(move |app| {
|
.setup(move |app| {
|
||||||
let setup_host = setup_slot.get().ok_or("the host is not ready")?;
|
let setup_host = setup_slot.get().ok_or("the host is not ready")?;
|
||||||
setup_host.attach(app.handle().clone());
|
setup_host.attach(app.handle().clone());
|
||||||
|
let setting = stored_theme(setup_host);
|
||||||
let mut window = WebviewWindowBuilder::new(app, MAIN_WINDOW, WebviewUrl::default())
|
let mut window = WebviewWindowBuilder::new(app, MAIN_WINDOW, WebviewUrl::default())
|
||||||
.title(WINDOW_TITLE)
|
.title(WINDOW_TITLE)
|
||||||
.inner_size(1200.0, 800.0)
|
.inner_size(1200.0, 800.0)
|
||||||
.min_inner_size(640.0, 400.0)
|
.min_inner_size(640.0, 400.0)
|
||||||
.initialization_script(theme::init_script(&theme));
|
.initialization_script(theme::init_script(&setting));
|
||||||
if let Some(color) = token_color(&theme, "bg") {
|
if let Some(color) = token_color(&theme::resolve(&setting, None), "bg") {
|
||||||
window = window.background_color(color);
|
window = window.background_color(color);
|
||||||
}
|
}
|
||||||
window.build()?;
|
let window = window.build()?;
|
||||||
|
if setting == theme::SYSTEM {
|
||||||
|
follow_system_background(&window);
|
||||||
|
}
|
||||||
if let Some(path) = &initial_path
|
if let Some(path) = &initial_path
|
||||||
&& let Err(e) = setup_host.open_project(path)
|
&& let Err(e) = setup_host.open_project(path)
|
||||||
{
|
{
|
||||||
|
|
@ -139,6 +143,36 @@ fn log_startup_events(events: &[Event]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The stored `appearance.theme` value, `system` if it cannot be read.
|
||||||
|
fn stored_theme(host: &Host) -> String {
|
||||||
|
host.run(
|
||||||
|
"settings.get",
|
||||||
|
serde_json::json!({ "keys": ["appearance.theme"] }),
|
||||||
|
)
|
||||||
|
.ok()
|
||||||
|
.and_then(|v| {
|
||||||
|
v.get("values")?
|
||||||
|
.get("appearance.theme")?
|
||||||
|
.as_str()
|
||||||
|
.map(str::to_string)
|
||||||
|
})
|
||||||
|
.unwrap_or_else(|| theme::SYSTEM.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// In "system" mode, sets the window background to the theme the OS
|
||||||
|
/// prefers; the page itself follows the OS through the init script's
|
||||||
|
/// `prefers-color-scheme` query. Failures are ignored: the background only
|
||||||
|
/// shows before the first paint, and the dark default stays.
|
||||||
|
fn follow_system_background(window: &tauri::WebviewWindow) {
|
||||||
|
let Ok(os) = window.theme() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let resolved = theme::resolve(theme::SYSTEM, Some(os == tauri::Theme::Dark));
|
||||||
|
if let Some(color) = token_color(&resolved, "bg") {
|
||||||
|
let _ = window.set_background_color(Some(color));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Reads a `#rrggbb` theme token as an opaque colour for the window
|
/// Reads a `#rrggbb` theme token as an opaque colour for the window
|
||||||
/// background, so that no white frame shows before the page paints.
|
/// background, so that no white frame shows before the page paints.
|
||||||
fn token_color(theme: &theme::Theme, name: &str) -> Option<Color> {
|
fn token_color(theme: &theme::Theme, name: &str) -> Option<Color> {
|
||||||
|
|
|
||||||
134
crates/control/tests/theme.rs
Normal file
134
crates/control/tests/theme.rs
Normal file
|
|
@ -0,0 +1,134 @@
|
||||||
|
//! Theme switching over a real TCP socket: `settings.set appearance.theme`
|
||||||
|
//! and `theme.systemPreference` stream `themeChanged` with the theme's
|
||||||
|
//! tokens to `events.subscribe` clients, the way the desktop window gets
|
||||||
|
//! them.
|
||||||
|
|
||||||
|
#![allow(
|
||||||
|
clippy::unwrap_used,
|
||||||
|
clippy::expect_used,
|
||||||
|
clippy::indexing_slicing,
|
||||||
|
clippy::panic
|
||||||
|
)]
|
||||||
|
|
||||||
|
use std::io::{BufRead, BufReader, Write};
|
||||||
|
use std::net::TcpStream;
|
||||||
|
use std::sync::Arc;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use lutra_engine::theme;
|
||||||
|
use lutra_testkit::EngineBackend;
|
||||||
|
use serde_json::{Value, json};
|
||||||
|
|
||||||
|
/// A client that collects event lines and returns responses.
|
||||||
|
struct Client {
|
||||||
|
reader: BufReader<TcpStream>,
|
||||||
|
writer: TcpStream,
|
||||||
|
events: Vec<Value>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Client {
|
||||||
|
fn connect(addr: std::net::SocketAddr) -> Self {
|
||||||
|
let stream = TcpStream::connect(addr).unwrap();
|
||||||
|
stream
|
||||||
|
.set_read_timeout(Some(Duration::from_secs(5)))
|
||||||
|
.unwrap();
|
||||||
|
Self {
|
||||||
|
writer: stream.try_clone().unwrap(),
|
||||||
|
reader: BufReader::new(stream),
|
||||||
|
events: Vec::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn line(&mut self) -> Value {
|
||||||
|
let mut line = String::new();
|
||||||
|
self.reader.read_line(&mut line).expect("line within 5 s");
|
||||||
|
serde_json::from_str(&line).unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sends a request and returns its response, collecting event lines that
|
||||||
|
/// arrive before it.
|
||||||
|
fn call(&mut self, request: Value) -> Value {
|
||||||
|
self.writer
|
||||||
|
.write_all(format!("{request}\n").as_bytes())
|
||||||
|
.unwrap();
|
||||||
|
loop {
|
||||||
|
let line = self.line();
|
||||||
|
if line.get("event").is_some() {
|
||||||
|
self.events.push(line["event"].clone());
|
||||||
|
} else {
|
||||||
|
return line;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Waits for the next `themeChanged` event (events arrive from a
|
||||||
|
/// subscriber queue, possibly after the response) and drops the events
|
||||||
|
/// before it.
|
||||||
|
fn next_theme(&mut self) -> Value {
|
||||||
|
loop {
|
||||||
|
if let Some(at) = self.events.iter().position(|e| e["kind"] == "themeChanged") {
|
||||||
|
let theme = self.events.remove(at);
|
||||||
|
self.events.drain(..at);
|
||||||
|
return theme;
|
||||||
|
}
|
||||||
|
let line = self.line();
|
||||||
|
if line.get("event").is_some() {
|
||||||
|
self.events.push(line["event"].clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn execute(command: &str, params: Value) -> Value {
|
||||||
|
json!({"id": 2, "method": "engine.execute", "params": {"command": command, "params": params}})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn tokens(theme: &theme::Theme) -> Value {
|
||||||
|
serde_json::to_value(theme::token_map(theme)).unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn switching_streams_theme_changed_with_tokens() {
|
||||||
|
let dir = tempfile::tempdir().unwrap();
|
||||||
|
let backend = Arc::new(EngineBackend::with_config(lutra_testkit::engine_config(
|
||||||
|
dir.path(),
|
||||||
|
)));
|
||||||
|
let server = lutra_control::start(0, backend.clone()).unwrap();
|
||||||
|
let mut client = Client::connect(server.local_addr());
|
||||||
|
client.call(json!({"id": 1, "method": "events.subscribe"}));
|
||||||
|
|
||||||
|
let r = client.call(execute("theme.list", Value::Null));
|
||||||
|
assert_eq!(r["result"][1]["id"], "lutra-light", "{r}");
|
||||||
|
|
||||||
|
let r = client.call(execute(
|
||||||
|
"settings.set",
|
||||||
|
json!({"key": "appearance.theme", "value": "lutra-light"}),
|
||||||
|
));
|
||||||
|
assert_eq!(r["result"]["value"], "lutra-light", "{r}");
|
||||||
|
let changed = client.next_theme();
|
||||||
|
assert_eq!(changed["id"], "lutra-light");
|
||||||
|
assert_eq!(changed["dark"], false);
|
||||||
|
assert_eq!(changed["tokens"], tokens(&theme::LIGHT));
|
||||||
|
|
||||||
|
client.call(execute(
|
||||||
|
"settings.set",
|
||||||
|
json!({"key": "appearance.theme", "value": "lutra-dark"}),
|
||||||
|
));
|
||||||
|
let changed = client.next_theme();
|
||||||
|
assert_eq!(changed["id"], "lutra-dark");
|
||||||
|
assert_eq!(changed["dark"], true);
|
||||||
|
assert_eq!(changed["tokens"], tokens(&theme::DARK));
|
||||||
|
|
||||||
|
client.call(execute(
|
||||||
|
"settings.set",
|
||||||
|
json!({"key": "appearance.theme", "value": "system"}),
|
||||||
|
));
|
||||||
|
let r = client.call(execute("theme.systemPreference", json!({"dark": false})));
|
||||||
|
assert_eq!(r["result"]["id"], "lutra-light", "{r}");
|
||||||
|
let changed = client.next_theme();
|
||||||
|
assert_eq!(
|
||||||
|
changed["id"], "lutra-light",
|
||||||
|
"switching from dark to system on an unreported (dark) OS must not emit"
|
||||||
|
);
|
||||||
|
assert_eq!(changed["tokens"]["--lt-editor-selection-bg"], "#e5d7c9");
|
||||||
|
}
|
||||||
|
|
@ -6,6 +6,7 @@ mod file;
|
||||||
mod params;
|
mod params;
|
||||||
mod project;
|
mod project;
|
||||||
mod settings;
|
mod settings;
|
||||||
|
pub mod theme;
|
||||||
|
|
||||||
use crate::{EngineError, Registry};
|
use crate::{EngineError, Registry};
|
||||||
|
|
||||||
|
|
@ -30,5 +31,7 @@ pub fn register_builtins(registry: &mut Registry) -> Result<(), EngineError> {
|
||||||
registry.register(Box::new(settings::Get))?;
|
registry.register(Box::new(settings::Get))?;
|
||||||
registry.register(Box::new(settings::Set))?;
|
registry.register(Box::new(settings::Set))?;
|
||||||
registry.register(Box::new(settings::Reset))?;
|
registry.register(Box::new(settings::Reset))?;
|
||||||
|
registry.register(Box::new(theme::List))?;
|
||||||
|
registry.register(Box::new(theme::SystemPreference))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ use serde::Deserialize;
|
||||||
use serde_json::{Map, Value, json};
|
use serde_json::{Map, Value, json};
|
||||||
|
|
||||||
use crate::cmd::params::parse;
|
use crate::cmd::params::parse;
|
||||||
|
use crate::cmd::theme;
|
||||||
use crate::settings::{self, DEFS, SetError};
|
use crate::settings::{self, DEFS, SetError};
|
||||||
use crate::{Command, CommandSpec, EngineError, Event, Outcome, State};
|
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> {
|
fn run(&self, state: &mut State, params: Value) -> Result<Outcome, EngineError> {
|
||||||
let id = self.spec().id;
|
let id = self.spec().id;
|
||||||
let p: SetParams = parse(id, params)?;
|
let p: SetParams = parse(id, params)?;
|
||||||
|
let before = theme::resolved(state);
|
||||||
let changed = state
|
let changed = state
|
||||||
.settings
|
.settings
|
||||||
.set(&p.key, p.value)
|
.set(&p.key, p.value)
|
||||||
.map_err(|e| set_error(id, e))?;
|
.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> {
|
fn run(&self, state: &mut State, params: Value) -> Result<Outcome, EngineError> {
|
||||||
let id = self.spec().id;
|
let id = self.spec().id;
|
||||||
let p: ResetParams = parse(id, params)?;
|
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))?;
|
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 }`.
|
/// Emits `settingsChanged` if the value changed, then `themeChanged` if the
|
||||||
fn finish(state: &mut State, key: &str, changed: bool) -> Result<Outcome, EngineError> {
|
/// 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 {
|
if changed {
|
||||||
state.emit(Event::SettingsChanged {
|
state.emit(Event::SettingsChanged {
|
||||||
keys: vec![key.to_string()],
|
keys: vec![key.to_string()],
|
||||||
});
|
});
|
||||||
|
theme::emit_if_changed(state, before);
|
||||||
}
|
}
|
||||||
let value = state
|
let value = state
|
||||||
.settings
|
.settings
|
||||||
|
|
|
||||||
102
crates/engine/src/cmd/theme.rs
Normal file
102
crates/engine/src/cmd/theme.rs
Normal file
|
|
@ -0,0 +1,102 @@
|
||||||
|
//! Theme commands: `theme.list` and `theme.systemPreference`. Switching
|
||||||
|
//! themes goes through `settings.set appearance.theme`; whenever the
|
||||||
|
//! resolved theme changes, `themeChanged` carries its tokens.
|
||||||
|
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde_json::{Value, json};
|
||||||
|
|
||||||
|
use crate::cmd::params::parse;
|
||||||
|
use crate::theme::{self, BUILTIN, Theme};
|
||||||
|
use crate::{Command, CommandSpec, EngineError, Event, Outcome, State};
|
||||||
|
|
||||||
|
/// The setting that selects the theme.
|
||||||
|
pub const SETTING: &str = "appearance.theme";
|
||||||
|
|
||||||
|
/// The theme the current settings and OS preference resolve to.
|
||||||
|
pub fn resolved(state: &State) -> Theme {
|
||||||
|
let setting = state.settings.get(SETTING);
|
||||||
|
let id = setting
|
||||||
|
.as_ref()
|
||||||
|
.and_then(Value::as_str)
|
||||||
|
.unwrap_or(theme::SYSTEM);
|
||||||
|
theme::resolve(id, state.system_dark)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The `themeChanged` event for a theme.
|
||||||
|
pub fn changed_event(theme: &Theme) -> Event {
|
||||||
|
Event::ThemeChanged {
|
||||||
|
id: theme.id.to_string(),
|
||||||
|
dark: theme.dark,
|
||||||
|
tokens: theme::token_map(theme),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Emits `themeChanged` if the resolved theme is no longer `before`.
|
||||||
|
pub fn emit_if_changed(state: &mut State, before: Theme) {
|
||||||
|
let now = resolved(state);
|
||||||
|
if now != before {
|
||||||
|
state.emit(changed_event(&now));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `theme.list`: the built-in themes.
|
||||||
|
pub struct List;
|
||||||
|
|
||||||
|
impl Command for List {
|
||||||
|
fn spec(&self) -> &CommandSpec {
|
||||||
|
&CommandSpec {
|
||||||
|
id: "theme.list",
|
||||||
|
label: "List Themes",
|
||||||
|
menu_path: None,
|
||||||
|
default_shortcut: None,
|
||||||
|
params: "none; returns [{ id, label, dark }], label is a message-catalog key",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run(&self, _state: &mut State, _params: Value) -> Result<Outcome, EngineError> {
|
||||||
|
let list: Vec<_> = BUILTIN
|
||||||
|
.iter()
|
||||||
|
.map(|t| json!({ "id": t.id, "label": t.label_key, "dark": t.dark }))
|
||||||
|
.collect();
|
||||||
|
Ok(Outcome::value(Value::Array(list)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Params of `theme.systemPreference`.
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
#[serde(deny_unknown_fields)]
|
||||||
|
struct PreferenceParams {
|
||||||
|
/// Whether the OS prefers a dark theme.
|
||||||
|
dark: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `theme.systemPreference`: the frontend reports the OS colour preference;
|
||||||
|
/// in "system" mode a change of it switches the theme.
|
||||||
|
pub struct SystemPreference;
|
||||||
|
|
||||||
|
impl Command for SystemPreference {
|
||||||
|
fn spec(&self) -> &CommandSpec {
|
||||||
|
&CommandSpec {
|
||||||
|
id: "theme.systemPreference",
|
||||||
|
label: "Report System Theme",
|
||||||
|
menu_path: None,
|
||||||
|
default_shortcut: None,
|
||||||
|
params: "{ dark: bool }; returns the resolved theme { id, dark, tokens }; emits themeChanged when it changes",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run(&self, state: &mut State, params: Value) -> Result<Outcome, EngineError> {
|
||||||
|
let p: PreferenceParams = parse(self.spec().id, params)?;
|
||||||
|
let before = resolved(state);
|
||||||
|
state.system_dark = Some(p.dark);
|
||||||
|
emit_if_changed(state, before);
|
||||||
|
let now = resolved(state);
|
||||||
|
let value = serde_json::to_value(changed_event(&now))
|
||||||
|
.map_err(|e| EngineError::Internal(e.to_string()))?;
|
||||||
|
let Value::Object(mut fields) = value else {
|
||||||
|
return Err(EngineError::Internal("theme is not an object".into()));
|
||||||
|
};
|
||||||
|
fields.remove("kind");
|
||||||
|
Ok(Outcome::value(Value::Object(fields)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -288,6 +288,8 @@ mod tests {
|
||||||
"settings.reset",
|
"settings.reset",
|
||||||
"settings.set",
|
"settings.set",
|
||||||
"test.disabled",
|
"test.disabled",
|
||||||
|
"theme.list",
|
||||||
|
"theme.systemPreference",
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
let by_id = |id: &str| list.iter().find(|c| c.id == id).unwrap();
|
let by_id = |id: &str| list.iter().find(|c| c.id == id).unwrap();
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@
|
||||||
//! Serialised as `{"kind": "<camelCase variant>", ...fields in camelCase}`.
|
//! Serialised as `{"kind": "<camelCase variant>", ...fields in camelCase}`.
|
||||||
//! Paths are project-relative with `/` separators, the root is `""`.
|
//! Paths are project-relative with `/` separators, the root is `""`.
|
||||||
|
|
||||||
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use serde_json::{Map, Value};
|
use serde_json::{Map, Value};
|
||||||
|
|
||||||
|
|
@ -83,6 +85,17 @@ pub enum Event {
|
||||||
/// The changed keys.
|
/// The changed keys.
|
||||||
keys: Vec<String>,
|
keys: Vec<String>,
|
||||||
},
|
},
|
||||||
|
/// The resolved theme changed, through `appearance.theme` or, in
|
||||||
|
/// "system" mode, the OS preference. The frontend writes the tokens onto
|
||||||
|
/// `:root` and sets `color-scheme`.
|
||||||
|
ThemeChanged {
|
||||||
|
/// Theme id, e.g. `lutra-light`.
|
||||||
|
id: String,
|
||||||
|
/// Whether the theme is dark.
|
||||||
|
dark: bool,
|
||||||
|
/// Every token as `--lt-<name>` → CSS value.
|
||||||
|
tokens: BTreeMap<String, String>,
|
||||||
|
},
|
||||||
/// A message for the user, shown as a toast.
|
/// A message for the user, shown as a toast.
|
||||||
Notification {
|
Notification {
|
||||||
/// Unique id of this notification, for dismissing it.
|
/// Unique id of this notification, for dismissing it.
|
||||||
|
|
@ -166,4 +179,17 @@ mod tests {
|
||||||
json!({"kind": "settingsChanged", "keys": ["editor.fontSize"]})
|
json!({"kind": "settingsChanged", "keys": ["editor.fontSize"]})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn theme_changed_shape() {
|
||||||
|
let e = Event::ThemeChanged {
|
||||||
|
id: "lutra-light".into(),
|
||||||
|
dark: false,
|
||||||
|
tokens: [("--lt-bg".to_string(), "#f4f1ec".to_string())].into(),
|
||||||
|
};
|
||||||
|
assert_eq!(
|
||||||
|
serde_json::to_value(e).unwrap(),
|
||||||
|
json!({"kind": "themeChanged", "id": "lutra-light", "dark": false, "tokens": {"--lt-bg": "#f4f1ec"}})
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,9 @@ pub struct State {
|
||||||
pub buffers: Buffers,
|
pub buffers: Buffers,
|
||||||
/// Settings, saved to the config directory when the engine has one.
|
/// Settings, saved to the config directory when the engine has one.
|
||||||
pub settings: Settings,
|
pub settings: Settings,
|
||||||
|
/// Whether the OS prefers a dark theme, as the frontend reported it with
|
||||||
|
/// `theme.systemPreference`; `None` until then.
|
||||||
|
pub system_dark: Option<bool>,
|
||||||
/// Where the engine stores its files; `None` for an engine without
|
/// Where the engine stores its files; `None` for an engine without
|
||||||
/// persistence ([`crate::Engine::new`]).
|
/// persistence ([`crate::Engine::new`]).
|
||||||
pub config: Option<EngineConfig>,
|
pub config: Option<EngineConfig>,
|
||||||
|
|
|
||||||
|
|
@ -2,21 +2,33 @@
|
||||||
//!
|
//!
|
||||||
//! Themes are defined here in Rust and rendered as CSS custom properties
|
//! Themes are defined here in Rust and rendered as CSS custom properties
|
||||||
//! (`--lt-<token>`). Frontend components use only `var(--lt-…)`. The palettes
|
//! (`--lt-<token>`). Frontend components use only `var(--lt-…)`. The palettes
|
||||||
//! are Lutra's own: warm otter browns with a copper accent.
|
//! are Lutra's own: warm otter browns with a copper accent. Text and
|
||||||
|
//! background pairs meet WCAG AA in both themes; `ui/tests/theme` checks it
|
||||||
|
//! against the snapshot `ui/tests/theme/themes.json`, which the test
|
||||||
|
//! `ui_snapshot_is_current` keeps in step with this file.
|
||||||
|
//!
|
||||||
|
//! The setting `appearance.theme` holds a theme id or [`SYSTEM`]. "System"
|
||||||
|
//! follows the OS: the frontend reports the OS preference and
|
||||||
|
//! [`resolve`] picks the theme.
|
||||||
|
|
||||||
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
/// A named set of token values.
|
/// A named set of token values.
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub struct Theme {
|
pub struct Theme {
|
||||||
/// Stable id used in settings, e.g. `lutra-dark`.
|
/// Stable id used in settings, e.g. `lutra-dark`.
|
||||||
pub id: &'static str,
|
pub id: &'static str,
|
||||||
/// Display name.
|
/// Message-catalog key of the display name.
|
||||||
pub name: &'static str,
|
pub label_key: &'static str,
|
||||||
/// Whether the theme is dark, for the window chrome and `color-scheme`.
|
/// Whether the theme is dark, for the window chrome and `color-scheme`.
|
||||||
pub dark: bool,
|
pub dark: bool,
|
||||||
/// Token names (without the `--lt-` prefix) and CSS values.
|
/// Token names (without the `--lt-` prefix) and CSS values.
|
||||||
pub tokens: &'static [(&'static str, &'static str)],
|
pub tokens: &'static [(&'static str, &'static str)],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The `appearance.theme` value that follows the OS preference.
|
||||||
|
pub const SYSTEM: &str = "system";
|
||||||
|
|
||||||
/// Tokens shared by every theme (fonts and sizes).
|
/// Tokens shared by every theme (fonts and sizes).
|
||||||
const COMMON: &[(&str, &str)] = &[
|
const COMMON: &[(&str, &str)] = &[
|
||||||
(
|
(
|
||||||
|
|
@ -29,12 +41,13 @@ const COMMON: &[(&str, &str)] = &[
|
||||||
),
|
),
|
||||||
("font-size-ui", "13px"),
|
("font-size-ui", "13px"),
|
||||||
("font-size-small", "12px"),
|
("font-size-small", "12px"),
|
||||||
|
("font-size-editor", "14px"),
|
||||||
];
|
];
|
||||||
|
|
||||||
/// The default dark theme.
|
/// The default dark theme.
|
||||||
pub const DARK: Theme = Theme {
|
pub const DARK: Theme = Theme {
|
||||||
id: "lutra-dark",
|
id: "lutra-dark",
|
||||||
name: "Lutra Dark",
|
label_key: "theme.lutraDark",
|
||||||
dark: true,
|
dark: true,
|
||||||
tokens: &[
|
tokens: &[
|
||||||
("bg", "#1f1d1b"),
|
("bg", "#1f1d1b"),
|
||||||
|
|
@ -46,24 +59,42 @@ pub const DARK: Theme = Theme {
|
||||||
("error", "#ef7b6c"),
|
("error", "#ef7b6c"),
|
||||||
("statusbar-bg", "#24211f"),
|
("statusbar-bg", "#24211f"),
|
||||||
("statusbar-fg", "#b8afa6"),
|
("statusbar-fg", "#b8afa6"),
|
||||||
|
("editor-selection-bg", "#513f2c"),
|
||||||
|
("editor-active-line-bg", "#232221"),
|
||||||
|
("editor-cursor", "#d39a5c"),
|
||||||
|
("editor-gutter-bg", "#191817"),
|
||||||
|
("editor-gutter-fg", "#9a928a"),
|
||||||
|
("editor-match-bg", "#3a2f23"),
|
||||||
|
("tab-active-bg", "#191817"),
|
||||||
|
("tab-modified", "#d39a5c"),
|
||||||
|
("notice-bg", "#3a3025"),
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The light theme.
|
/// The light theme.
|
||||||
pub const LIGHT: Theme = Theme {
|
pub const LIGHT: Theme = Theme {
|
||||||
id: "lutra-light",
|
id: "lutra-light",
|
||||||
name: "Lutra Light",
|
label_key: "theme.lutraLight",
|
||||||
dark: false,
|
dark: false,
|
||||||
tokens: &[
|
tokens: &[
|
||||||
("bg", "#f4f1ec"),
|
("bg", "#f4f1ec"),
|
||||||
("editor-bg", "#fbfaf8"),
|
("editor-bg", "#fbfaf8"),
|
||||||
("fg", "#2a2622"),
|
("fg", "#2a2622"),
|
||||||
("fg-muted", "#7a7168"),
|
("fg-muted", "#6b625a"),
|
||||||
("border", "#ddd6cd"),
|
("border", "#ddd6cd"),
|
||||||
("accent", "#a8662a"),
|
("accent", "#965a22"),
|
||||||
("error", "#c2412f"),
|
("error", "#b23a29"),
|
||||||
("statusbar-bg", "#ece7e0"),
|
("statusbar-bg", "#ece7e0"),
|
||||||
("statusbar-fg", "#5a5149"),
|
("statusbar-fg", "#5a5149"),
|
||||||
|
("editor-selection-bg", "#e5d7c9"),
|
||||||
|
("editor-active-line-bg", "#f1efed"),
|
||||||
|
("editor-cursor", "#965a22"),
|
||||||
|
("editor-gutter-bg", "#fbfaf8"),
|
||||||
|
("editor-gutter-fg", "#6b625a"),
|
||||||
|
("editor-match-bg", "#ece2d8"),
|
||||||
|
("tab-active-bg", "#fbfaf8"),
|
||||||
|
("tab-modified", "#965a22"),
|
||||||
|
("notice-bg", "#e9dfd4"),
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -75,6 +106,34 @@ pub fn by_id(id: &str) -> Option<Theme> {
|
||||||
BUILTIN.iter().copied().find(|t| t.id == id)
|
BUILTIN.iter().copied().find(|t| t.id == id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The theme for an `appearance.theme` value.
|
||||||
|
///
|
||||||
|
/// # Parameters
|
||||||
|
/// - `setting`: a theme id or [`SYSTEM`].
|
||||||
|
/// - `system_dark`: the OS preference; `None` while the frontend has not
|
||||||
|
/// reported it, which counts as dark.
|
||||||
|
///
|
||||||
|
/// Returns [`DARK`] for an unknown id.
|
||||||
|
pub fn resolve(setting: &str, system_dark: Option<bool>) -> Theme {
|
||||||
|
if setting == SYSTEM {
|
||||||
|
return if system_dark.unwrap_or(true) {
|
||||||
|
DARK
|
||||||
|
} else {
|
||||||
|
LIGHT
|
||||||
|
};
|
||||||
|
}
|
||||||
|
by_id(setting).unwrap_or(DARK)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Every token of a theme, shared ones included, as `--lt-<name>` → value.
|
||||||
|
pub fn token_map(theme: &Theme) -> BTreeMap<String, String> {
|
||||||
|
COMMON
|
||||||
|
.iter()
|
||||||
|
.chain(theme.tokens)
|
||||||
|
.map(|(name, value)| (format!("--lt-{name}"), (*value).to_string()))
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
/// Renders a theme as a `:root { … }` rule of CSS custom properties.
|
/// Renders a theme as a `:root { … }` rule of CSS custom properties.
|
||||||
pub fn css_variables(theme: &Theme) -> String {
|
pub fn css_variables(theme: &Theme) -> String {
|
||||||
let mut css = String::from(":root {\n");
|
let mut css = String::from(":root {\n");
|
||||||
|
|
@ -89,11 +148,26 @@ pub fn css_variables(theme: &Theme) -> String {
|
||||||
css
|
css
|
||||||
}
|
}
|
||||||
|
|
||||||
/// JavaScript that installs the theme's CSS as a `<style id="lt-theme">`
|
/// The CSS for an `appearance.theme` value: the theme's variables, or for
|
||||||
/// element as soon as the document has a `<head>`, for use as a webview
|
/// [`SYSTEM`] the dark theme with the light one inside a
|
||||||
/// initialization script.
|
/// `prefers-color-scheme: light` media query, so the first frame follows the
|
||||||
pub fn init_script(theme: &Theme) -> String {
|
/// OS before the frontend has started.
|
||||||
let css = serde_json::Value::String(css_variables(theme)).to_string();
|
pub fn css_for_setting(setting: &str) -> String {
|
||||||
|
if setting == SYSTEM {
|
||||||
|
return format!(
|
||||||
|
"{}\n@media (prefers-color-scheme: light) {{\n{}\n}}",
|
||||||
|
css_variables(&DARK),
|
||||||
|
css_variables(&LIGHT)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
css_variables(&resolve(setting, None))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// JavaScript that installs the CSS for an `appearance.theme` value as a
|
||||||
|
/// `<style id="lt-theme">` element as soon as the document has a `<head>`,
|
||||||
|
/// for use as a webview initialization script.
|
||||||
|
pub fn init_script(setting: &str) -> String {
|
||||||
|
let css = serde_json::Value::String(css_for_setting(setting)).to_string();
|
||||||
format!(
|
format!(
|
||||||
"(function(){{var css={css};function apply(){{var s=document.getElementById('lt-theme');if(!s){{s=document.createElement('style');s.id='lt-theme';document.head.appendChild(s);}}s.textContent=css;}}if(document.head){{apply();}}else{{document.addEventListener('DOMContentLoaded',apply);}}}})();"
|
"(function(){{var css={css};function apply(){{var s=document.getElementById('lt-theme');if(!s){{s=document.createElement('style');s.id='lt-theme';document.head.appendChild(s);}}s.textContent=css;}}if(document.head){{apply();}}else{{document.addEventListener('DOMContentLoaded',apply);}}}})();"
|
||||||
)
|
)
|
||||||
|
|
@ -103,12 +177,65 @@ pub fn init_script(theme: &Theme) -> String {
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
/// The snapshot of every theme that the frontend's contrast test reads.
|
||||||
|
fn ui_snapshot() -> String {
|
||||||
|
let themes: Vec<_> = BUILTIN
|
||||||
|
.iter()
|
||||||
|
.map(|t| {
|
||||||
|
serde_json::json!({
|
||||||
|
"id": t.id,
|
||||||
|
"labelKey": t.label_key,
|
||||||
|
"dark": t.dark,
|
||||||
|
"tokens": token_map(t),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
let mut text = serde_json::to_string_pretty(&themes).unwrap();
|
||||||
|
text.push('\n');
|
||||||
|
text
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn themes_define_the_same_tokens() {
|
fn themes_define_the_same_tokens() {
|
||||||
let names = |t: &Theme| t.tokens.iter().map(|(n, _)| *n).collect::<Vec<_>>();
|
let names = |t: &Theme| t.tokens.iter().map(|(n, _)| *n).collect::<Vec<_>>();
|
||||||
assert_eq!(names(&DARK), names(&LIGHT));
|
assert_eq!(names(&DARK), names(&LIGHT));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn themes_define_the_editor_tokens() {
|
||||||
|
for theme in BUILTIN {
|
||||||
|
let tokens = token_map(theme);
|
||||||
|
for name in [
|
||||||
|
"editor-selection-bg",
|
||||||
|
"editor-active-line-bg",
|
||||||
|
"editor-cursor",
|
||||||
|
"editor-gutter-bg",
|
||||||
|
"editor-gutter-fg",
|
||||||
|
"editor-match-bg",
|
||||||
|
"font-size-editor",
|
||||||
|
"tab-active-bg",
|
||||||
|
"tab-modified",
|
||||||
|
"notice-bg",
|
||||||
|
] {
|
||||||
|
assert!(
|
||||||
|
tokens.contains_key(&format!("--lt-{name}")),
|
||||||
|
"{} lacks {name}",
|
||||||
|
theme.id
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn resolves_settings() {
|
||||||
|
assert_eq!(resolve("lutra-light", Some(true)), LIGHT);
|
||||||
|
assert_eq!(resolve("lutra-dark", Some(false)), DARK);
|
||||||
|
assert_eq!(resolve(SYSTEM, Some(false)), LIGHT);
|
||||||
|
assert_eq!(resolve(SYSTEM, Some(true)), DARK);
|
||||||
|
assert_eq!(resolve(SYSTEM, None), DARK);
|
||||||
|
assert_eq!(resolve("nope", Some(false)), DARK);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn renders_css_variables() {
|
fn renders_css_variables() {
|
||||||
let css = css_variables(&DARK);
|
let css = css_variables(&DARK);
|
||||||
|
|
@ -118,12 +245,43 @@ mod tests {
|
||||||
assert!(css.contains("color-scheme: dark;"));
|
assert!(css.contains("color-scheme: dark;"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn css_follows_the_setting() {
|
||||||
|
assert_eq!(css_for_setting("lutra-light"), css_variables(&LIGHT));
|
||||||
|
assert_eq!(css_for_setting("lutra-dark"), css_variables(&DARK));
|
||||||
|
let system = css_for_setting(SYSTEM);
|
||||||
|
assert!(system.starts_with(&css_variables(&DARK)));
|
||||||
|
assert!(system.contains("@media (prefers-color-scheme: light) {\n:root {"));
|
||||||
|
assert!(system.contains("color-scheme: light;"));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn init_script_embeds_escaped_css() {
|
fn init_script_embeds_escaped_css() {
|
||||||
let js = init_script(&LIGHT);
|
let js = init_script("lutra-light");
|
||||||
assert!(js.contains("\\\"Segoe UI\\\""));
|
assert!(js.contains("\\\"Segoe UI\\\""));
|
||||||
assert!(js.contains("lt-theme"));
|
assert!(js.contains("lt-theme"));
|
||||||
|
assert!(js.contains("--lt-bg: #f4f1ec;"));
|
||||||
assert_eq!(by_id("lutra-light"), Some(LIGHT));
|
assert_eq!(by_id("lutra-light"), Some(LIGHT));
|
||||||
assert_eq!(by_id("nope"), None);
|
assert_eq!(by_id("nope"), None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set `LUTRA_UPDATE_SNAPSHOTS=1` to rewrite the snapshot after changing
|
||||||
|
/// a token.
|
||||||
|
#[test]
|
||||||
|
fn ui_snapshot_is_current() {
|
||||||
|
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||||
|
.join("../../ui/tests/theme/themes.json");
|
||||||
|
let expected = ui_snapshot();
|
||||||
|
if std::env::var_os("LUTRA_UPDATE_SNAPSHOTS").is_some() {
|
||||||
|
std::fs::write(&path, &expected).unwrap();
|
||||||
|
}
|
||||||
|
let actual = std::fs::read_to_string(&path)
|
||||||
|
.unwrap_or_default()
|
||||||
|
.replace("\r\n", "\n");
|
||||||
|
assert!(
|
||||||
|
actual == expected,
|
||||||
|
"{} is out of date; run with LUTRA_UPDATE_SNAPSHOTS=1",
|
||||||
|
path.display()
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,10 +72,10 @@ fn get_set_reset_and_events() {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(out.value, json!({"value": "lutra-light"}));
|
assert_eq!(out.value, json!({"value": "lutra-light"}));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
out.events,
|
out.events.first(),
|
||||||
vec![Event::SettingsChanged {
|
Some(&Event::SettingsChanged {
|
||||||
keys: vec!["appearance.theme".into()]
|
keys: vec!["appearance.theme".into()]
|
||||||
}]
|
})
|
||||||
);
|
);
|
||||||
let same = e
|
let same = e
|
||||||
.execute(
|
.execute(
|
||||||
|
|
@ -94,7 +94,7 @@ fn get_set_reset_and_events() {
|
||||||
.execute("settings.reset", json!({"key": "appearance.theme"}))
|
.execute("settings.reset", json!({"key": "appearance.theme"}))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(reset.value, json!({"value": "system"}));
|
assert_eq!(reset.value, json!({"value": "system"}));
|
||||||
assert_eq!(reset.events.len(), 1);
|
assert_eq!(reset.events.len(), 2);
|
||||||
let again = e
|
let again = e
|
||||||
.execute("settings.reset", json!({"key": "appearance.theme"}))
|
.execute("settings.reset", json!({"key": "appearance.theme"}))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
|
||||||
154
crates/engine/tests/theme.rs
Normal file
154
crates/engine/tests/theme.rs
Normal file
|
|
@ -0,0 +1,154 @@
|
||||||
|
//! Theme commands and `themeChanged`: switching through `settings.set`, the
|
||||||
|
//! "system" mode following the reported OS preference, and the stored theme
|
||||||
|
//! surviving a restart.
|
||||||
|
|
||||||
|
#![allow(
|
||||||
|
clippy::unwrap_used,
|
||||||
|
clippy::expect_used,
|
||||||
|
clippy::panic,
|
||||||
|
clippy::indexing_slicing
|
||||||
|
)]
|
||||||
|
|
||||||
|
use lutra_engine::{Engine, EngineConfig, Event, theme};
|
||||||
|
use serde_json::{Value, json};
|
||||||
|
use tempfile::TempDir;
|
||||||
|
|
||||||
|
fn themes(events: &[Event]) -> Vec<(String, bool)> {
|
||||||
|
events
|
||||||
|
.iter()
|
||||||
|
.filter_map(|e| match e {
|
||||||
|
Event::ThemeChanged { id, dark, .. } => Some((id.clone(), *dark)),
|
||||||
|
_ => None,
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_theme(engine: &mut Engine, value: &str) -> Vec<(String, bool)> {
|
||||||
|
let outcome = engine
|
||||||
|
.execute(
|
||||||
|
"settings.set",
|
||||||
|
json!({"key": "appearance.theme", "value": value}),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
themes(&outcome.events)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn report(engine: &mut Engine, dark: bool) -> (Value, Vec<(String, bool)>) {
|
||||||
|
let outcome = engine
|
||||||
|
.execute("theme.systemPreference", json!({"dark": dark}))
|
||||||
|
.unwrap();
|
||||||
|
let events = themes(&outcome.events);
|
||||||
|
(outcome.value, events)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn list_names_the_builtin_themes_by_catalog_key() {
|
||||||
|
let mut e = Engine::new().unwrap();
|
||||||
|
let list = e.execute("theme.list", Value::Null).unwrap().value;
|
||||||
|
assert_eq!(
|
||||||
|
list,
|
||||||
|
json!([
|
||||||
|
{"id": "lutra-dark", "label": "theme.lutraDark", "dark": true},
|
||||||
|
{"id": "lutra-light", "label": "theme.lutraLight", "dark": false},
|
||||||
|
])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn switching_the_setting_emits_the_new_tokens() {
|
||||||
|
let mut e = Engine::new().unwrap();
|
||||||
|
let outcome = e
|
||||||
|
.execute(
|
||||||
|
"settings.set",
|
||||||
|
json!({"key": "appearance.theme", "value": "lutra-light"}),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
let Some(Event::ThemeChanged { id, dark, tokens }) = outcome
|
||||||
|
.events
|
||||||
|
.iter()
|
||||||
|
.find(|e| matches!(e, Event::ThemeChanged { .. }))
|
||||||
|
else {
|
||||||
|
panic!("no themeChanged in {:?}", outcome.events);
|
||||||
|
};
|
||||||
|
assert_eq!(id, "lutra-light");
|
||||||
|
assert!(!dark);
|
||||||
|
assert_eq!(tokens, &theme::token_map(&theme::LIGHT));
|
||||||
|
assert_eq!(tokens["--lt-bg"], "#f4f1ec");
|
||||||
|
assert_eq!(tokens["--lt-font-size-editor"], "14px");
|
||||||
|
assert!(matches!(
|
||||||
|
outcome.events.first(),
|
||||||
|
Some(Event::SettingsChanged { .. })
|
||||||
|
));
|
||||||
|
|
||||||
|
assert_eq!(set_theme(&mut e, "lutra-light"), []);
|
||||||
|
assert_eq!(
|
||||||
|
set_theme(&mut e, "lutra-dark"),
|
||||||
|
[("lutra-dark".into(), true)]
|
||||||
|
);
|
||||||
|
let reset = e
|
||||||
|
.execute("settings.reset", json!({"key": "appearance.theme"}))
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(themes(&reset.events), []);
|
||||||
|
let other = e
|
||||||
|
.execute(
|
||||||
|
"settings.set",
|
||||||
|
json!({"key": "editor.fontSize", "value": 18}),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(themes(&other.events), []);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn system_mode_follows_the_reported_preference() {
|
||||||
|
let mut e = Engine::new().unwrap();
|
||||||
|
let (value, events) = report(&mut e, true);
|
||||||
|
assert_eq!(events, []);
|
||||||
|
assert_eq!(value["id"], "lutra-dark");
|
||||||
|
assert_eq!(value["dark"], true);
|
||||||
|
assert_eq!(value["tokens"]["--lt-bg"], "#1f1d1b");
|
||||||
|
assert!(value.get("kind").is_none());
|
||||||
|
|
||||||
|
let (value, events) = report(&mut e, false);
|
||||||
|
assert_eq!(events, [("lutra-light".into(), false)]);
|
||||||
|
assert_eq!(value["id"], "lutra-light");
|
||||||
|
assert_eq!(report(&mut e, false).1, []);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
set_theme(&mut e, "lutra-dark"),
|
||||||
|
[("lutra-dark".into(), true)]
|
||||||
|
);
|
||||||
|
let (value, events) = report(&mut e, true);
|
||||||
|
assert_eq!(events, []);
|
||||||
|
assert_eq!(report(&mut e, false).1, []);
|
||||||
|
assert_eq!(value["id"], "lutra-dark");
|
||||||
|
|
||||||
|
assert_eq!(set_theme(&mut e, "system"), [("lutra-light".into(), false)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn rejects_bad_preference_params() {
|
||||||
|
let mut e = Engine::new().unwrap();
|
||||||
|
for params in [
|
||||||
|
json!({}),
|
||||||
|
json!({"dark": "yes"}),
|
||||||
|
json!({"dark": true, "x": 1}),
|
||||||
|
] {
|
||||||
|
let err = e.execute("theme.systemPreference", params).unwrap_err();
|
||||||
|
assert_eq!(err.code(), "invalid_params");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn the_stored_theme_survives_a_restart() {
|
||||||
|
let dir = TempDir::new().unwrap();
|
||||||
|
let config = EngineConfig {
|
||||||
|
config_dir: dir.path().join("config"),
|
||||||
|
data_dir: dir.path().join("data"),
|
||||||
|
};
|
||||||
|
let mut e = Engine::with_config(config.clone()).unwrap();
|
||||||
|
set_theme(&mut e, "lutra-light");
|
||||||
|
drop(e);
|
||||||
|
let mut e = Engine::with_config(config).unwrap();
|
||||||
|
let (value, _) = report(&mut e, true);
|
||||||
|
assert_eq!(value["id"], "lutra-light");
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# Architecture
|
# Architecture
|
||||||
|
|
||||||
> **Status:** M0 decisions recorded, M1 workspace, desktop bridge, tabs and editor, message catalog, engine construction and settings documented · **Last updated:** 2026-10-16
|
> **Status:** M0 decisions recorded, M1 workspace, desktop bridge, tabs and editor, message catalog, engine construction, settings and themes documented · **Last updated:** 2026-10-16
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
|
|
@ -67,7 +67,7 @@ As built in M0:
|
||||||
|
|
||||||
The frontend calls `run(id, params)` over Tauri IPC (`engine_execute`, `engine_list_commands`) and subscribes to state events. Buffer contents live in the engine; CodeMirror sends edits as transactions and receives authoritative changes back.
|
The frontend calls `run(id, params)` over Tauri IPC (`engine_execute`, `engine_list_commands`) and subscribes to state events. Buffer contents live in the engine; CodeMirror sends edits as transactions and receives authoritative changes back.
|
||||||
|
|
||||||
Theme tokens are defined in Rust (`lutra_engine::theme`) and rendered as CSS custom properties (`--lt-*`). The desktop injects them with the window's initialization script, so the first frame is already themed and the frontend needs no round trip. Components use only `var(--lt-…)`.
|
Theme tokens are defined in Rust (`lutra_engine::theme`) and rendered as CSS custom properties (`--lt-*`). The desktop injects the stored theme with the window's initialization script, so the first frame is already themed and the frontend needs no round trip. Components use only `var(--lt-…)`; switching is described under Themes.
|
||||||
|
|
||||||
### Workspace (M1.3)
|
### Workspace (M1.3)
|
||||||
|
|
||||||
|
|
@ -99,7 +99,7 @@ Watched directories: the VFS watcher is non-recursive, so `project.children` wat
|
||||||
- Line breaks: the engine keeps text as on disk and counts `\r\n` as two UTF-16 units; CodeMirror counts every break as one position. `EngineText` remembers which breaks are `\r\n` and converts positions when building edits; inserted breaks are sent with the buffer's line ending, so a CRLF file stays CRLF in memory. Text without `\r\n` (the common case) needs no table.
|
- Line breaks: the engine keeps text as on disk and counts `\r\n` as two UTF-16 units; CodeMirror counts every break as one position. `EngineText` remembers which breaks are `\r\n` and converts positions when building edits; inserted breaks are sent with the buffer's line ending, so a CRLF file stays CRLF in memory. Text without `\r\n` (the common case) needs no table.
|
||||||
- Save, save all and close run from the engine's default shortcuts (`file.save` `Mod+S`, `file.saveAll` `Mod+Alt+S`, `buffer.close` `Mod+W`), loaded with `listCommands` and matched by key code, with the active buffer as context. Saving and closing wait until the sync has no pending edits.
|
- Save, save all and close run from the engine's default shortcuts (`file.save` `Mod+S`, `file.saveAll` `Mod+Alt+S`, `buffer.close` `Mod+W`), loaded with `listCommands` and matched by key code, with the active buffer as context. Saving and closing wait until the sync has no pending edits.
|
||||||
- Closing a dirty tab asks Save / Don't Save / Cancel; `buffer.close` without `force` failing with `unsaved_changes` also leads to the question. Lutra saves only on request for now (no autosave).
|
- Closing a dirty tab asks Save / Don't Save / Cancel; `buffer.close` without `force` failing with `unsaved_changes` also leads to the question. Lutra saves only on request for now (no autosave).
|
||||||
- Theme: the editor reads colours only from `--lt-*` tokens. Tokens the theme does not have yet are read as `var(--lt-new-token, <fallback from existing tokens>)` so they take effect once added in Rust.
|
- Theme: the editor reads colours only from `--lt-*` tokens, including the editor tokens from M1.10 (selection, active line, cursor, gutter, match, editor font size); no fallbacks remain.
|
||||||
|
|
||||||
### Message catalog (M1.11)
|
### Message catalog (M1.11)
|
||||||
|
|
||||||
|
|
@ -121,6 +121,17 @@ Watched directories: the VFS watcher is non-recursive, so `project.children` wat
|
||||||
- Commands: `settings.list` → `[{key, type: enum|int, default, enumValues?, min?, max?, labelKey, descriptionKey, section}]` (catalog keys `settings.<key>.label` / `.description`; `section` is an id shown with `settings.section.<id>`), `settings.get {keys?}` → `{values}`, `settings.set {key, value}` → `{value}`, `settings.reset {key}` → `{value}`. Unknown keys and bad values fail with `invalid_params`; a write failure fails with `failed` and changes nothing.
|
- Commands: `settings.list` → `[{key, type: enum|int, default, enumValues?, min?, max?, labelKey, descriptionKey, section}]` (catalog keys `settings.<key>.label` / `.description`; `section` is an id shown with `settings.section.<id>`), `settings.get {keys?}` → `{values}`, `settings.set {key, value}` → `{value}`, `settings.reset {key}` → `{value}`. Unknown keys and bad values fail with `invalid_params`; a write failure fails with `failed` and changes nothing.
|
||||||
- Events: `settingsChanged {keys}` when an effective value changes; `notification {id, level: info|warning|error, messageKey?, message?, params?}` (ids `n1`, `n2`…).
|
- Events: `settingsChanged {keys}` when an effective value changes; `notification {id, level: info|warning|error, messageKey?, message?, params?}` (ids `n1`, `n2`…).
|
||||||
|
|
||||||
|
### Themes (M1.10)
|
||||||
|
|
||||||
|
- `lutra_engine::theme` defines `DARK` (`lutra-dark`) and `LIGHT` (`lutra-light`) with the same token names, plus shared font tokens. Besides the base colours (`bg`, `editor-bg`, `fg`, `fg-muted`, `border`, `accent`, `error`, `statusbar-*`) both define `editor-selection-bg`, `editor-active-line-bg`, `editor-cursor`, `editor-gutter-bg`, `editor-gutter-fg`, `editor-match-bg`, `tab-active-bg`, `tab-modified`, `notice-bg`; `font-size-editor` is shared (14px). Values are opaque `#rrggbb` derived from the palette (selection, match and notice are the accent mixed into the background); the designer may change values, never names.
|
||||||
|
- `appearance.theme` selects the theme: a theme id or `system`. `theme::resolve(setting, system_dark)` picks the theme; `system` follows the OS preference the frontend reports, and counts as dark until it has.
|
||||||
|
- Commands: `theme.list` → `[{id, label, dark}]` (`label` is a catalog key, `theme.lutraDark`/`theme.lutraLight`); `theme.systemPreference {dark}` stores the OS preference and returns the resolved theme `{id, dark, tokens}`. Switching goes through `settings.set appearance.theme` (or `settings.reset`).
|
||||||
|
- Event: `themeChanged {id, dark, tokens: {"--lt-…": value}}` (every token, shared ones included) whenever the resolved theme changes: after `settingsChanged` for `appearance.theme`, or after `theme.systemPreference` in system mode. A change that resolves to the same theme (`lutra-dark` → `system` on a dark OS) emits nothing.
|
||||||
|
- First frame: the desktop reads `appearance.theme` before creating the window and passes `theme::init_script(setting)`, which installs `<style id="lt-theme">`. For `system` the CSS is the dark theme plus the light one inside `@media (prefers-color-scheme: light)`, so the first frame follows the OS without a round trip; the native window background is set from the resolved theme (`Window::theme()` for system).
|
||||||
|
- Live switch: `ui/src/theme.ts` (`startTheme`, called by `App.vue`) reports `matchMedia("(prefers-color-scheme: dark)")` now and on every change, applies the result and every `themeChanged`: tokens go onto `:root`'s inline style (which wins over the injected style element), `color-scheme` is set, and `data-theme` holds the id. No reload.
|
||||||
|
- Accessibility: `ui/tests/theme/contrast.test.ts` checks every text/background pair the components draw with against WCAG AA (4.5:1 text, 3:1 cursor and modified dot) in both themes. It reads `ui/tests/theme/themes.json`, which the Rust test `theme::tests::ui_snapshot_is_current` keeps equal to the Rust definition (`LUTRA_UPDATE_SNAPSHOTS=1` rewrites it). `ui/tests/theme/theme.test.ts` fails on a `var(--lt-x)` the themes lack and on a fallback for a token they define.
|
||||||
|
- Not themed yet: the native title bar follows the OS, not the Lutra theme; spacing and size tokens (`--lt-space-*`, `--lt-radius`, `--lt-row-height`…) are still CSS fallbacks in components; `editor.fontSize` does not drive `--lt-font-size-editor` yet.
|
||||||
|
|
||||||
## Decisions (M0)
|
## Decisions (M0)
|
||||||
|
|
||||||
| Question | Decision | Why |
|
| Question | Decision | Why |
|
||||||
|
|
@ -138,6 +149,7 @@ Watched directories: the VFS watcher is non-recursive, so `project.children` wat
|
||||||
|
|
||||||
| Date | Change | Summary |
|
| Date | Change | Summary |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
|
| 2026-10-16 | minor | M1.10: themes (light theme, editor tokens, theme.list, theme.systemPreference, themeChanged, init script from the setting, live switch, contrast test) |
|
||||||
| 2026-10-16 | minor | M1.9a: engine construction (EngineConfig, with_config) and settings (file, commands, settingsChanged, notification) |
|
| 2026-10-16 | minor | M1.9a: engine construction (EngineConfig, with_config) and settings (file, commands, settingsChanged, notification) |
|
||||||
| 2026-10-15 | minor | M1.11: message catalog (`t`, lint rule, catalog test, engine messages stay English) |
|
| 2026-10-15 | minor | M1.11: message catalog (`t`, lint rule, catalog test, engine messages stay English) |
|
||||||
| 2026-10-15 | minor | M1.6: tabs and editor (buffer sync, CRLF offsets, shortcuts from command specs) |
|
| 2026-10-15 | minor | M1.6: tabs and editor (buffer sync, CRLF offsets, shortcuts from command specs) |
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# Gaps
|
# Gaps
|
||||||
|
|
||||||
> **Status:** M0 closed G1; G2 under way (text buffer, engine buffers, tabs and editor in the app); G3 project tree works in the app, settings backend landed; G14 English UI catalog in place · **Last updated:** 2026-10-16
|
> **Status:** M0 closed G1; G2 under way (text buffer, engine buffers, tabs and editor in the app); G3 project tree works in the app, settings backend and theme switching landed; G14 English UI catalog in place · **Last updated:** 2026-10-16
|
||||||
|
|
||||||
Every known shortfall, ranked. This is the work list: unless the owner gives a task, take the highest open gap. Hours are agent wall-clock hours for one agent, all estimated.
|
Every known shortfall, ranked. This is the work list: unless the owner gives a task, take the highest open gap. Hours are agent wall-clock hours for one agent, all estimated.
|
||||||
|
|
||||||
|
|
@ -8,7 +8,7 @@ Every known shortfall, ranked. This is the work list: unless the owner gives a t
|
||||||
|---|---|---|---|
|
|---|---|---|---|
|
||||||
| G1 | ~~Foundation: workspace, quality gate, command registry, guard, control channel~~ closed 2026-10-14 | M0 | done (~2 h measured) |
|
| G1 | ~~Foundation: workspace, quality gate, command registry, guard, control channel~~ closed 2026-10-14 | M0 | done (~2 h measured) |
|
||||||
| G2 | Editor core: ~~engine buffers, save~~ (M1.3), ~~editor UI with tabs, undo, multi-caret~~ (M1.6, CodeMirror basics), recovery journal, tab management (preview, pin, split, close others, reopen), conflict UI for files changed on disk, autosave option | M1 | ~18 h |
|
| G2 | Editor core: ~~engine buffers, save~~ (M1.3), ~~editor UI with tabs, undo, multi-caret~~ (M1.6, CodeMirror basics), recovery journal, tab management (preview, pin, split, close others, reopen), conflict UI for files changed on disk, autosave option | M1 | ~18 h |
|
||||||
| G3 | Project model: ~~VFS~~ (M1.2: listing, ignore rules, native file watching with polling fallback, safe file IO), ~~project tree wiring~~ (M1.5 UI, M1.3 engine, M1.4 bridge: folder picker, live tree), tree toolbar and options, showing truncated listings, error notifications for the folder picker, ~~tabs~~ (M1.6); command palette, settings (backend: M1.9a; dialog: M1.9b), theme switching | M1 | ~24 h |
|
| G3 | Project model: ~~VFS~~ (M1.2: listing, ignore rules, native file watching with polling fallback, safe file IO), ~~project tree wiring~~ (M1.5 UI, M1.3 engine, M1.4 bridge: folder picker, live tree), tree toolbar and options, showing truncated listings, error notifications for the folder picker, ~~tabs~~ (M1.6); command palette, settings (backend: M1.9a; dialog: M1.9b), ~~theme switching~~ (M1.10: light/dark, live, system mode; picker comes with the dialog) | M1 | ~24 h |
|
||||||
| G4 | Syntax and structure: tree-sitter PHP, Lezer highlighting, file structure | M2 | ~15 h |
|
| G4 | Syntax and structure: tree-sitter PHP, Lezer highlighting, file structure | M2 | ~15 h |
|
||||||
| G5 | Search and navigation: find in files, go to file/class/symbol, first index | M2 | ~35 h |
|
| G5 | Search and navigation: find in files, go to file/class/symbol, first index | M2 | ~35 h |
|
||||||
| G6 | Language server: completion, diagnostics, definition, hover, rename via Phpactor | M3 | ~45 h |
|
| G6 | Language server: completion, diagnostics, definition, hover, rename via Phpactor | M3 | ~45 h |
|
||||||
|
|
@ -39,6 +39,7 @@ Known smaller items from M0:
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| 2026-10-15 | minor | G14 note: English message catalog (M1.11) |
|
| 2026-10-15 | minor | G14 note: English message catalog (M1.11) |
|
||||||
| 2026-10-15 | minor | G2 shrunk: tabs and editor (M1.6) |
|
| 2026-10-15 | minor | G2 shrunk: tabs and editor (M1.6) |
|
||||||
|
| 2026-10-16 | minor | G3: theme switching (M1.10) |
|
||||||
| 2026-10-16 | minor | G3: settings backend (M1.9a) |
|
| 2026-10-16 | minor | G3: settings backend (M1.9a) |
|
||||||
| 2026-10-15 | minor | G3 shrunk: project tree wired to the engine (M1.4) |
|
| 2026-10-15 | minor | G3 shrunk: project tree wired to the engine (M1.4) |
|
||||||
| 2026-10-14 | minor | G2 shrunk, G3 note: engine workspace (M1.3) |
|
| 2026-10-14 | minor | G2 shrunk, G3 note: engine workspace (M1.3) |
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
# Milestones
|
# Milestones
|
||||||
|
|
||||||
> **Status:** M0 done, M1 in progress · **Last updated:** 2026-10-15
|
> **Status:** M0 done, M1 in progress · **Last updated:** 2026-10-16
|
||||||
|
|
||||||
Hours are agent wall-clock hours for one agent; M0 and M1 so far are measured, the rest estimated. Since cycle C1 (factor 0.07) M1–M3 are scaled ×0.1; M4–M6 keep their first raw estimates (multiply by ~0.1 for the calibrated value).
|
Hours are agent wall-clock hours for one agent; M0 and M1 so far are measured, the rest estimated. Since cycle C1 (factor 0.07) M1–M3 are scaled ×0.1; M4–M6 keep their first raw estimates (multiply by ~0.1 for the calibrated value).
|
||||||
|
|
||||||
| Milestone | Goal | State | Hours |
|
| Milestone | Goal | State | Hours |
|
||||||
|---|---|---|---:|
|
|---|---|---|---:|
|
||||||
| M0 | Foundation: workspace, lints, quality gate, command registry, control channel, empty window | done 2026-10-14 (CI workflow written, not yet run: hosted on Forgejo, runners unknown) | ~2 (measured) |
|
| M0 | Foundation: workspace, lints, quality gate, command registry, control channel, empty window | done 2026-10-14 (CI workflow written, not yet run: hosted on Forgejo, runners unknown) | ~2 (measured) |
|
||||||
| M1 | Editor and project: open folder, tree, tabs, editor, save, recovery, palette, settings, themes | in progress (M1.1 text, M1.2 VFS, M1.5 tree UI, M1.3 engine workspace, M1.4 desktop bridge, M1.6 tabs and editor, M1.11 message catalog) | ~6 (2.5 measured for M1.1–M1.6) |
|
| M1 | Editor and project: open folder, tree, tabs, editor, save, recovery, palette, settings, themes | in progress (M1.1 text, M1.2 VFS, M1.5 tree UI, M1.3 engine workspace, M1.4 desktop bridge, M1.6 tabs and editor, M1.11 message catalog, M1.9a settings backend, M1.10 themes) | ~6 (2.5 measured for M1.1–M1.6) |
|
||||||
| M2 | Syntax and search: highlighting, structure, find in files, go to file/class/symbol | not started | ~5 |
|
| M2 | Syntax and search: highlighting, structure, find in files, go to file/class/symbol | not started | ~5 |
|
||||||
| M3 | LSP, terminal, CLI: completion, diagnostics, go to definition, hover, rename; terminal; `lutra` CLI and MCP — **MVP** | not started | ~8 |
|
| M3 | LSP, terminal, CLI: completion, diagnostics, go to definition, hover, rename; terminal; `lutra` CLI and MCP — **MVP** | not started | ~8 |
|
||||||
| M4 | Git: status, diff, commit, branches, log, blame, conflicts | not started | ~150 |
|
| M4 | Git: status, diff, commit, branches, log, blame, conflicts | not started | ~150 |
|
||||||
|
|
@ -31,6 +31,7 @@ By the raw estimates the alpha gate needs M1–M4 plus cross-platform verificati
|
||||||
|
|
||||||
| Date | Change | Summary |
|
| Date | Change | Summary |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
|
| 2026-10-16 | minor | M1.9a settings backend, M1.10 themes |
|
||||||
| 2026-10-15 | minor | M1.11 message catalog |
|
| 2026-10-15 | minor | M1.11 message catalog |
|
||||||
| 2026-10-15 | minor | Cycle C1 review: M1–M3 hours recalibrated ×0.1, M0 CI note |
|
| 2026-10-15 | minor | Cycle C1 review: M1–M3 hours recalibrated ×0.1, M0 CI note |
|
||||||
| 2026-10-15 | minor | M1.6 tabs and editor |
|
| 2026-10-15 | minor | M1.6 tabs and editor |
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ Hours are the estimated agent wall-clock hours for one agent to reach behaviour
|
||||||
| HTTP client | 1 | 0% | everything | ~60 (est.) | — |
|
| HTTP client | 1 | 0% | everything | ~60 (est.) | — |
|
||||||
| Web languages | 2 | 0% | everything | ~200 (est.) | — |
|
| Web languages | 2 | 0% | everything | ~200 (est.) | — |
|
||||||
| Docker and remote | 1 | 0% | everything | ~120 (est.) | — |
|
| Docker and remote | 1 | 0% | everything | ~120 (est.) | — |
|
||||||
| Settings, keymaps, themes | 1 | 2% (est.) | settings UI, keymaps, theme switching (theme tokens exist in `lutra_engine::theme`; M1.9a: settings backend with 3 keys, persistence, `settings.*` commands, no UI yet) | ~60 (est.) | — |
|
| Settings, keymaps, themes | 1 | 4% (est.) | settings UI, keymaps, colour scheme editor, custom and imported themes, per-language colours (M1.9a: settings backend with 3 keys, persistence, `settings.*` commands, no UI yet; M1.10: light and dark themes with live switching and a system mode, chosen through the setting only) | ~60 (est.) | — |
|
||||||
| Plug-ins | 0.5 | 0% | everything | ~120 (est.) | — |
|
| Plug-ins | 0.5 | 0% | everything | ~120 (est.) | — |
|
||||||
| AI features | 0.5 | 0% | everything | ~60 (est.) | — |
|
| AI features | 0.5 | 0% | everything | ~60 (est.) | — |
|
||||||
|
|
||||||
|
|
@ -56,11 +56,13 @@ The project tree is the first user-visible feature (Project view 8%, estimated);
|
||||||
` / `
|
` / `
|
||||||
` / `
|
` / `
|
||||||
` detection with a keep-the-file's-ending save policy. 23 unit tests and 6 proptests (round-trips on emoji, ZWJ sequences, CJK and combining marks; random edit batches checked against a `String` model, never panicking).
|
` detection with a keep-the-file's-ending save policy. 23 unit tests and 6 proptests (round-trips on emoji, ZWJ sequences, CJK and combining marks; random edit batches checked against a `String` model, never panicking).
|
||||||
|
- M1.10 themes (2026-10-16): Lutra Dark and Lutra Light with the same tokens, including real editor, tab and notice tokens; `appearance.theme` switches live without a reload, `system` follows the OS preference, and the window starts in the stored theme. Both themes pass a WCAG AA contrast test for every text/background pair in use. Checked by engine, control-channel and Vitest DOM tests; not yet looked at in the running app (gaming mode). No theme picker yet (settings dialog, M1.9b).
|
||||||
|
|
||||||
## Revision history
|
## Revision history
|
||||||
|
|
||||||
| Date | Change | Summary |
|
| Date | Change | Summary |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
|
| 2026-10-16 | minor | M1.10: Settings row 2% → 4% (est.), light/dark themes with live switching |
|
||||||
| 2026-10-16 | minor | M1.9a: Settings row 0% → 2% (est.), settings backend without UI |
|
| 2026-10-16 | minor | M1.9a: Settings row 0% → 2% (est.), settings backend without UI |
|
||||||
| 2026-10-15 | minor | Calibration note after cycle C1 (factor 0.07) |
|
| 2026-10-15 | minor | Calibration note after cycle C1 (factor 0.07) |
|
||||||
| 2026-10-15 | minor | Editor core 0% → 8% (estimated): tabs and editor in the app (M1.6) |
|
| 2026-10-15 | minor | Editor core 0% → 8% (estimated): tabs and editor in the app (M1.6) |
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# UI parity checklist
|
# UI parity checklist
|
||||||
|
|
||||||
> **Status:** main window layout (M1.5), project tree running against the engine (M1.4), editor tabs with a CodeMirror editor (M1.6) · **Last updated:** 2026-10-15
|
> **Status:** main window layout (M1.5), project tree running against the engine (M1.4), editor tabs with a CodeMirror editor (M1.6), light and dark themes (M1.10) · **Last updated:** 2026-10-16
|
||||||
|
|
||||||
- [ ] Main window: tool window stripes, editor area, status bar, navigation bar
|
- [ ] Main window: tool window stripes, editor area, status bar, navigation bar
|
||||||
- M1.5 (2026-10-14): left tool window with header, hide button, collapsed stripe with a show button, resizable by pointer and keyboard; editor area placeholder; status bar. Missing: stripes with several tool windows, bottom/right docking, navigation bar, layout persistence. Not checked in the running app yet (needs M1.4).
|
- M1.5 (2026-10-14): left tool window with header, hide button, collapsed stripe with a show button, resizable by pointer and keyboard; editor area placeholder; status bar. Missing: stripes with several tool windows, bottom/right docking, navigation bar, layout persistence. Not checked in the running app yet (needs M1.4).
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
- [ ] Settings dialog with search
|
- [ ] Settings dialog with search
|
||||||
- [ ] Keymap editor (Lutra's own default keymap; no copied keymaps)
|
- [ ] Keymap editor (Lutra's own default keymap; no copied keymaps)
|
||||||
- [ ] Light and dark themes from theme tokens
|
- [ ] Light and dark themes from theme tokens
|
||||||
|
- M1.10 (2026-10-16): Lutra Dark and Lutra Light from Rust tokens, switched live through `appearance.theme` (no reload), `system` follows the OS preference, the first frame uses the stored theme; the editor (selection, active line, cursor, gutter, matches), tabs and notices have their own tokens; WCAG AA contrast checked by Vitest for every text pair in both themes. Covered by Vitest DOM and control-channel tests; live check pending (gaming mode). Missing: a theme picker (settings dialog, M1.9b; command palette, M1.8), the native title bar following the theme, editor font size from `editor.fontSize`, colour scheme editor, high-contrast theme, design review of the values.
|
||||||
- [ ] Notifications and background task indicator
|
- [ ] Notifications and background task indicator
|
||||||
- [ ] Structure tool window
|
- [ ] Structure tool window
|
||||||
- [ ] Problems tool window
|
- [ ] Problems tool window
|
||||||
|
|
@ -24,6 +25,7 @@
|
||||||
|
|
||||||
| Date | Change | Summary |
|
| Date | Change | Summary |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
|
| 2026-10-16 | minor | Themes partial (M1.10) |
|
||||||
| 2026-10-15 | minor | Editor tabs partial (M1.6) |
|
| 2026-10-15 | minor | Editor tabs partial (M1.6) |
|
||||||
| 2026-10-15 | minor | Project tool window runs against the engine (M1.4) |
|
| 2026-10-15 | minor | Project tool window runs against the engine (M1.4) |
|
||||||
| 2026-10-14 | minor | Notes on main window and project tool window (M1.5) |
|
| 2026-10-14 | minor | Notes on main window and project tool window (M1.5) |
|
||||||
|
|
|
||||||
|
|
@ -2,18 +2,28 @@
|
||||||
/**
|
/**
|
||||||
* Root component: mounts the main window layout with the editor area; the
|
* Root component: mounts the main window layout with the editor area; the
|
||||||
* slogan shows while no tab is open. Loads product information from the
|
* slogan shows while no tab is open. Loads product information from the
|
||||||
* engine on mount.
|
* engine on mount and starts following the theme (see `theme.ts`).
|
||||||
*/
|
*/
|
||||||
import { onMounted } from "vue";
|
import { onMounted, onUnmounted } from "vue";
|
||||||
import EditorArea from "./components/editor/EditorArea.vue";
|
import EditorArea from "./components/editor/EditorArea.vue";
|
||||||
import MainLayout from "./components/layout/MainLayout.vue";
|
import MainLayout from "./components/layout/MainLayout.vue";
|
||||||
import { useAppStore } from "./stores/app";
|
import { useAppStore } from "./stores/app";
|
||||||
|
import { startTheme } from "./theme";
|
||||||
|
|
||||||
const app = useAppStore();
|
const app = useAppStore();
|
||||||
|
|
||||||
|
/** Stops following the theme; set while mounted. */
|
||||||
|
let stopTheme: (() => void) | null = null;
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
stopTheme = startTheme();
|
||||||
void app.loadAbout();
|
void app.loadAbout();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
stopTheme?.();
|
||||||
|
stopTheme = null;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ onBeforeUnmount(() => {
|
||||||
padding: 4px 12px;
|
padding: 4px 12px;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
color: var(--lt-fg);
|
color: var(--lt-fg);
|
||||||
background: var(--lt-notice-bg, color-mix(in srgb, var(--lt-accent) 15%, var(--lt-bg)));
|
background: var(--lt-notice-bg);
|
||||||
border-bottom: 1px solid var(--lt-border);
|
border-bottom: 1px solid var(--lt-border);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,7 @@ function onKeydown(event: KeyboardEvent): void {
|
||||||
|
|
||||||
.tabs__tab--active {
|
.tabs__tab--active {
|
||||||
color: var(--lt-fg);
|
color: var(--lt-fg);
|
||||||
background: var(--lt-tab-active-bg, var(--lt-editor-bg));
|
background: var(--lt-tab-active-bg);
|
||||||
border-bottom-color: var(--lt-accent);
|
border-bottom-color: var(--lt-accent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -131,7 +131,7 @@ function onKeydown(event: KeyboardEvent): void {
|
||||||
width: 7px;
|
width: 7px;
|
||||||
height: 7px;
|
height: 7px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
background: var(--lt-tab-modified, var(--lt-accent));
|
background: var(--lt-tab-modified);
|
||||||
}
|
}
|
||||||
|
|
||||||
.tabs__close {
|
.tabs__close {
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,10 @@
|
||||||
/**
|
/**
|
||||||
* CodeMirror extensions of the Lutra editor: the basic setup (line numbers,
|
* CodeMirror extensions of the Lutra editor: the basic setup (line numbers,
|
||||||
* history, selection, brackets, search) without a language (PHP comes in
|
* history, selection, brackets, search) without a language (PHP comes in
|
||||||
* M2), and a theme that takes every colour from `--lt-*` tokens.
|
* M2), and a theme that takes every colour from `--lt-*` tokens, including
|
||||||
*
|
* the editor tokens (`--lt-editor-selection-bg`, `--lt-editor-active-line-bg`,
|
||||||
* Tokens the theme does not define yet are read with a fallback derived from
|
* `--lt-editor-cursor`, `--lt-editor-gutter-bg`, `--lt-editor-gutter-fg`,
|
||||||
* existing tokens (`var(--lt-editor-selection-bg, color-mix(…))`), so that a
|
* `--lt-editor-match-bg`, `--lt-font-size-editor`).
|
||||||
* token added to the Rust theme later takes effect without code changes.
|
|
||||||
* Requested from design: `--lt-editor-selection-bg`,
|
|
||||||
* `--lt-editor-active-line-bg`, `--lt-editor-cursor`, `--lt-editor-gutter-bg`,
|
|
||||||
* `--lt-editor-gutter-fg`, `--lt-editor-match-bg`, `--lt-font-size-editor`.
|
|
||||||
*/
|
*/
|
||||||
import { EditorView } from "@codemirror/view";
|
import { EditorView } from "@codemirror/view";
|
||||||
import type { Extension } from "@codemirror/state";
|
import type { Extension } from "@codemirror/state";
|
||||||
|
|
@ -20,7 +16,7 @@ export const lutraEditorTheme: Extension = EditorView.theme({
|
||||||
height: "100%",
|
height: "100%",
|
||||||
color: "var(--lt-fg)",
|
color: "var(--lt-fg)",
|
||||||
backgroundColor: "var(--lt-editor-bg)",
|
backgroundColor: "var(--lt-editor-bg)",
|
||||||
fontSize: "var(--lt-font-size-editor, var(--lt-font-size-ui))",
|
fontSize: "var(--lt-font-size-editor)",
|
||||||
},
|
},
|
||||||
"&.cm-focused": {
|
"&.cm-focused": {
|
||||||
outline: "none",
|
outline: "none",
|
||||||
|
|
@ -30,37 +26,32 @@ export const lutraEditorTheme: Extension = EditorView.theme({
|
||||||
lineHeight: "1.5",
|
lineHeight: "1.5",
|
||||||
},
|
},
|
||||||
".cm-content": {
|
".cm-content": {
|
||||||
caretColor: "var(--lt-editor-cursor, var(--lt-accent))",
|
caretColor: "var(--lt-editor-cursor)",
|
||||||
},
|
},
|
||||||
".cm-cursor, .cm-dropCursor": {
|
".cm-cursor, .cm-dropCursor": {
|
||||||
borderLeftColor: "var(--lt-editor-cursor, var(--lt-accent))",
|
borderLeftColor: "var(--lt-editor-cursor)",
|
||||||
},
|
},
|
||||||
"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":
|
"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":
|
||||||
{
|
{
|
||||||
backgroundColor:
|
backgroundColor: "var(--lt-editor-selection-bg)",
|
||||||
"var(--lt-editor-selection-bg, color-mix(in srgb, var(--lt-accent) 30%, transparent))",
|
|
||||||
},
|
},
|
||||||
".cm-activeLine": {
|
".cm-activeLine": {
|
||||||
backgroundColor:
|
backgroundColor: "var(--lt-editor-active-line-bg)",
|
||||||
"var(--lt-editor-active-line-bg, color-mix(in srgb, var(--lt-fg) 5%, transparent))",
|
|
||||||
},
|
},
|
||||||
".cm-selectionMatch, .cm-searchMatch": {
|
".cm-selectionMatch, .cm-searchMatch": {
|
||||||
backgroundColor:
|
backgroundColor: "var(--lt-editor-match-bg)",
|
||||||
"var(--lt-editor-match-bg, color-mix(in srgb, var(--lt-accent) 18%, transparent))",
|
|
||||||
},
|
},
|
||||||
"&.cm-focused .cm-matchingBracket": {
|
"&.cm-focused .cm-matchingBracket": {
|
||||||
backgroundColor:
|
backgroundColor: "var(--lt-editor-match-bg)",
|
||||||
"var(--lt-editor-match-bg, color-mix(in srgb, var(--lt-accent) 18%, transparent))",
|
|
||||||
outline: "1px solid var(--lt-border)",
|
outline: "1px solid var(--lt-border)",
|
||||||
},
|
},
|
||||||
".cm-gutters": {
|
".cm-gutters": {
|
||||||
backgroundColor: "var(--lt-editor-gutter-bg, var(--lt-editor-bg))",
|
backgroundColor: "var(--lt-editor-gutter-bg)",
|
||||||
color: "var(--lt-editor-gutter-fg, var(--lt-fg-muted))",
|
color: "var(--lt-editor-gutter-fg)",
|
||||||
borderRight: "1px solid var(--lt-border)",
|
borderRight: "1px solid var(--lt-border)",
|
||||||
},
|
},
|
||||||
".cm-activeLineGutter": {
|
".cm-activeLineGutter": {
|
||||||
backgroundColor:
|
backgroundColor: "var(--lt-editor-active-line-bg)",
|
||||||
"var(--lt-editor-active-line-bg, color-mix(in srgb, var(--lt-fg) 5%, transparent))",
|
|
||||||
color: "var(--lt-fg)",
|
color: "var(--lt-fg)",
|
||||||
},
|
},
|
||||||
".cm-panels": {
|
".cm-panels": {
|
||||||
|
|
|
||||||
|
|
@ -18,5 +18,7 @@
|
||||||
"project.empty.noFolder": "No folder is open.",
|
"project.empty.noFolder": "No folder is open.",
|
||||||
"project.openFolder": "Open Folder…",
|
"project.openFolder": "Open Folder…",
|
||||||
"project.toolWindow.title": "Project",
|
"project.toolWindow.title": "Project",
|
||||||
"project.tree.loading": "Loading…"
|
"project.tree.loading": "Loading…",
|
||||||
|
"theme.lutraDark": "Lutra Dark",
|
||||||
|
"theme.lutraLight": "Lutra Light"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,8 @@ export type EngineEventPayload =
|
||||||
| { kind: "dirtyChanged"; id: number; dirty: boolean }
|
| { kind: "dirtyChanged"; id: number; dirty: boolean }
|
||||||
| { kind: "bufferClosed"; id: number }
|
| { kind: "bufferClosed"; id: number }
|
||||||
| { kind: "fileChangedOnDisk"; path: string; id: number; removed: boolean }
|
| { kind: "fileChangedOnDisk"; path: string; id: number; removed: boolean }
|
||||||
| { kind: "watchFailed"; message: string };
|
| { kind: "watchFailed"; message: string }
|
||||||
|
| { kind: "themeChanged"; id: string; dark: boolean; tokens: Record<string, string> };
|
||||||
|
|
||||||
/** Callback receiving engine events. */
|
/** Callback receiving engine events. */
|
||||||
export type EngineEventHandler = (event: EngineEventPayload) => void;
|
export type EngineEventHandler = (event: EngineEventPayload) => void;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* Base layout of the Lutra window. Colours and fonts come only from the
|
* Base layout of the Lutra window. Colours and fonts come only from the
|
||||||
* theme tokens (`--lt-*`) that the desktop shell injects before first paint.
|
* theme tokens (`--lt-*`) that the desktop shell injects before first paint
|
||||||
|
* and `theme.ts` replaces on `:root` when the theme changes.
|
||||||
*/
|
*/
|
||||||
html,
|
html,
|
||||||
body,
|
body,
|
||||||
|
|
|
||||||
109
ui/src/theme.ts
Normal file
109
ui/src/theme.ts
Normal file
|
|
@ -0,0 +1,109 @@
|
||||||
|
/**
|
||||||
|
* Live theme switching. The desktop shell injects the stored theme's tokens
|
||||||
|
* before first paint; afterwards the engine sends `themeChanged` with every
|
||||||
|
* token, and {@link applyTheme} writes them onto `:root` and sets
|
||||||
|
* `color-scheme`, so a switch needs no reload. In "system" mode the engine
|
||||||
|
* resolves the theme from the OS preference that {@link startTheme} reports
|
||||||
|
* with `theme.systemPreference` whenever it changes.
|
||||||
|
*/
|
||||||
|
import { onEngineEvent, run } from "./ipc";
|
||||||
|
|
||||||
|
/** A resolved theme as the engine sends it. */
|
||||||
|
export interface ResolvedTheme {
|
||||||
|
/** Theme id, e.g. `lutra-light`. */
|
||||||
|
id: string;
|
||||||
|
/** Whether the theme is dark. */
|
||||||
|
dark: boolean;
|
||||||
|
/** Every token as `--lt-<name>` → CSS value. */
|
||||||
|
tokens: Record<string, string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Media query of the OS dark preference. */
|
||||||
|
export const DARK_QUERY = "(prefers-color-scheme: dark)";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads a resolved theme from untrusted data (an event or a command result).
|
||||||
|
* Tokens without the `--lt-` prefix or with a non-string value are dropped.
|
||||||
|
*
|
||||||
|
* @param value - the data.
|
||||||
|
* @returns the theme, or null if `id` or `dark` is missing.
|
||||||
|
*/
|
||||||
|
export function toResolvedTheme(value: unknown): ResolvedTheme | null {
|
||||||
|
if (typeof value !== "object" || value === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const { id, dark, tokens } = value as Record<string, unknown>;
|
||||||
|
if (typeof id !== "string" || typeof dark !== "boolean") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const clean: Record<string, string> = {};
|
||||||
|
if (typeof tokens === "object" && tokens !== null) {
|
||||||
|
for (const [name, token] of Object.entries(tokens)) {
|
||||||
|
if (name.startsWith("--lt-") && typeof token === "string") {
|
||||||
|
clean[name] = token;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { id, dark, tokens: clean };
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies a theme: writes its tokens onto the root element's inline style
|
||||||
|
* (which wins over the injected `<style id="lt-theme">`), sets
|
||||||
|
* `color-scheme` and records the id in `data-theme`.
|
||||||
|
*
|
||||||
|
* @param theme - the theme.
|
||||||
|
* @param root - the element to theme; the document element by default.
|
||||||
|
*/
|
||||||
|
export function applyTheme(theme: ResolvedTheme, root: HTMLElement = document.documentElement): void {
|
||||||
|
for (const [name, value] of Object.entries(theme.tokens)) {
|
||||||
|
root.style.setProperty(name, value);
|
||||||
|
}
|
||||||
|
root.style.colorScheme = theme.dark ? "dark" : "light";
|
||||||
|
root.dataset.theme = theme.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reports the OS preference to the engine and applies the theme it
|
||||||
|
* resolves. A failed call keeps the current theme.
|
||||||
|
*
|
||||||
|
* @param dark - whether the OS prefers a dark theme.
|
||||||
|
*/
|
||||||
|
export async function reportSystemPreference(dark: boolean): Promise<void> {
|
||||||
|
const result = await run("theme.systemPreference", { dark });
|
||||||
|
if (!result.ok) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const theme = toResolvedTheme(result.value);
|
||||||
|
if (theme) {
|
||||||
|
applyTheme(theme);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts following the theme: applies every `themeChanged` event and
|
||||||
|
* reports the OS preference now and whenever it changes. Outside a browser
|
||||||
|
* with `matchMedia` the OS preference counts as dark.
|
||||||
|
*
|
||||||
|
* @returns a function that stops following.
|
||||||
|
*/
|
||||||
|
export function startTheme(): () => void {
|
||||||
|
const unsubscribe = onEngineEvent((event) => {
|
||||||
|
if (event.kind === "themeChanged") {
|
||||||
|
const theme = toResolvedTheme(event);
|
||||||
|
if (theme) {
|
||||||
|
applyTheme(theme);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const query = typeof window.matchMedia === "function" ? window.matchMedia(DARK_QUERY) : null;
|
||||||
|
const onChange = (event: MediaQueryListEvent): void => {
|
||||||
|
void reportSystemPreference(event.matches);
|
||||||
|
};
|
||||||
|
query?.addEventListener("change", onChange);
|
||||||
|
void reportSystemPreference(query?.matches ?? true);
|
||||||
|
return () => {
|
||||||
|
unsubscribe();
|
||||||
|
query?.removeEventListener("change", onChange);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -35,6 +35,12 @@ const usedKeys = sourceFiles(SRC).flatMap((file) =>
|
||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keys the source never passes to `t` literally because they arrive at
|
||||||
|
* runtime from the engine: theme labels from `theme.list`.
|
||||||
|
*/
|
||||||
|
const RUNTIME_KEYS = new Set(["theme.lutraDark", "theme.lutraLight"]);
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
vi.restoreAllMocks();
|
vi.restoreAllMocks();
|
||||||
});
|
});
|
||||||
|
|
@ -81,7 +87,7 @@ describe("t", () => {
|
||||||
describe("en.json", () => {
|
describe("en.json", () => {
|
||||||
it("uses flat dotted keys of known areas with string values", () => {
|
it("uses flat dotted keys of known areas with string values", () => {
|
||||||
for (const [key, value] of Object.entries(en)) {
|
for (const [key, value] of Object.entries(en)) {
|
||||||
expect(key).toMatch(/^(app|project|editor|common)\.[A-Za-z0-9]+(\.[A-Za-z0-9]+)*$/);
|
expect(key).toMatch(/^(app|project|editor|common|theme)\.[A-Za-z0-9]+(\.[A-Za-z0-9]+)*$/);
|
||||||
expect(typeof value).toBe("string");
|
expect(typeof value).toBe("string");
|
||||||
expect(value.trim()).not.toBe("");
|
expect(value.trim()).not.toBe("");
|
||||||
}
|
}
|
||||||
|
|
@ -98,8 +104,12 @@ describe("en.json", () => {
|
||||||
expect(missing).toEqual([]);
|
expect(missing).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("has every runtime key", () => {
|
||||||
|
expect([...RUNTIME_KEYS].filter((key) => !hasMessage(key))).toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
it("has no unused keys", () => {
|
it("has no unused keys", () => {
|
||||||
const used = new Set(usedKeys.map(({ key }) => key));
|
const used = new Set([...usedKeys.map(({ key }) => key), ...RUNTIME_KEYS]);
|
||||||
expect(Object.keys(en).filter((key) => !used.has(key))).toEqual([]);
|
expect(Object.keys(en).filter((key) => !used.has(key))).toEqual([]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
94
ui/tests/theme/contrast.test.ts
Normal file
94
ui/tests/theme/contrast.test.ts
Normal file
|
|
@ -0,0 +1,94 @@
|
||||||
|
/**
|
||||||
|
* WCAG 2.1 contrast check of the built-in themes
|
||||||
|
* (https://www.w3.org/TR/WCAG21/#contrast-minimum). Every token pair the
|
||||||
|
* UI draws text with reaches AA: 4.5:1 for body text, 3:1 for non-text
|
||||||
|
* marks (cursor, modified dot; WCAG 1.4.11). The themes come from
|
||||||
|
* `themes.json`, a snapshot that the Rust test `ui_snapshot_is_current`
|
||||||
|
* keeps equal to `lutra_engine::theme`.
|
||||||
|
*/
|
||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
import themes from "./themes.json";
|
||||||
|
|
||||||
|
/** Minimum ratio for normal-size text (AA). */
|
||||||
|
const TEXT = 4.5;
|
||||||
|
/** Minimum ratio for large text and non-text marks (AA). */
|
||||||
|
const LARGE = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Foreground token, background token and minimum ratio, for every
|
||||||
|
* combination the components use (see `ui/src/**` `color`/`background`).
|
||||||
|
*/
|
||||||
|
const PAIRS: [string, string, number][] = [
|
||||||
|
["fg", "bg", TEXT],
|
||||||
|
["fg", "editor-bg", TEXT],
|
||||||
|
["fg", "tab-active-bg", TEXT],
|
||||||
|
["fg", "notice-bg", TEXT],
|
||||||
|
["fg", "editor-active-line-bg", TEXT],
|
||||||
|
["fg", "editor-selection-bg", TEXT],
|
||||||
|
["fg", "editor-match-bg", TEXT],
|
||||||
|
["fg-muted", "bg", TEXT],
|
||||||
|
["fg-muted", "editor-bg", TEXT],
|
||||||
|
["accent", "bg", TEXT],
|
||||||
|
["error", "bg", TEXT],
|
||||||
|
["error", "statusbar-bg", TEXT],
|
||||||
|
["statusbar-fg", "statusbar-bg", TEXT],
|
||||||
|
["editor-gutter-fg", "editor-gutter-bg", TEXT],
|
||||||
|
["editor-gutter-fg", "editor-active-line-bg", TEXT],
|
||||||
|
["editor-cursor", "editor-bg", LARGE],
|
||||||
|
["editor-cursor", "editor-active-line-bg", LARGE],
|
||||||
|
["tab-modified", "bg", LARGE],
|
||||||
|
["tab-modified", "tab-active-bg", LARGE],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Relative luminance of a `#rrggbb` colour (WCAG 2.1 definition).
|
||||||
|
*
|
||||||
|
* @param hex - the colour.
|
||||||
|
* @returns the luminance, 0 (black) to 1 (white).
|
||||||
|
*/
|
||||||
|
export function luminance(hex: string): number {
|
||||||
|
const match = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(hex);
|
||||||
|
if (!match) {
|
||||||
|
throw new Error(`not a #rrggbb colour: ${hex}`);
|
||||||
|
}
|
||||||
|
const [r, g, b] = match.slice(1).map((part) => {
|
||||||
|
const c = parseInt(part, 16) / 255;
|
||||||
|
return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
|
||||||
|
}) as [number, number, number];
|
||||||
|
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contrast ratio of two colours.
|
||||||
|
*
|
||||||
|
* @param a - one `#rrggbb` colour.
|
||||||
|
* @param b - the other.
|
||||||
|
* @returns the ratio, 1 to 21.
|
||||||
|
*/
|
||||||
|
export function contrast(a: string, b: string): number {
|
||||||
|
const [hi, lo] = [luminance(a), luminance(b)].sort((x, y) => y - x) as [number, number];
|
||||||
|
return (hi + 0.05) / (lo + 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
describe("contrast helper", () => {
|
||||||
|
it("matches the WCAG extremes", () => {
|
||||||
|
expect(contrast("#000000", "#ffffff")).toBeCloseTo(21, 5);
|
||||||
|
expect(contrast("#777777", "#777777")).toBe(1);
|
||||||
|
expect(contrast("#767676", "#ffffff")).toBeGreaterThanOrEqual(4.5);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe.each(themes)("theme $id", (theme) => {
|
||||||
|
const tokens: Record<string, string> = theme.tokens;
|
||||||
|
const token = (name: string): string => {
|
||||||
|
const value = tokens[`--lt-${name}`];
|
||||||
|
if (value === undefined) {
|
||||||
|
throw new Error(`${theme.id} has no --lt-${name}`);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
};
|
||||||
|
|
||||||
|
it.each(PAIRS)("%s on %s reaches %d:1", (fg, bg, min) => {
|
||||||
|
expect(contrast(token(fg), token(bg))).toBeGreaterThanOrEqual(min);
|
||||||
|
});
|
||||||
|
});
|
||||||
194
ui/tests/theme/theme.test.ts
Normal file
194
ui/tests/theme/theme.test.ts
Normal file
|
|
@ -0,0 +1,194 @@
|
||||||
|
/**
|
||||||
|
* Tests of live theme switching (`ui/src/theme.ts`): tokens and
|
||||||
|
* `color-scheme` land on `:root`, `themeChanged` events and the OS
|
||||||
|
* preference drive it, and the components read only tokens both themes
|
||||||
|
* define (no `var(--lt-x, fallback)` left for theme tokens).
|
||||||
|
*/
|
||||||
|
import { readdirSync, readFileSync } from "node:fs";
|
||||||
|
import { join } from "node:path";
|
||||||
|
import { flushPromises } from "@vue/test-utils";
|
||||||
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
|
import themes from "./themes.json";
|
||||||
|
|
||||||
|
const invoke = vi.hoisted(() => vi.fn());
|
||||||
|
const listeners = vi.hoisted(() => new Map<string, (event: { payload: unknown }) => void>());
|
||||||
|
vi.mock("@tauri-apps/api/core", () => ({ invoke }));
|
||||||
|
vi.mock("@tauri-apps/api/event", () => ({
|
||||||
|
listen: (name: string, handler: (event: { payload: unknown }) => void) => {
|
||||||
|
listeners.set(name, handler);
|
||||||
|
return Promise.resolve(() => listeners.delete(name));
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
import { ENGINE_EVENT } from "../../src/ipc";
|
||||||
|
import { applyTheme, startTheme, toResolvedTheme, type ResolvedTheme } from "../../src/theme";
|
||||||
|
|
||||||
|
/** The snapshot themes by id. */
|
||||||
|
const byId = (id: string): ResolvedTheme => {
|
||||||
|
const theme = themes.find((t) => t.id === id);
|
||||||
|
if (!theme) {
|
||||||
|
throw new Error(`no theme ${id}`);
|
||||||
|
}
|
||||||
|
return theme;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** A controllable `matchMedia` stand-in. */
|
||||||
|
function fakeMedia(dark: boolean) {
|
||||||
|
const handlers = new Set<(event: MediaQueryListEvent) => void>();
|
||||||
|
const query = {
|
||||||
|
matches: dark,
|
||||||
|
addEventListener: (_: string, h: (event: MediaQueryListEvent) => void) => handlers.add(h),
|
||||||
|
removeEventListener: (_: string, h: (event: MediaQueryListEvent) => void) =>
|
||||||
|
handlers.delete(h),
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
query,
|
||||||
|
handlers,
|
||||||
|
change(next: boolean) {
|
||||||
|
query.matches = next;
|
||||||
|
for (const h of handlers) {
|
||||||
|
h({ matches: next } as MediaQueryListEvent);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const root = document.documentElement;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
invoke.mockReset();
|
||||||
|
listeners.clear();
|
||||||
|
root.removeAttribute("style");
|
||||||
|
delete root.dataset.theme;
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
vi.unstubAllGlobals();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("applyTheme", () => {
|
||||||
|
it("writes every token and the colour scheme onto :root", () => {
|
||||||
|
const light = byId("lutra-light");
|
||||||
|
applyTheme(light);
|
||||||
|
for (const [name, value] of Object.entries(light.tokens)) {
|
||||||
|
expect(root.style.getPropertyValue(name)).toBe(value);
|
||||||
|
}
|
||||||
|
expect(root.style.colorScheme).toBe("light");
|
||||||
|
expect(root.dataset.theme).toBe("lutra-light");
|
||||||
|
|
||||||
|
applyTheme(byId("lutra-dark"));
|
||||||
|
expect(root.style.getPropertyValue("--lt-bg")).toBe("#1f1d1b");
|
||||||
|
expect(root.style.getPropertyValue("--lt-editor-selection-bg")).toBe("#513f2c");
|
||||||
|
expect(root.style.colorScheme).toBe("dark");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("toResolvedTheme", () => {
|
||||||
|
it("rejects malformed data and drops foreign tokens", () => {
|
||||||
|
expect(toResolvedTheme(null)).toBeNull();
|
||||||
|
expect(toResolvedTheme({ id: "x" })).toBeNull();
|
||||||
|
expect(
|
||||||
|
toResolvedTheme({
|
||||||
|
kind: "themeChanged",
|
||||||
|
id: "x",
|
||||||
|
dark: true,
|
||||||
|
tokens: { "--lt-bg": "#000000", color: "red", "--lt-fg": 3 },
|
||||||
|
}),
|
||||||
|
).toEqual({ id: "x", dark: true, tokens: { "--lt-bg": "#000000" } });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("startTheme", () => {
|
||||||
|
it("reports the OS preference, applies the result and follows changes", async () => {
|
||||||
|
const media = fakeMedia(false);
|
||||||
|
vi.stubGlobal("matchMedia", () => media.query);
|
||||||
|
invoke.mockImplementation((_: string, args: { command: string; params: { dark: boolean } }) =>
|
||||||
|
Promise.resolve(
|
||||||
|
args.command === "theme.systemPreference"
|
||||||
|
? byId(args.params.dark ? "lutra-dark" : "lutra-light")
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const stop = startTheme();
|
||||||
|
await flushPromises();
|
||||||
|
expect(invoke).toHaveBeenCalledWith("engine_execute", {
|
||||||
|
command: "theme.systemPreference",
|
||||||
|
params: { dark: false },
|
||||||
|
});
|
||||||
|
expect(root.dataset.theme).toBe("lutra-light");
|
||||||
|
expect(root.style.colorScheme).toBe("light");
|
||||||
|
|
||||||
|
media.change(true);
|
||||||
|
await flushPromises();
|
||||||
|
expect(root.dataset.theme).toBe("lutra-dark");
|
||||||
|
expect(root.style.getPropertyValue("--lt-bg")).toBe("#1f1d1b");
|
||||||
|
|
||||||
|
stop();
|
||||||
|
expect(media.handlers.size).toBe(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("applies themeChanged events without a reload", async () => {
|
||||||
|
invoke.mockResolvedValue(null);
|
||||||
|
const stop = startTheme();
|
||||||
|
await flushPromises();
|
||||||
|
const emit = listeners.get(ENGINE_EVENT);
|
||||||
|
expect(emit).toBeDefined();
|
||||||
|
emit?.({ payload: { kind: "themeChanged", ...byId("lutra-light") } });
|
||||||
|
expect(root.dataset.theme).toBe("lutra-light");
|
||||||
|
expect(root.style.getPropertyValue("--lt-notice-bg")).toBe("#e9dfd4");
|
||||||
|
emit?.({ payload: { kind: "treeChanged", dir: "" } });
|
||||||
|
expect(root.dataset.theme).toBe("lutra-light");
|
||||||
|
stop();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("keeps the current theme when the engine call fails", async () => {
|
||||||
|
invoke.mockRejectedValue({ code: "internal", message: "down" });
|
||||||
|
const stop = startTheme();
|
||||||
|
await flushPromises();
|
||||||
|
expect(root.dataset.theme).toBeUndefined();
|
||||||
|
stop();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("components", () => {
|
||||||
|
const SRC = join(import.meta.dirname, "..", "..", "src");
|
||||||
|
const files = (dir: string): string[] =>
|
||||||
|
readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
|
||||||
|
const path = join(dir, entry.name);
|
||||||
|
if (entry.isDirectory()) {
|
||||||
|
return files(path);
|
||||||
|
}
|
||||||
|
return /\.(ts|vue|css)$/.test(entry.name) ? [path] : [];
|
||||||
|
});
|
||||||
|
const source = files(SRC).map((file) => readFileSync(file, "utf8"));
|
||||||
|
const defined = (name: string) => themes.every((t) => name in t.tokens);
|
||||||
|
|
||||||
|
it("use only theme tokens that both themes define, without fallbacks", () => {
|
||||||
|
const used = source.flatMap((text) =>
|
||||||
|
[...text.matchAll(/var\((--lt-[a-z0-9-]+)\s*(,)?/g)].map((m) => ({
|
||||||
|
name: m[1] ?? "",
|
||||||
|
fallback: m[2] !== undefined,
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
expect(used.length).toBeGreaterThan(0);
|
||||||
|
const missing = used.filter((u) => !u.fallback && !defined(u.name)).map((u) => u.name);
|
||||||
|
expect([...new Set(missing)]).toEqual([]);
|
||||||
|
const needless = used.filter((u) => u.fallback && defined(u.name)).map((u) => u.name);
|
||||||
|
expect([...new Set(needless)]).toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("give the editor every editor token", () => {
|
||||||
|
const editor = readFileSync(join(SRC, "components", "editor", "extensions.ts"), "utf8");
|
||||||
|
for (const name of [
|
||||||
|
"--lt-editor-selection-bg",
|
||||||
|
"--lt-editor-active-line-bg",
|
||||||
|
"--lt-editor-cursor",
|
||||||
|
"--lt-editor-gutter-bg",
|
||||||
|
"--lt-editor-gutter-fg",
|
||||||
|
"--lt-editor-match-bg",
|
||||||
|
"--lt-font-size-editor",
|
||||||
|
]) {
|
||||||
|
expect(editor).toContain(`var(${name})`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
62
ui/tests/theme/themes.json
Normal file
62
ui/tests/theme/themes.json
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"dark": true,
|
||||||
|
"id": "lutra-dark",
|
||||||
|
"labelKey": "theme.lutraDark",
|
||||||
|
"tokens": {
|
||||||
|
"--lt-accent": "#d39a5c",
|
||||||
|
"--lt-bg": "#1f1d1b",
|
||||||
|
"--lt-border": "#34302c",
|
||||||
|
"--lt-editor-active-line-bg": "#232221",
|
||||||
|
"--lt-editor-bg": "#191817",
|
||||||
|
"--lt-editor-cursor": "#d39a5c",
|
||||||
|
"--lt-editor-gutter-bg": "#191817",
|
||||||
|
"--lt-editor-gutter-fg": "#9a928a",
|
||||||
|
"--lt-editor-match-bg": "#3a2f23",
|
||||||
|
"--lt-editor-selection-bg": "#513f2c",
|
||||||
|
"--lt-error": "#ef7b6c",
|
||||||
|
"--lt-fg": "#e6e1da",
|
||||||
|
"--lt-fg-muted": "#9a928a",
|
||||||
|
"--lt-font-mono": "ui-monospace, \"Cascadia Code\", Menlo, Consolas, monospace",
|
||||||
|
"--lt-font-size-editor": "14px",
|
||||||
|
"--lt-font-size-small": "12px",
|
||||||
|
"--lt-font-size-ui": "13px",
|
||||||
|
"--lt-font-ui": "system-ui, -apple-system, \"Segoe UI\", Roboto, Ubuntu, sans-serif",
|
||||||
|
"--lt-notice-bg": "#3a3025",
|
||||||
|
"--lt-statusbar-bg": "#24211f",
|
||||||
|
"--lt-statusbar-fg": "#b8afa6",
|
||||||
|
"--lt-tab-active-bg": "#191817",
|
||||||
|
"--lt-tab-modified": "#d39a5c"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"dark": false,
|
||||||
|
"id": "lutra-light",
|
||||||
|
"labelKey": "theme.lutraLight",
|
||||||
|
"tokens": {
|
||||||
|
"--lt-accent": "#965a22",
|
||||||
|
"--lt-bg": "#f4f1ec",
|
||||||
|
"--lt-border": "#ddd6cd",
|
||||||
|
"--lt-editor-active-line-bg": "#f1efed",
|
||||||
|
"--lt-editor-bg": "#fbfaf8",
|
||||||
|
"--lt-editor-cursor": "#965a22",
|
||||||
|
"--lt-editor-gutter-bg": "#fbfaf8",
|
||||||
|
"--lt-editor-gutter-fg": "#6b625a",
|
||||||
|
"--lt-editor-match-bg": "#ece2d8",
|
||||||
|
"--lt-editor-selection-bg": "#e5d7c9",
|
||||||
|
"--lt-error": "#b23a29",
|
||||||
|
"--lt-fg": "#2a2622",
|
||||||
|
"--lt-fg-muted": "#6b625a",
|
||||||
|
"--lt-font-mono": "ui-monospace, \"Cascadia Code\", Menlo, Consolas, monospace",
|
||||||
|
"--lt-font-size-editor": "14px",
|
||||||
|
"--lt-font-size-small": "12px",
|
||||||
|
"--lt-font-size-ui": "13px",
|
||||||
|
"--lt-font-ui": "system-ui, -apple-system, \"Segoe UI\", Roboto, Ubuntu, sans-serif",
|
||||||
|
"--lt-notice-bg": "#e9dfd4",
|
||||||
|
"--lt-statusbar-bg": "#ece7e0",
|
||||||
|
"--lt-statusbar-fg": "#5a5149",
|
||||||
|
"--lt-tab-active-bg": "#fbfaf8",
|
||||||
|
"--lt-tab-modified": "#965a22"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue