Skip to content

Name a page's Leaf controls by Leaf's own classes, so Leaf styles no class a page coins - #5865

Merged
max-sixty merged 2 commits into
mainfrom
author-class-prefix
Nov 12, 2026
Merged

max-sixty merged 2 commits into
mainfrom
author-class-prefix

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Leaf's kernel styled four generic classes on every page: .button (with .button.primary), .field, .choice and .scroll. A page that coined one of these names for its own design took Leaf's face or behaviour anyway:

  • The plain form fixture's own <label class="choice"> took Leaf's aim floor and inline-flex layout, which grew the form. test_plain_pages pinned this as the class-vocabulary obstacle.
  • A page's own .scroll box turned position: relative, took a fade mask and joined the keyboard stops.
  • Bulma, Foundation and similar sheets use .button and .field throughout, so pages built on them hit the same collision.

With this change a page takes a Leaf control's face by writing that control's own lf- name, and Leaf styles no class a page coins for itself.

Before After
class="button" class="lf-btn"
class="button primary" class="lf-btn lf-commit"
class="field" class="lf-field"
<label class="choice"> <label class="lf-choice">
class="scroll" class="lf-scroll"

How it works

  • One name per idiom. lf-btn, lf-commit and lf-choice are the classes Leaf's own controls already wear. Each face rule now names one class where it named a twin pair: :is(.lf-btn, .button) is now .lf-btn, and build/styles.mjs maps Web Awesome's native styles the same way. lf-field and lf-scroll are new; Leaf's own fields keep lf-ui and its own scrollers data-lf-scroll.
  • page check allows these classes and refuses every other lf- class. structure.AUTHORED_CLASSES reads the classes named in the kernel registry's idiom keys. The registry entries are renamed, and .lf-scroll gains an entry of its own; page-authoring.md described it, but no registry entry declared it. Only the kernel registry can grant an lf- class.
  • A test stops a generic class coming back. test_the_kernel_styles_no_class_a_page_coins holds the kernel's sheets and DOM queries to Leaf's names: lf-, the Layouts' layout- and density-, and the libraries Leaf draws for. It fails on main.

Calls you may reverse

  • Merging the page's names with Leaf's own. This reverses Give Leaf's own controls their own names where they wore an author's #5288's choice to give a page generic twins of Leaf's names. A page rule written for .lf-choice now reaches Leaf's own choice labels too, so page-layout.md tells authors to arrange their own controls by a class or id of their own. The alternative was a second author-facing name per idiom, such as lf-button beside lf-btn, with every rule still listing both. I chose one name per idiom.
  • Left as they are:
  • The portable sheet is unchanged. It still nests the kernel's shared sheet under the widgets' tags, because the native-control font rule is page-wide. Its large-host style cost therefore stays.

Verification

  • Probed in Chromium. On this branch, lf-btn, lf-btn lf-commit, lf-field, lf-choice and lf-scroll compute the same as button, button primary, field, choice and scroll on main. The probe compared font, ink, ground, frame, padding, floors, display, position, mask, gap, cursor, box size and the scroll mark. The old names on this branch now take the browser's defaults.
  • The plain-pages form case passes with its pin removed. tests/smoke/test_plain_page.py passes.
  • Focused tests:
    • model tests (layer, contracts, render gate, product): 593 passed;
    • pnpm run test:runtime: 935 passed;
    • the 17 browser tests whose pages use the renamed classes;
    • the choice, ring and theme tests in tests/browser/controls;
    • build/browser/build.mjs --check;
    • pre-commit.

This was written by Claude Code on behalf of max-sixty

https://claude.ai/code/session_01GQAnFBpRfi8Gh5cgPofNzs

…class a page coins

The kernel styled four generic classes on every page: `.button`
(with `.button.primary`), `.field`, `.choice` and `.scroll`. A page
that coined one for its own design took Leaf's face or behaviour
anyway. The plain form fixture's own `<label class="choice">` took
Leaf's aim floor and inline-flex layout and grew the form, which
test_plain_pages pinned as the `class-vocabulary` obstacle. A page's
own `.scroll` box turned `position: relative`, took a fade mask and
joined the keyboard stops. Bulma, Foundation and similar sheets use
`.button` and `.field` throughout.

A page now takes a Leaf control's face by writing that control's own
name:

- `lf-btn`, and `lf-btn lf-commit` for the committing action;
- `lf-field` on a text input or select;
- `lf-choice` on a radio or checkbox label;
- `lf-scroll` on a box the page's CSS scrolls.

`lf-btn`, `lf-commit` and `lf-choice` are the classes Leaf's own
controls already wear, so each face rule names one class where it
named a pair (`:is(.lf-btn, .button)` is now `.lf-btn`). `lf-field`
and `lf-scroll` are new; Leaf's own fields keep `lf-ui` and its own
scrollers `data-lf-scroll`.

The kernel registry declares the idioms under these names, and adds
`.lf-scroll`, which page-authoring.md described but no registry entry
declared. `page check` still refuses every other `lf-` class.
`structure.AUTHORED_CLASSES` reads the classes the kernel's idiom keys
name and leaves those to the author, so the refusal and the vocabulary
come from one list.

