Skip to main content

max / makeover-webview

2.5 KB · 66 lines History Blame Raw
1 # makeover-webview
2
3 The webview renderer for
4 [`makeover-layout`]https://makenot.work/git/max/makeover-layout. Emits CSS.
5
6 ## The renderer that needs no palette
7
8 `makeover-immediate` and `makeover-tui` both take a `Palette`, because egui and
9 a terminal need an actual colour before they can put anything on screen. A
10 webview does not. `var(--surface-raised)` *is* the late binding, and the browser
11 resolves it against whatever the theme layer last wrote onto `:root`.
12
13 So this crate emits text naming intents and never learns a colour, which is the
14 deferral rule with no adapter in the way. It is also why the webview was always
15 the wrong renderer to derive a vocabulary from: it can express anything, so it
16 never pushes back.
17
18 ## Phase A: the stylesheet only
19
20 No markup, deliberately. GoingsOn has 145 `innerHTML` sites and Balanced
21 Breakfast 175 `createElement` sites, so moving markup is a migration while
22 adopting a generated stylesheet is a deletion. The apps keep every line of their
23 markup and gain the classes.
24
25 ```css
26 :root {
27 --bevel-raised: inset 1px 1px 0 var(--bevel-light), inset -1px -1px 0 var(--bevel-dark);
28 --bevel-inset: inset 1px 1px 0 var(--bevel-dark), inset -1px -1px 0 var(--bevel-light);
29 }
30
31 .raised { background: var(--surface-raised); box-shadow: var(--bevel-raised); }
32 .well { background: var(--surface-well, var(--surface-page)); box-shadow: var(--bevel-inset); }
33 .raised:active { box-shadow: var(--bevel-inset); }
34 ```
35
36 Those two custom properties are byte-identical to what both apps already
37 hand-write, which is asserted in the tests. Adoption removes duplicated lines
38 rather than changing a pixel.
39
40 `.raised:active` is the one thing this renderer gets for free: the cascade
41 carries a pressed state that an immediate-mode renderer resolves per call site,
42 eighteen of them in audiofiles.
43
44 ## Substitution, three ways
45
46 `Fill::Well` has no colour on makeover before 2.3.0, and the three renderers
47 answer that differently. That is the evidence that taking `Fill::fallback` out of
48 the description was right:
49
50 - `makeover-immediate` substitutes the page in Rust.
51 - `makeover-tui` refuses to substitute and draws an edge, because a terminal
52 quantises the two together.
53 - here, CSS already has the mechanism. `var(--surface-well, var(--surface-page))`
54 falls back in the browser and nothing in Rust decides anything.
55
56 ## Status
57
58 Unpublished, path dep on `makeover-layout`. No consumer yet; GoingsOn goes first
59 when phase A is adopted, since it holds the deletion test.
60
61 `cargo run --example dump` prints the stylesheet.
62
63 ## Licence
64
65 MIT.
66