Skip to content

Resolve cornerRadius refs from the radius scale first - #259

Merged
vicmaster merged 2 commits into
masterfrom
fix-radius-token-precedence
Nov 22, 2026
Merged

vicmaster merged 2 commits into
masterfrom
fix-radius-token-precedence

Conversation

@vicmaster

Copy link
Copy Markdown
Owner

A follow-up named in Phase 32 slice C's verify round (docs/specs/PHASE-32-SPEC.md), fixed as its own change.

The problem

lookupToken always read the spacing scale before the radius scale, whatever property the ref sat on. All four built-in presets define sm, md and lg in both scales, so under any of them cornerRadius: "$md" rendered the spacing value (16) instead of the radius value (8). The unknown-token rule saw a number token where a number belongs and stayed silent, and the README's own get_variables example (cornerRadius: "$sm") rendered 8 instead of 4.

What changed

  • lookupToken takes the property a ref sits on. On cornerRadius, as a single value or as array entries, it reads radius first and falls back to spacing. Every other property reads spacing first, as before.
  • The unknown-token rule's check for a token defined as another ref passes the property too, so it reads the same scale the renderer does.
  • The token-detachment lint already matched a literal corner radius against the radius scale and proposed cornerRadius: "$md". Under a preset, that fix used to render the spacing value. It now renders the value it matched.
  • The rule is stated in the README, docs/GUIDELINES.md, and the set_variables, workspace_set_design_system and project_set_design_system descriptions. The spec's note now records the fix.

Renders that move

A canvas that uses a preset's short names on cornerRadius gets smaller corners. Under the dark and light presets, $sm goes from 8 to 4, $md from 16 to 8, and $lg from 24 to 16; material and minimal move by their own radius values. Generated design systems name their tokens space-* and radius-*, which never collide, so canvases themed by generate_design_system or stamped from a scaffold render unchanged. No test's verdict moved.

Tests

  • New test/unit/test-radius-token-precedence.ts: under the dark preset, cornerRadius: "$md" resolves to 8, gap: "$md" to 16, a padding array to spacing values, a cornerRadius array to radius values, and a cornerRadius name defined only in spacing still resolves. It failed on master with 16 and the spacing array.
  • Full tier 149/149; the type check of src and test is clean; test-discoverability.ts 166/166.

lookupToken read spacing before radius, so under a preset that defines md in
both, cornerRadius "$md" rendered the spacing value (16, not 8). It now takes
the property: cornerRadius reads radius first, every other prop spacing first.
The detachment lint's radius re-attach fix now renders the value it matched.
@vicmaster
vicmaster merged commit 09ec388 into master Nov 22, 2026
3 checks passed
@vicmaster
vicmaster deleted the fix-radius-token-precedence branch November 22, 2026 23:01
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.

1 participant