This reverses #5288's choice to give a page generic twins of Leaf's
names. A page rule written for `.lf-choice` now reaches Leaf's own
choice labels too. page-layout.md says to arrange your own controls by
a class or id of yours. Leaf no longer reaches a class a page coins
for itself, and `data-room` keeps its `data-lf-room` twin.

Each renamed selector keeps its specificity and matches the same
elements. Probed in Chromium:

- `lf-btn`, `lf-btn lf-commit`, `lf-field`, `lf-choice` and
  `lf-scroll` on this branch compute the same as `button`,
  `button primary`, `field`, `choice` and `scroll` on main, on font,
  ink, ground, frame, padding, floors, display, position, mask, gap,
  cursor, box size and the scroll mark;
- the old names on this branch now take the browser's defaults.

Leaf's own presses already wear `lf-ui-face`, so adding `.lf-btn` to
the control face's font rule changes none of them. The ink rule names
`.lf-field` alone, since the press face (Web Awesome's button rules)
sets every `lf-btn`'s colour later in the same tier.
`test_a_press_wears_its_role_s_face_alone` refuses a press's colour
set outside its role's sheets.

Other changes:

- The plain-pages `class-vocabulary` obstacle and the form fixture's
  pin go. The form case now passes.
- `test_the_kernel_styles_no_class_a_page_coins` holds the kernel's
  sheets and DOM queries to Leaf's names: `lf-`, the Layouts'
  `layout-` and `density-`, and the libraries Leaf draws for. It fails
  on main on `.scroll`, `.button`, `.choice`, `.field` and `.primary`.
- The reserved-markers test now writes the idiom classes beside one
  `lf-` class the author may not write.
- Examples, fixtures, evals, `leaf-dev pins` and the tests use the new
  names. The plain fixtures and the portable host test keep their own
  generic classes, which are now the page's own.
- The portable sheet still nests the kernel's shared sheet under the
  widgets' tags, since the native-control font rule is page-wide.

Claude-Session: https://claude.ai/code/session_01GQAnFBpRfi8Gh5cgPofNzs
@max-sixty
max-sixty merged commit 286ce93 into main Nov 12, 2026
5 checks passed
@max-sixty
max-sixty deleted the author-class-prefix branch November 12, 2026 06:26
leaf-agent added a commit that referenced this pull request Nov 13, 2026
…passes (#5924)

#5865 gave `.lf-scroll` its own entry in `browser/registry.json`, which
puts it in the idiom catalog that
`test_every_idiom_in_the_catalog_stands_in_a_corpus_source` holds to the
corpus. No authored source wore the class, so the test has failed on
every `ci` push run on main since that merge (`no example holds
.lf-scroll`). This adds an `lf-scroll` scenario to the feature gallery's
**Page & layout** view: a request timeline wider than the page, in a box
whose own CSS sets `overflow-x: auto`. That is the idiom's intended use
(`page-authoring.md`), and the gallery is where `examples/AGENTS.md`
puts core-feature scenarios. The gate stays as it was.

![The new gallery section, focused and scrolled by the arrow
keys](https://github.com/user-attachments/assets/822c6b34-cd69-4ae4-8728-4e3ef953fd37)

**Verification**

- The gate test fails on `7acf9d5ce` and passes with this change.
- In Chromium, with the Page & layout tab open, Leaf lends the box a tab
stop (`tabindex=0`) and marks `data-lf-more-after`. After focus and two
ArrowRight presses it has scrolled (`scrollLeft` 0 → 80) and carries
both `data-lf-more-before` and `data-lf-more-after`.
- `tests/model/test_product_page.py` and `test_interact_product.py`
pass, and so does `leaf page check` on the gallery preview (its one
advisory, `measurement-lag` on `bg-latency`, was already there).
`--render` couldn't launch Chrome in this sandbox, so it didn't run.

**One thing to look at in #5865's registry entry:** its `x-example` puts
`<svg width="1600">` in an `lf-scroll` box. Leaf's own `img,
svg:where(:not([data-lf-icon])) { max-width: 100% }` fits that SVG to
the box, so the box as written never overflows. This scenario adds
`max-width: none` to its SVG for that reason. The example or the
description may want the same note. I left the registry alone here,
since that wording belongs to #5865's author.

Closes #5914 — automated triage

Co-authored-by: leaf-agent <[email protected]>
leaf-agent added a commit that referenced this pull request Nov 13, 2026
The `.lf-scroll` registry example added in #5865 never scrolled: its box
had no `overflow-x: auto`, and [`base.css`'s media fit
rule](https://github.com/max-sixty/leaf/blob/5606fc2c96d1d33e9988e5e4d49bd0720ce7e8e7/browser/base.css#L772-L777)
shrank its 1600px SVG to the box's width. An agent copying the example
got the class with no tab stop and no continuation cues, and nothing
reported it. The example now sets `overflow-x: auto` on the box and
`max-width: none` on the SVG (an inline declaration, which outranks the
fit rule's selector), and the registry description and
`page-authoring.md`'s `lf-scroll` paragraph say that media inside the
box has to opt out of the fit rule.

This takes the first of the two settlements #5929 lists and leaves
`base.css` alone. The other — exempting `.lf-scroll`'s media from the
fit rule — would make the idiom work without the opt-out, and its
failure (a box missing `overflow-x` spilling sideways) is one the render
gate already refuses, whereas the current failure passes silently. It is
still open as a product choice; if a maintainer takes it, the sentence
added here comes out with it.

**Verification:** the vocabulary, layer-contract and layer interaction
tests (259) pass, and prettier/typos pass on both files. Chrome can't
start in this sandbox (it can't open a unix socket), so I couldn't
render the example; the claim that it overflows rests on the cascade
above. #5924 confirmed in Chromium that a gallery box with the same
`max-width: none` opt-out scrolls and gets Leaf's tab stop and cues.

Closes #5929 — automated triage

Co-authored-by: leaf-agent <[email protected]>
max-sixty added a commit that referenced this pull request Nov 16, 2026
…or every choice

The previous commit made a choice a grid of its label's children so its
words, not its mark, gave it its baseline. Each run of words and each
element inside them became a cell of its own, though, so a label holding
markup, such as "Use <strong>high quality</strong> for this image",
wrapped each part in its own column: in a 220px box "image" broke under
"for" rather than under "Use". With a tight line-height the words stood
at the top of a row the taller mark set, 2 to 2.5px above the mark's
centre, and a package's own grid of a choice's parts, the command
reference's setting, fought the grid's column flow.

Now everything after the mark is one run of words laid out as a
paragraph, and the mark is floated into the label's start padding,
centred on the first line and taking none of the words' room. A wrapped
line starts under the first, a wrapped label's mark stands by its first
line rather than between its lines, and the words still give the choice
its baseline in Chromium, Firefox and WebKit, checked or not, left to
right or right to left. The start padding holds the mark, so a package
changes the room around it through `--lf-choice-pad` and
`--lf-choice-gap`, never `padding` or `gap`. A playground toggle, a lone
mark, stands centred in its target as a small grid; the command
reference's setting keeps its own grid and drops the mark's room from
its padding.

The gap between mark and words took four values, 3.5px in a playground
rail, 4px in its cards, 7px in visual review and 8px in the command
reference. It is one theme token now, `--lf-choice-gap`, half the em of
the choice's type as Web Awesome spaces its own radios, and the
screenshot's pixel key reads it to line its words up with the choice
above it.

A rich playground candidate is a card whose head is the choice's label,
padded nowhere at its foot, so the label's focus ring ran through its
words and doubled the card's border. The card wears its radio's ring
now, as an lf-options row does.

The screenshot's Full frame and Outline changes choices wore the
browser's own checkbox: #5865 renamed `.choice` to `.lf-choice` and
missed the class `shot-view.js` passed to `offered()`. They wear Leaf's
choice face again.

The choice test adds a label holding markup that wraps, and checks that
each line starts under the first; it fails on the grid. A fresh reviewer
read captures of every choice surface; the gap, the card's ring and the
pixel key came from that read.

> _This was written by Claude Code on behalf of max-sixty_
max-sixty added a commit that referenced this pull request Nov 16, 2026
…keep a tall playground rail's actions whole (#6110)

An authored radio or checkbox (`<label class="lf-choice">`, the markup
page-layout.md gives authors) took its baseline from its mark's foot, so
a legend, a sentence or the next choice beside it stood 2.5–4px below
the choice's words, and a checked mark's dot raised that baseline a
border, so every selection moved the radios. A choice was also a row of
its label's parts, so a label holding markup ("Use <strong>high
quality</strong> for this image") wrapped each part in its own column.
Now everything after the mark is one run of words laid out as a
paragraph, the words give the choice its baseline, and the mark hangs in
the start padding, centred on the first line. The playground rail,
bounded to the window, ran its bar of actions past its foot at 1728×999;
its controls now give up that height and scroll in their pane, and the
bar stays whole.

To weigh: the gap between mark and words is one theme token,
`--lf-choice-gap`, half the type's em as Web Awesome spaces its radios,
where it took four values (3.5–8px). Packages set the room around a mark
through `--lf-choice-pad` and `--lf-choice-gap`, since the start padding
holds it; four of Leaf's own did. Under a coarse pointer the iOS
text-field type floor no longer reaches radios and checkboxes, so their
marks keep their label's size. A rich playground card wears its radio's
focus ring, which ran through its words, and the screenshot's options
choices wear Leaf's face again after #5865's rename missed them.

The user asked for this on a Leaf page. A fresh reviewer read captures
of every choice surface, and Codex reviewed the first round's diff.

Tests: the choice test checks the selection holds the face still, the
words' baseline and a wrapped label holding markup; a new test holds a
rail taller than the window. Each fails on main.

> _This was written by Claude Code on behalf of max-sixty_
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.

2 participants