Skip to content

style hooks S2: web tags parts as-<finish>, finish CSS, worn.json (#399) - #431

Merged
jirathip-k merged 5 commits into
stagingfrom
issue-399
Nov 28, 2026
Merged

jirathip-k merged 5 commits into
stagingfrom
issue-399

Conversation

@jirathip-k

@jirathip-k jirathip-k commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Closes #399

Slice S2 of the style-hooks ADR (docs/architecture/style-hooks/adr.md, decision parts 2, 4, 6 and 7).

For humans

Nothing on screen changes: every look draws exactly as before.
The parts a look restyles (tiles, tinted chips and step marks, the labels) now carry a public name in the page, so an app's stylesheet can style them, and a look setting can only reach parts by those names.
A new check proves each look setting actually changes the parts it names, and a list records the few settings that change nothing in the browser today.

What changed

  • The three HTML writers (live HTML web/src/render, React web/react/src, the crate's site writer) tag parts as-<finish>, exactly the parts the old private selectors reached: as-surface (cards, chart/plot/boxplot/heat cards, stat tiles, a list's own rows, a form with no submit, config, choice, secret, run, table, the timeline's draw ghost, the shell's sheet-list rows), as-tint (a chip while on, a done step mark), as-mark + data-mark="done", and the label finishes (header, section, title, button, chip, picked, screen).
  • Finish::selector is now the class (.as-surface, …); button stays the button/a.btn elements. marks: text writes content:attr(data-mark), so the word "done" is gone from the crate's CSS. sections: quiet has rows on both header and section labels (the section's h3 is a header label only, per shapes.md §3).
  • web/src/css/look/tiles.css → look/surface.css: its 9-selector list is now .as-surface.
  • fixtures/look/worn.json (generated by just gen from the site's HTML of every fixtures/blocks and fixtures/fields file): each kind's finishes, and each style value's finishes. Codegen fails on an as- class that is no worn finish.
  • blocks-shot reports what it drew: report.json gains worn (kind → finishes); tree::Report gains the optional field.
  • The look check's new fact look: <axis> <value> changes no <finish> (web/shot/look.ts unchanged), measured on the kinds page plus steps, a scene, a button and a picked diagram; its forced-defect test pins the surface and sees surface dashed/surface solid fail.
  • ci/tokens/finishes.txt: the first web lines (fills solid, labels back|group|kind|said); the measured test holds the fact list to exactly these lines.
  • web/lint.mjs fails an .as-<x> that is no finish (fixture web/lint-fixtures/unknown-finish.css).
  • .drover/arch.toml: S2's generated line and the gen/schemes ban from the ADR; arch-baseline.txt 673 → 679.

For apps: parts now carry as-<finish> classes an app's CSS may style (owner's answer to open question 1); labels.section no longer reaches a section's header (labels.header does, as before). The harness Report gains an optional worn. No wire or style.json change.

Decisions

  • surface.css selects .as-surface.as-surface: two classes keep the old :is(…) list's specificity, so kind rules that lost to it today (.card.accent, .row.sticky, .imp>.tbl, .tmgh.st) still lose. One class would change those pixels; that is S5's call.
  • A list's rows: the live HTML list tags its .row/.rw children and a MutationObserver tags rows a patch redraws or inserts (the old .list>.row selector did this for free); React passes the list's rows through a Tiles context; the site writer marks a list's direct children. look.test.ts now asserts a patched list keeps its tiles; it fails with the observer removed. web/test/dom.ts gets an inert MutationObserver.
  • Only surface.css was added under css/look/: the other finishes' base declarations differ per kind today and moving them changes specificity; S5 owns that.
  • No only-shrinks gate on finishes.txt yet: it would refuse S3's swift lines. The measured test already pins the web lines to the facts.
  • worn.test.ts allows live-only extras: buttons of controls the static site does not write (table, timeline, tool) and the timeline's draw ghost; site.test.ts compares as- elements too, skipping the ghost and the lazy import chunk's inside.
  • src/ net +190 (budget +40): the worn generator (≈95) and the finish fact (≈45) are bigger than the README's estimate; no other path makes either.

