Repository navigation
Generate the choice mark from Web Awesome's native styles instead of copying them - #5247
Conversation
…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
left a comment
There was a problem hiding this comment.
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.
…er reach the .choice root
.choicecarried a hand copy of the radio and checkbox rules from Web Awesome'snative.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.cssis 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.mjswrites that section tobrowser/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.cssimports the generated sheet just beforecontrols.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.csskeeps only Leaf's adjustments, 28 lines in place of 72 copied ones:@scope, a selector without:scopematches only below the root, so the region'slabel:has()rules never style the.choicelabel itself and reach only the mark;A scoped rule outranks an unscoped one of equal specificity, so each adjustment's selector carries one extra attribute.
Testing
leaf-dev stillsagainst 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.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:browserandpnpm 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.