Skip to content

Design tokens in the inspector: chips, color-picker palette, oklch fix (v0.3.1) - #133

Merged
rezailmi merged 7 commits into
mainfrom
advisor/023-025-token-feature
Jun 26, 2026
Merged

Design tokens in the inspector: chips, color-picker palette, oklch fix (v0.3.1)#133
rezailmi merged 7 commits into
mainfrom
advisor/023-025-token-feature

Conversation

@rezailmi

Copy link
Copy Markdown
Owner

Surfaces the design token / CSS variable behind each inspector value (Figma-style), adds a token palette to the color picker, and fixes oklch color parsing. Bumps to 0.3.1.

What's in it (plans 023–028)

  • 023 Design-token / CSS-variable resolution layer (pure, unit-tested): scans :root / @theme / shadcn vars, resolves alias chains, maps Tailwind color classes → vars.
  • 024 Color rows show the bound CSS variable as a chip; clicking opens a Figma-style popover (alias chain + resolved value + editable hex/alpha). Raw-input fallback preserved when no token.
  • 025 Typography rows show the Tailwind utility (text-base, font-semibold, leading-7…) instead of raw px/weight; raw fallback otherwise.
  • 026 Fix parseColorValue for oklch()/lab()/lch()/color() — rasterize a pixel instead of round-tripping fillStyle (Chrome returns oklch unchanged). oklch is the default for Tailwind v4 / shadcn, so this was breaking all oklch swatches.
  • 027 Token palette in the color picker; picking a token binds via var(--token) (not a flattened hex), so the chip persists and the agent gets the token. Editing the HSV detaches.
  • 028 Polish: alpha-aware token binding (color-mix), shadcn @theme inline resolution via the generated utility rule (varForClassRule), parseColorValue dedup, version bump.

Verification

  • tsc --noEmit clean; 667 tests pass (48 files).
  • Browser-verified on the dev harness: oklch swatches show real colors; the Variables palette renders; picking --color-brand wrote var(--color-brand); @theme inline tokens (--muted-foreground) resolve via the class rule.

Notes

  • dev/ token harness is dev-only (not in the published tarball: files = dist/README/LICENSE).
  • One documented, unreachable edge case from the parser dedup: percentage-channel rgb(100% …) (never emitted by getComputedStyle).

Publish (made-refine@0.3.1) is a separate manual step after merge: gh workflow run publish.yml --ref main -f task=release -f npm_tag=auto.

https://claude.ai/code/session_01JzitXiMcdedyPbH4wqkXqX

rezailmi added 7 commits June 26, 2026 17:40
Introduce src/utils/design-tokens.ts: a pure, unit-tested layer that
collects theme variables from document stylesheets, resolves var() alias
chains textually, builds a color-token index, maps Tailwind color/typography
utility classes back to their CSS variables, and reverse-maps resolved
colors to the best-matching token. Re-export the public API from the
src/utils.ts barrel.

Claude-Session: https://claude.ai/code/session_01JzitXiMcdedyPbH4wqkXqX
Add a shared TokenChip pill (shadow-DOM-safe base-ui popover) and make the
inspector's color rows token-aware. ColorInput now shows the bound CSS
variable (resolved via plan 023's resolveColorToken) with the hex/alpha
editors moved into a detail popover; rows fall back to the existing hex/alpha
inputs when no token binds. Thread elementInfo.classList into the fill,
background, and border sections and invalidate the color-token index on
selection change.

Claude-Session: https://claude.ai/code/session_01JzitXiMcdedyPbH4wqkXqX
Make the font-size, line-height, letter-spacing, and font-weight rows of the
Text section token-aware. A new TypographyField wrapper shows the attributed
Tailwind utility (text-base, leading-7, font-semibold, …) via the shared
TokenChip from plan 024, moving the raw editor into the chip popover; rows fall
back to today's controls when no utility is attributed. Resolution reuses
typographyTokenForProperty from plan 023; classList is threaded from the panel.

Claude-Session: https://claude.ai/code/session_01JzitXiMcdedyPbH4wqkXqX
- formatColorValue: preserve alpha on bound tokens via color-mix (<100%)
- design-tokens: add varForClassRule to recover shadcn @theme inline bindings
  from the generated utility rule; tokenForColorClass falls back to it
- dedup parseColorValue: src/utils.ts now re-exports from src/utils/color.ts
- bump package version 0.3.0 -> 0.3.1

Claude-Session: https://claude.ai/code/session_01JzitXiMcdedyPbH4wqkXqX
@rezailmi
rezailmi merged commit 4375aba into main Jun 26, 2026
3 checks passed
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