-
Notifications
You must be signed in to change notification settings - Fork 1
feat(tokens): add --sf-density control-geometry dial #615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment (and matching prose in
docs/llm-guide.mdanddocs/token-annotations.json) states that a nested--sf-densityoverride "does not retroactively rescale" the--sf-size-*ladder. This is incorrect. CSS custom property values are token streams that are substituted lazily at used-value time in each element's own cascade context — the same mechanism used by--sf-space-scaleinline in the space tokens. A descendant element with--sf-density: 0.8set on it inherits the token streamcalc(2.5rem * var(--sf-density))for--sf-size-m; when CSS resolvesvar(--sf-size-m)for that element,var(--sf-density)is looked up in that element's context → 0.8, giving 2rem. The behaviour the PR says was "verified" (no rescale) only holds when reading the size from the parent element after setting density on a child — the child and its descendants do see the rescaled value. Documenting this as strictly:root-only misinforms developers who would benefit from component-level density control, which actually works by design.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked this carefully before pushing the "does not rescale" claim, and re-verified it again just now — the documented behavior is correct, and this comment describes a plausible-sounding but incorrect mental model of custom-property substitution.
The key detail:
var()substitution inside a custom property's own value happens at the element where that custom property is declared (or wins the cascade), not lazily re-evaluated per consuming descendant.--sf-size-m: calc(2.5rem * var(--sf-density))is declared once, at:root. Chromium resolvesvar(--sf-density)there (→1) and the already-substituted token stream (calc(2.5rem * 1)) is what inherits down — not the originalvar(--sf-density)reference. A descendant overriding--sf-densitydoes change its owngetComputedStyle(...).getPropertyValue('--sf-density'), but--sf-size-mon that descendant still readscalc(2.5rem * 1), because it was never re-declared in that scope.Verified two ways just now:
<div class="child" style="width:var(--derived)">→ computed width is 10px, not 50px.dist/slashed.full.csswith--sf-densityon a scoped<aside>.This isn't a novel claim either — it's the exact same phenomenon
core/layout.cssalready documents for--sf-fluid-width(see the.sf-fluid-cqcomment): "the--sf-text-*/--sf-space-*tokens are computed at:root, so theirvar(--sf-fluid-width)is substituted there... overriding--sf-fluid-widthlower in the tree can't retroactively rewrite an already-computed inherited value."--sf-densityhas the identical resolution shape, so the identical caveat applies.If someone genuinely wants scoped density, the fix mirrors
.sf-fluid-cq: re-declare the--sf-size-*ladder (not just--sf-density) on the scoping element's children. That's a real, addressable feature gap, but documenting today's behavior as "already works by design" would be inaccurate and would mislead people who try<aside style="--sf-density: 0.8">expecting it to work. Keeping the current wording.Generated by Claude Code