Skip to content

Generate the choice mark from Web Awesome's native styles instead of copying them - #5247

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

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

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

.choice carried a hand copy of the radio and checkbox rules from Web Awesome's native.css (#5230). The build now takes that section from the installed package, the way it already generates the library's theme sheet, so a Web Awesome upgrade carries any change to those rules.

native.css is one sheet meant to restyle the whole page: headings, lists, tables, buttons and every input. Loading it would restyle every Leaf page, so the build takes only its "Checkboxes + Radios" section.

Changes

  • build/styles.mjs writes that section to browser/styles/vendor/webawesome-choice.css, scoped to .choice. An optional third member of a style entry names the section and the scope. If the section is renamed or removed, the build fails rather than shipping an empty sheet. The dependency publisher's list of generated sheets picks up the new output unchanged.

  • browser/shadow.css imports the generated sheet just before controls.css, in the same layer. Imported into a lower layer, it lost to Leaf's :where() input defaults: .lf-ui-face's ink turned a checked radio's dot and a checkbox's tick ink.

  • controls.css keeps only Leaf's adjustments, 28 lines in place of 72 copied ones:

    • the mark sized to the label's text;
    • the library's default control outline, in place of Leaf's lighter field border;
    • a disabled choice fading as a whole, as the library's own label does. Inside @scope, a selector without :scope matches only below the root, so the region's label:has() rules never style the .choice label itself and reach only the mark;
    • the platform control in forced-colours mode.

    A scoped rule outranks an unscoped one of equal specificity, so each adjustment's selector carries one extra attribute.

Testing

  • leaf-dev stills against Draw Leaf's radios and checkboxes in Web Awesome's design #5230, for ten states with radios and checkboxes (playground, quoted playground, visual review, command reference, lf-shot options, settled options). There are no pixel differences. The only computed differences are the inputs' own line height, plus the font of the command reference's checkbox; neither draws any text.
  • A disabled choice computes the same as in Draw Leaf's radios and checkboxes in Web Awesome's design #5230 in Firefox: the label at 0.5 opacity with a not-allowed cursor, the mark inside it unfaded.
  • Twelve Firefox captures of the comparison page, light and dark, at rest, hovered and focused, match Draw Leaf's radios and checkboxes in Web Awesome's design #5230's exactly.
  • test_plain_choices_stand_one_per_line_until_the_author_sets_columns, test_an_ordinary_page_is_drawn_as_written[form] (its known class-vocabulary pins are unchanged), test_each_control_archetype_holds_its_neighbours_still[visual-review-approval], pnpm run check:browser and pnpm run test:browser.

A Web Awesome upgrade that changes these rules now changes Leaf's look by itself. The dependency PR that regenerates the sheet is where that shows.

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

…copying them

`.choice` carried a hand copy of the radio and checkbox rules from Web Awesome's
native.css. The build now takes that region from the installed package into
browser/styles/vendor/webawesome-choice.css, scoped to `.choice`, the way it already
generates the library's theme sheet, so a Web Awesome upgrade carries its changes and a
moved region fails the build. controls.css keeps only Leaf's adaptations: the mark
sized to the label's type, the library's default control border, selectable label
words, a single fade when disabled, and the platform control in forced colours.

The generated sheet sits in Leaf's base layer before controls.css, so it outranks
Leaf's `:where()` input defaults (`.lf-ui-face`'s ink had turned a checked radio's dot
and checkbox's tick ink). Being scoped, it also outranks unscoped rules of equal
weight, so the adaptations weigh one attribute more than the library's.

Stills of ten states with radios and checkboxes match the copied version pixel for
pixel in Chromium, and twelve Firefox captures in light and dark match it exactly.

@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.

A disabled choice no longer fades. Inside @scope (.choice), a selector without :scope or & gets the scoping root and a descendant combinator prepended (css-cascade-6: p matches the same elements as :scope p). So the library's label:has(input[type='checkbox']) rules only reach labels inside a .choice, never the label.choice root. Its &:has(:disabled) { opacity: 0.5; cursor: not-allowed } never applies to the label. The diff removed .choice:has(> input:disabled), and &:disabled { opacity: 1 } cancels the library's fade on the input, so nothing fades a disabled choice now. Visual review's "Looks right" checkbox (?disabled=${!available} in lf-visual-review.js) looks exactly like an enabled control, with the label's pointer cursor. None of the stills in the testing list shows a disabled choice, which would explain why no pixel changed.

The same thing breaks two claims. The description says the library's label rules (form-control ink, fit-content width) now apply to .choice, but they don't. And label.choice:has(> input[type]) { user-select: auto } overrides a rule that never matches. The suggestions below put the label fade back and correct the header. The description's "library's label rules now apply" paragraph should go too.

Comment thread browser/styles/components/controls.css Resolved
Comment thread browser/styles/components/controls.css Resolved
@max-sixty
max-sixty merged commit 22cb320 into main Nov 3, 2026
6 checks passed
@max-sixty
max-sixty deleted the playground-controls-layout branch November 3, 2026 21:45
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