fix(docs): resolve color token values so swatches render in docs pages#759
Open
maarkN wants to merge 1 commit into
Open
fix(docs): resolve color token values so swatches render in docs pages#759maarkN wants to merge 1 commit into
maarkN wants to merge 1 commit into
Conversation
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.
Fixes #760
Problem
On the docs Design System pages (
yarn docs:dev→ Background Color, Border Color,Text Design › Text Color), all color swatches render transparent/empty — the colors
don't show up.
Root cause
The semantic color tokens generated in
tailwind/colorPalette.jsresolve to Tailwindstrings containing the internal
<alpha-value>placeholder, e.g.:That placeholder is only substituted by Tailwind when generating utility classes.
docs/content/docs/design-system/[token].paths.tswas passing this raw value to thetoken components, which use it as an inline style (
backgroundColor/color/borderColor) — invalid CSS, so the swatches rendered transparent.Fix
Added a small resolver in
[token].paths.tsthat extracts the theme-awarevar(--token, fallback)portion of the value and applied it in the three colorgetters (
getBgColors,getTextColors,getBorderColors). Since the CSS variablesare defined on
:root/[data-theme="dark"]by the theme plugin, the swatches alsofollow dark mode correctly.
Before / After
Dark mode (swatches follow the theme):

Also fixes Border Color and Text Design › Text Color, which used the same data: