Repository navigation
Conversation
A `Style` gains a `Sheet`: for each part of a widget (a `Part` enum with a `data-slot` string), rules `(When, Tw body, layer)`. `Sheet::resolve` merges the rules whose keys hold, lowest layer first, later winning per property; `replace` drops what is below it. `When` asks for variant, size, attribute, ARIA state, and their negations (`not_aria`, `not_attr`); `Aria` gains `HasPopup`. Layers: defaults, preset, app, scope, ancestor, call site, important; the writer's layer is set by whoever hands out the sheet (`as_preset`, `as_app`, `Builder::styled` for scope). `Builder::part` resolves a part's classes (memoised per build, as a `Tw` is not `Send`) and returns them as the base of the node's own classes; the rules of the containers above now go between that base and the call site (`Rules::apply_layered`), as CSS gives shadcn's `[&_svg]:size-3` over an icon's default but under a caller's explicit class. A node with no sheet is built exactly as before. In debug builds a `Tw` records which class, in which layer, set each property (`Tw::origin_of`): every class method is `#[track_caller]`, and the property list now names box paint and text properties too. Release builds carry none of it. Behavior changes: none for existing widgets (no widget is on the sheet yet). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AJYxo4YJZUXcPJ1bHdAHKy
Owner
Author
|
Approved by the user on its tests and bench (2026-11-20). GitHub's required checks pass on the branch merged with current main. Merging. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #443 (epic #446),
SheetPR 1 of the approved note. No widget is on the sheet yet.What it adds
Part(Base UI names,data-slotstring,SOURCE),Key(variant, size, attr, aria, and negated attr/aria),When(up to four keys;not_aria,not_attr),Aria::HasPopup.Sheetas a field of coreStyle:rule,replace,resolve,keys. The preset constructor (Shadcn::style) hands out the sheet at the preset layer, so the light and dark halves each carry their own.as_preset,as_app, andBuilder::styledfor scope.Builder::part: resolves a part's classes and returns them as the base of the node's own classes (merge the call site over them). ReportsMissingStyleEntryfor a variant or size the sheet names others of but not this one.Rules::apply_layered); a node with no sheet takes the old path unchanged.Tw::origin_of(Property)gives the layer and source (Rustcall site, orShadcnfile/line/class viaTw::sourced) of each property's winner. Every class method is#[track_caller]; the property list now names box paint and text properties too. Release builds carry none of it (Twstays 840 bytes there).Where it differs from the note
Sheet.taffy::Styleholds a*const (), so aTwis notSend, and aStylemust be (it lives in egui's data). The sheet therefore stores each rule's body as anFn(Tw) -> Tw + Send + Sync, andBuilder::partmemoises by (sheet version, part, keys) inBuildState.Sheet::resolveitself runs the bodies (for tests and tools).b.part(..)returns the base already layered, so the widget just merges its call site over it. No second builder entry was needed, and every existing entry point accepts it.replacedrops every lower rule that holds with it (the note's "start empty"), not only same-keyed ones.why(PR 2). Nodes do not keep their origins yet;Twdoes.hover:and the like) yet.Cost
Interleaved bench binaries (main at the base vs this branch), 4 rounds:
gridandtextbuild, 100 and 1,000 nodes: no slower (this branch 2–4 % faster, within layout noise).rulesscenario (own classes vs rule): unchanged.sheetscenario (1,000 buttons, layout phase): own classes 5.05 ms, sheet part 5.35 ms, +6 %, from the layered apply, merge and memo clone per node.Tests
tests/it/sheet.rs(through the real builder): keys, call site over sheet, ancestor rules between, slot matching, layer order,replace, the missing-variant report, negated keys, preset layer. Unit tests for provenance, merge, layered apply andSheet. Clippy, fmt and the full workspace tests pass; the release-gates profile compiles clean.🤖 Generated with Claude Code
https://claude.ai/code/session_01AJYxo4YJZUXcPJ1bHdAHKy