Evidence (head 7e4e263, after merging origin/staging 5c8bbc8; pixel run at 8f0086c, whose renderers and CSS these merges leave as they were)

  • Pixel run: every fixtures/blocks file (54) under every fixtures/styles file (filled, modern, still, terminal), HTML and React adapters, 390×844, animations frozen (*{animation:none;transition:none} on both sides): 432 PNGs at base 5851193 vs 432 at head; 431 byte-equal, 1 (still/html/heat-sleep) differed, and head's equals two later redraws of base (base's first draw was the odd one: run-to-run dot-grid flake). Without freezing, the only differences were the spinning ↻ in tool and table-ot.

  • node --test test/measured.test.ts test/worn.test.ts → exit 0 (5 pass, incl. the finish fact and its forced defect)

  • node --test test/site.test.ts test/axes.test.ts test/look.test.ts → site/render parity, axes, look pass; "the fixture site is the same PNG … before and after blocks.js" fails here and fails identically on untouched base (local, pre-existing)

  • node --test web/react/test/markup.test.ts → exit 0 (new case: a list of plain, swiped, linked rows and a card's row; a picked chip)

  • node --test --test-name-pattern "one --plan launch, each run" test/shot.test.ts → exit 0

  • cargo test -p blocks --no-fail-fast → all pass after updating 5 tests that pinned old markup

  • cargo clippy -p blocks -p blocks-desk --features blocks/schema -- -D warnings → 0; cargo check -p blocks-desk --tests → 0

  • sh scripts/gen.sh → 0 (worn.json regenerates byte-equal); npm run lint → 0; tsc --noEmit → 0; scripts/lint-fixtures.sh ts → 0 (unknown-finish refused, clean passes); cargo fmt --check → 0; drover arch-check → 0 violations

  • After the staging merge (new glance kind; fixtures/html/glance*.html and worn.json regenerate with its row title's as-title-label): sh scripts/gen.sh → 0; cargo test -p blocks --no-fail-fast → 0; node --test test/worn.test.ts test/measured.test.ts react/test/markup.test.ts → 0; site/render parity test → 0; lint, tsc, fmt, arch-check (713-line arch.toml baseline) → 0

  • At head 3ef710f (merged origin/staging e1aa341, the table spark column): rebuilt web/dist with npm run build → exit 0 (the dist conflicts are build output); sh scripts/arch-gen.sh → exit 0, regenerating fixtures/html/table-trend.html with the table's as-surface (worn.json unchanged); drover arch-check → 0 violations after that; npm run lint → 0; cargo fmt --check → 0

  • CI's red local/web at 2974ca6 was kind tests pinning pre-S2 class lists (secret, config, scene); updated to the as- classes. node --test test/kind/*.test.ts test/worn.test.ts test/hooks.test.ts → 106 pass, 1 fail: the browser-driven React search typing test lost its report under host load; rerun alone (--test-name-pattern "in HTML and React" test/kind/search.test.ts) → exit 0, 3 pass

  • At head 7e4e263 (merged origin/staging 5c8bbc8, chart money): the conflicts in fixtures/html/chart-targets.html and web/dist/blocks.js are generated; npm run build → 0 and sh scripts/arch-gen.sh → 0 rewrite them (the chart card gains as-surface, nothing else); node --test test/kind/chart*.test.ts → exit 0, 2 pass; npm run lint → 0; cargo fmt --check → 0

# Conflicts:
#	.drover/arch-baseline.txt
#	web/dist/blocks.js
#	web/dist/import.js
#	web/dist/play.js
# Conflicts:
#	web/dist/blocks.css
#	web/dist/blocks.js
#	web/dist/blocks.scoped.css
#	web/dist/react.js
# Conflicts:
#	fixtures/html/chart-targets.html
#	web/dist/blocks.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant