Skip to content

Take Leaf's buttons and fields from Web Awesome's native styles - #5340

Merged
max-sixty merged 12 commits into
mainfrom
playground-controls-layout
Nov 4, 2026
Merged

max-sixty merged 12 commits into
mainfrom
playground-controls-layout

Conversation

@max-sixty

@max-sixty max-sixty commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

Leaf's word, symbol and committing presses, and its text fields and selects, now take Web Awesome's design from the installed library, as its radios and checkboxes already did. The build generates the rules from Web Awesome's native.css, so Leaf no longer draws these faces itself.

The user asked for a reasonable design from a UI library rather than looks of Leaf's own, and asked why Leaf copied the library's rules rather than referencing them. After seeing previews, they asked that words keep Leaf's quiet look, through the library's own tokens.

What changes on screen

  • Words (.lf-btn, authored .button) keep Leaf's muted ink and regular weight. Their side padding becomes the library's 1em, 12.5–14px, up from 10px. Under a hovering pointer they take the library's quiet fill, Leaf's field colour, where they took the chip and turned ink; the words stay muted. Symbols take the same fill.
  • Keyboard focus on a word or symbol shows Leaf's focus band alone. Before, it also laid the chip under the press.
  • The committing press (.lf-btn.lf-commit, authored .button.primary) is the library's outlined button in the brand variant: accent words under the softened accent hairline, with the tint under the pointer, on a clear ground rather than the card's.
  • Disabled controls fade to 0.5 with the not-allowed cursor, the library's pair, also for a press disabled through aria-disabled. surfaces.css's cue for every disabled control a widget offers moves to the same pair from 0.55 and the default cursor, and Send and Dictate, which keep their own muted face, take the same not-allowed hand. A disabled commit used to have a grey face of its own.
  • Fields and selects (.field, and inputs and selects with .lf-ui) keep their height. Their inner padding becomes 1em, up from 8px, and a select shows the library's chevron instead of Leaf's small drawn arrow, set in a neutral grey (the library's own grey turned violet on Leaf's warm grounds). An authored textarea.field takes the library's text box; Leaf's own text boxes, which grow with their words, keep theirs.
  • Radios and checkboxes look the same; the mark now changes at once instead of over the library's 150ms fade.

How the rules are generated

build/styles.mjs takes the "Checkboxes + Radios", "Buttons" and "Text Fields + Textareas + Selects" regions of native.css into one generated sheet, browser/styles/vendor/webawesome-native.css. That sheet replaces webawesome-choice.css. For each region, a map names the Leaf faces that the library's element types, classes and states stand for. For example, button becomes :is(.lf-btn, .button, .lf-icon-action), .wa-plain becomes :not(.lf-commit, .primary), .wa-outlined becomes :is(.lf-commit, .primary) and :disabled also matches [aria-disabled="true"].

lightningcss, already in the lock through Vite and now a pinned dev dependency, lowers the library's nesting and rewrites each selector through the map. The rewrite drops:

  • selectors that need an element no Leaf face is, such as input[type=file] or wa-icon, and a single-choice listbox (size over 1), which the library would draw as a closed select, so it keeps the browser's face;
  • declarations of type, outline and transition, since Leaf owns every control's font (surfaces.css), its focus band and its motion. The library's 75ms colour fades also reported a press's old colour to anything reading it mid-fade, which a test that reads a state just set caught;
  • one value: the select chevron's cool grey becomes a neutral grey (LEAF_SETS), since the library's grey blended to violet on Leaf's warm grounds. The build fails if the library stops writing that value.

Every generated rule weighs nothing (:where()), as the library's own sheet sits in its lowest cascade layer. shadow.css imports it after Leaf's defaults for every control and before controls.css, which now states only where Leaf departs from the library:

  • quiet words;
  • labels that wrap as the words around them do, and stay inline so an arrow keeps its space ("Next unchecked →");
  • fields a line tall wherever a surface sets its line (--lf-line), at their own width, on the card ground;
  • no hover fill under a finger;
  • the chevron on the left in right-to-left text, and the platform's control in forced colours;
  • no inset hover shadow on these faces, which the layer otherwise lays under an offered control, so a press a widget builds looks as an authored one does;
  • a symbol's grid laying out what it holds, such as the On me mark's symbol and count.

The radio region moves from @scope (.lf-choice, .choice) to the same map (input → :is(.lf-choice, .choice) > input). Leaf's [type] workaround against scope proximity goes with it.

#5329, which landed first, draws each role's face only in its role's rules and checks that no other sheet does (test_a_press_wears_its_role_s_face_alone). The generated sheet is now the second place a role's rules stand (FACE_HOMES): it holds the library's part of the word, symbol and commit faces, named by their face classes and narrowed only by states. #5329's variants (tones, discs, an open menu's chip, a pressed commit) stay in controls.css on top of the library's faces.

The library's tokens off Leaf

The generated rules read Web Awesome's tokens, so a page without Leaf that links portable.css drew its widgets' presses without a frame or padding (test_a_host_draws_each_widget_as_a_leaf_page_does). portable.css now carries Web Awesome's tokens and Leaf's values for them at the host's root, as it carries Leaf's tokens:

  • build/styles.mjs keeps only the theme's custom properties, its tokens. Its root colour, colour scheme and sans and its page-frame rules go, so base.css's rule reverting the first three goes too.
  • Leaf's values for the library's tokens move from components/webawesome.css into their own sheet, styles/webawesome-tokens.css, which shadow.css imports where the rule stood and portable.css places at the root.

Testing

  • leaf-dev stills against main for release-draft, trace-controls, notification-playground, hub-choice, command-hub, plan-panel, visual-review-gallery and command-reference-search, and trace-controls in the dark scheme. The differences are the ones listed above. The floating panel's filter tabs keep their one-line wrap, and plan-panel shows no pixel change.
  • A fresh reviewer read the captures and the code. Its findings are fixed here: the doubled hover (fill plus the layer's shadow), the On me mark's packed symbol and count, fields ignoring a local --lf-line, two disabled looks, the violet chevron, a build guard for selector arguments it can't rewrite, and stale comments. It confirmed the fixes and that a fresh build matches the committed sheets byte for byte.
  • A Firefox probe of the notification playground. A word reads muted at rest and under the pointer, weight 400, with the field fill on hover. A pressed toggle keeps its accent face under the pointer. The commit takes the tint on hover. A keyboard-focused word wears the 2px accent band.
  • test_a_pressed_quiet_action_looks_like_its_neighbour now compares the band as well as the ground, since visible focus no longer lays a fill, and test_a_control_a_widget_built_is_told_from_a_label_it_wrote expects the not-allowed hand on a spent control. Both pass, with test_a_tapped_button_looks_like_its_neighbour and the choice ring tests; the ring tests run in Chromium and Firefox.
  • test_plain_choices_stand_one_per_line_until_the_author_sets_columns, test_an_ordinary_page_is_drawn_as_written for every plain page, and test_each_control_archetype_holds_its_neighbours_still for playground-actions, shot-view and both visual-review archetypes.
  • test_a_host_draws_each_widget_as_a_leaf_page_does, the face checks in test_interact_layer.py (with the generated sheet as a home), and the Web Awesome typography and menu tests.
  • pnpm run check:tools, pnpm run check:browser (the generated sheets match the build) and the dependency-bundle publisher's tests. Stills after taking the theme's tokens only show no change of colour, colour scheme or font anywhere.

Known weaknesses

  • lightningcss 1.33's visitor hands optional fields over as null and refuses them back, so the build strips nulls before returning a rule.
  • The generated rules weigh nothing, so a theme package's element rule (button { … } in its defaults.css, which comes after Leaf's sheet in the same layer) now restyles Leaf's presses in the page, where Leaf's class-weight faces used to win. No bundled or installed theme has such a rule.
  • A host that uses Web Awesome itself now gets Leaf's values for the library's tokens at its root, below its own unlayered theme, which outranks them.
  • LEAF_SETS swaps one literal colour in the library's output; a library update that redraws the chevron in another grey fails the build until the entry is updated.

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

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR and #5329 change the same face rules in opposite directions, so merge order is a decision for you, and merging this one under yolo would make it for you:

  • #5329 makes a role's look come only from its role's rules in controls.css. Its check, test_a_press_wears_its_role_s_face_alone, refuses any rule outside controls.css that sets background/color/border/box-shadow on a role's control. This PR moves the word, symbol and commit faces into the generated vendor/webawesome-native.css. The check passes that sheet only because it skips every path under vendor, so after both land, much of a role's face sits in a sheet the check never reads.
  • #5329 deletes the .lf-msg-edit-actions > .lf-msg-control:is(:hover, [data-lf-focus]) fill in response.css. This PR rewrites that rule to a background-color that falls back to the library's tokens. Under #5329 it is the kind of rule the check refuses.

Whichever lands second has to reconcile both points, and the first needs a decision: either the generated sheet joins #5329's face check as a declared source of role faces, or the check states that the vendor map owns them. Apart from this overlap I found nothing to change. node build/browser/build.mjs --check reproduces the committed sheet, and the ring, tapped-button and spent-control tests pass locally (30 passed).

@max-sixty
max-sixty merged commit da934c9 into main Nov 4, 2026
4 checks passed
@max-sixty
max-sixty deleted the playground-controls-layout branch November 4, 2026 11:09
max-sixty pushed a commit that referenced this pull request Nov 7, 2026
…he shift watch hear it (#5675)

Since #5340 took Leaf's buttons from Web Awesome's native styles, a
pressed `.lf-btn` carries `transform: scale(.9875)` while it is
`:active`. After a touch tap, Chromium keeps that press on a timer for
about 100 ms past the pointer's last event. Two readings in
`test_on_a_phone_turning_on_s_tabs_moves_nothing` caught that window:

- **The assertion.** `panel_settled` returns inside the press window, so
the tab geometry the test reads can include the press's scale. The
failing reading is exactly that: the first tab's width goes 44.92 →
44.36 (× 0.9875), and x and y move by half the lost width and height.
Whether a read lands in the window depends on timing, which is why CI's
onset couldn't be bisected: the runtime speedups in
`b3c9842e8..6cd5093` let `panel_settled` return sooner. The test now
reads once no control in the panel's foot, where its tabs stand, is
`:active`. No tab actually moves when the views change.
- **The teardown error.** `shift_watch.js` only re-reads the page when
something announces a change. When the press lets go on that timer, no
event fires, so the verdict read found an unannounced change to the
tab's text (`shift watch missed a change to #text in
span.lf-fp-tab-words`). The watch now remembers the node a pointer
released on and announces the frame where its `:active` match changes,
which costs one `matches()` per frame. The header's "Unchanged frames"
list names the new source.

No product behavior changes; the press feedback stays.

Verification: on main, the floating-panel test fails locally every run
with the same numbers CI reports, and with this change it passed three
runs in a row. Each half fails without the other. The new
`test_a_tap_s_press_letting_go_is_heard` reports `shift-watch-missed`
without the watch change and passes with it. The shift-watch tests
matching press, tap, verdict and complete-readings (42) and the floating
panel's phone/tap/touch tests pass.

Closes #5653 — automated triage

Co-authored-by: leaf-agent <[email protected]>
leaf-agent added a commit that referenced this pull request Nov 7, 2026
…y's button padding (#5689)

#5340 moved Leaf's word buttons onto Web Awesome's side padding,
`--wa-form-control-padding-inline` (1em, so 12.5–14px), replacing a
fixed 10px. Two widgets reserve their room before they upgrade, and both
reservations still added a hard-coded 10px per side: lf-tally's
invisible "Next on me" placeholder, and the inset on lf-dial's measure
of its three radio labels. So each widget got wider once it upgraded
(the dial by 24px in a column page), and the widget-quality
`keeps-first-box` check failed. Both reservations now use the token. The
token is resolved in the same font as the control each one stands in
for, so the reserved box follows the library's padding and doesn't
hard-code a second copy of it.

The upgraded widgets look exactly as they did. Only the invisible box
before upgrade changes: it is now as wide as the control that replaces
it, so the widget no longer moves the content that follows it. For that
reason this PR has no before/after screenshots.


`tests/journeys/test_widget_quality.py::test_bundled_widgets_meet_the_widget_quality_checks[default]`
and `[detail]` (run with `--run-nightly`) fail on main `76c9c08fd` with
the messages in #5680 and pass with this change.
`known_widget_findings.py` is unchanged. No other `:not(:defined)`
reservation in `packages/` or `browser/styles` hard-codes the button
padding.

Closes #5680 — automated triage

---------

Co-authored-by: leaf-agent <[email protected]>
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