diff options
| author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2026-10-28 08:42:30 +0100 |
|---|---|---|
| committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2026-10-28 08:42:30 +0100 |
| commit | aab6af1601fa4cdb9b351987220f32de062d4b2c (patch) | |
| tree | e5d2b4b6af7e5d8fd8d19717786ed0f29b619b0f /crates/wipfel/src/compass.rs | |
| parent | d57f022243850b532239ae08dd75717f55415fbf (diff) | |
web: follow system light/dark preference
All colors moved into CSS custom properties on :root (dark default)
with a prefers-color-scheme: light override block. The two canvas-
drawn surfaces follow too: the viewport now clears transparent so the
CSS canvas background shows through, and the compass strip reads its
colors from the same variables via a new bridge::css_var helper.
theme-color metas (dark + light variants) tint mobile browser chrome
to match.
Diffstat (limited to 'crates/wipfel/src/compass.rs')
| -rw-r--r-- | crates/wipfel/src/compass.rs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/crates/wipfel/src/compass.rs b/crates/wipfel/src/compass.rs index b539e07..5e91c9a 100644 --- a/crates/wipfel/src/compass.rs +++ b/crates/wipfel/src/compass.rs @@ -127,9 +127,11 @@ pub fn compass(props: &Props) -> Html { } let _ = ctx.set_transform(dpr, 0.0, 0.0, dpr, 0.0, 0.0); - let on = "rgb(217, 217, 217)"; - let bg = "rgb(41, 41, 41)"; - let divider = "rgb(82, 82, 82)"; + // theme colors come from the CSS variables, so the strip + // follows light/dark preference like the rest of the UI + let on = bridge::css_var("--compass-fg", "rgb(217, 217, 217)"); + let bg = bridge::css_var("--compass-bg", "rgb(41, 41, 41)"); + let divider = bridge::css_var("--compass-divider", "rgb(82, 82, 82)"); let red = "rgb(255, 102, 64)"; let fill = |c: &str| { @@ -142,9 +144,9 @@ pub fn compass(props: &Props) -> Html { ctx.set_line_width(width); }; - fill(bg); + fill(&bg); ctx.fill_rect(0.0, 0.0, w, STRIP_H); - stroke(divider, 1.0); + stroke(÷r, 1.0); ctx.begin_path(); ctx.move_to(0.0, 0.5); ctx.line_to(w, 0.5); @@ -188,7 +190,7 @@ pub fn compass(props: &Props) -> Html { let a_hi = a_hi.min(c + fold); // baseline - stroke(on, 1.0); + stroke(&on, 1.0); ctx.begin_path(); ctx.move_to(0.0, y0 + 0.5); ctx.line_to(w, y0 + 0.5); @@ -225,7 +227,7 @@ pub fn compass(props: &Props) -> Html { if !x.is_finite() || x < -20.0 || x > w + 20.0 { continue; } - fill(if deg == 0.0 { red } else { on }); + fill(if deg == 0.0 { red } else { &on }); ctx.fill_text(name, x, label_y).ok(); } ctx.set_text_align("start"); |
