Skip to content

feat: token() on background + gradient stops (Phase 2d, partial) - #93

Merged
kiyeonjeon21 merged 4 commits into
mainfrom
feat/design-tokens-2d
Jun 22, 2026
Merged

kiyeonjeon21 merged 4 commits into
mainfrom
feat/design-tokens-2d

Conversation

@kiyeonjeon21

Copy link
Copy Markdown
Owner

Closes the two silent footguns from the 2d investigation: background: token("color.bg") and $ref gradient stops used to misrender silently (invalid color string → no/garbage paint). Now they resolve. Numeric/type tokens (which need IR type-widening) are deliberately left for later.

What

  • Scene background — background: token("color.bg") resolves at compile (CompiledScene.background); renderer-canvas + preview read it (compiled.background ?? compiled.ir.background).
  • Gradient stops — a $ref in a ColorStop.color resolves in evaluate against CompiledScene.effectiveTheme. Gradients bypass the value path (static objects), so resolveGradient returns the same object when no stop is a token → non-token scenes byte-identical.
  • No type-widening — both slots are already string-typed, so token() just works there.

Golden-safe

No design/$ref → effectiveTheme is brand, resolveGradient is identity, background is the literal → byte-identical IR/DisplayList. The 6 golden snapshots are unchanged (verified).

Demo

themed-card.ts now uses background: token("color.bg") and a gradient accent bar with token stops, so --theme / a design.* batch column re-skins the background and gradient too.

Verification

  • pnpm test — 446 pass (442 + 4 new: background resolve/literal, gradient-stop resolve, gradient identity-preserved); goldens byte-identical; typecheck + lint clean.
  • reframe frame themed-card.ts --t 1 vs … --theme examples/themes/ocean.json differs (bg + gradient re-skinned).

Out of scope (later)

Numeric / type tokens (fontSize: token(...)) — needs number | TokenRef widening across the numeric style props.

🤖 Generated with Claude Code

kiyeonjeon21 and others added 4 commits June 22, 2026 23:24
Extends design-token resolution past color props to the two other slots where a
token would otherwise misrender silently. `background: token("color.bg")` resolves
at compile (exposed as CompiledScene.background; renderer/preview read it). A
`$ref` in a gradient stop resolves in evaluate against CompiledScene.effectiveTheme
— gradients are static objects that bypass the value path, so resolveGradient
returns the SAME object when no stop is a token, keeping non-token scenes
byte-identical. No type-widening needed (both slots are already string-typed).
Numeric/type tokens (IR widening) remain a later phase.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…okens

The scene background is token("color.bg") and the accent bar is a gradient whose
stops are tokens, so --theme / a design.* batch column re-skins them too.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Fixes the CI typecheck (op.fill on the DisplayOp union); runtime behavior
unchanged. Use `"fill" in op` narrowing instead of a bare property access.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mintlify

mintlify Bot commented Jun 22, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
reframe 🟢 Ready View Preview Jun 22, 2026, 2:28 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@kiyeonjeon21
kiyeonjeon21 merged commit ad116ed into main Jun 22, 2026
1 check passed
@kiyeonjeon21
kiyeonjeon21 deleted the feat/design-tokens-2d branch June 22, 2026 14:30

This branch was successfully deployed

1 active deployment
staging - docs — 5e5c6aa3 Deployed Jun 22, 2026 by mintlify[bot]
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