Repository navigation
fix: theme tokens and recipes that never reach apps - #54
Conversation
Several theme values were lost when merging with Chakra's defaultConfig: - brand.muted dark referenced `yellow.7 00`, which never resolved - black/white alpha shades were dropped by the merge with Chakra's single black/white values; they move to blackAlpha/whiteAlpha, fixing bg.muted - bg/fg never overrode Chakra's: add bg.DEFAULT and fg.DEFAULT using _light so they win (bg.default kept as an alias) - recipe keys Toast/Text/Heading were capitalised, so Chakra never read them; lowercase them and drop the base color from text/heading - mono font renamed to 'Intel One Mono', the name @fontsource registers Add a system test that builds the merged system and checks every token ships as declared and every recipe key is one Chakra reads. Remove the matching workarounds from the design system site.
| // Same value as `bg`, kept for apps that already use it | ||
| default: { value: { _light: '{colors.gray.50}', _dark: '{colors.gray.950}' } }, | ||
| inverted: { value: { _light: '{colors.gray.800}', _dark: '{colors.gray.100}' } }, | ||
| muted: { value: { _light: '{colors.blackAlpha.200}', _dark: '{colors.whiteAlpha.200}' } }, |
There was a problem hiding this comment.
With bg now resolving to gray.50 / gray.950, Chakra's bg.panel (white / gray.950) ends up identical to the page background in dark mode, so cards, dialogs, menus etc. lose their contrast. Chakra's line table variant also puts rows on plain bg, so table rows blend into the page in both modes (checked against control-center-frontend, where all 32 tables use the default variant).
Could we add a panel token here so surfaces stay one step off the page?
| muted: { value: { _light: '{colors.blackAlpha.200}', _dark: '{colors.whiteAlpha.200}' } }, | |
| muted: { value: { _light: '{colors.blackAlpha.200}', _dark: '{colors.whiteAlpha.200}' } }, | |
| // Surfaces that sit on the page (cards, dialogs, menus, table rows). Chakra's dark value is | |
| // gray.950, the same as the page background, so surfaces would disappear in dark mode. | |
| panel: { value: { _light: '{colors.white}', _dark: '{colors.gray.900}' } }, |
And in config.ts, point the line table rows at it so they no longer use the page background:
slotRecipes: {
table: {
slots: ['root', 'caption', 'header', 'body', 'footer', 'row', 'columnHeader', 'cell'],
variants: {
variant: {
line: { row: { bg: 'bg.panel' } },
},
},
},
// ...
}Light mode is unchanged for everything already on bg.panel (still white); dark mode shifts those surfaces from gray.950 to gray.900.
There was a problem hiding this comment.
Good catch, thanks. Before this PR the page was #09090B and panels gray.950, so this PR is what makes them collapse in dark mode. I've applied both suggestions in 63b7883. I checked that all dark text tokens stay ≥ 4.5:1 on gray.900, except secondary.fg (4.07), which the follow-up contrast PR fixes. One side effect: secondary.subtle in dark mode is also gray.900, so I'll move it off the panel colour in that PR.
There was a problem hiding this comment.
On reflection I'll leave secondary.subtle as is: text on it stays at 5.98:1, and the fill is only cosmetic. Listed as a known gap in the contrast PR.
With bg now resolving to gray.50 / gray.950, Chakra's bg.panel (white / gray.950) matched the page in dark mode, so cards, dialogs and menus lost their contrast. Add bg.panel (white / gray.900) and put the `line` table rows on it instead of the page background.
RobinAtherton
left a comment
There was a problem hiding this comment.
Thanks for the panel token fixes and toasts, LGTM 🦕
Why
Several theme values are lost when the theme is merged with Chakra's
defaultConfig. The source looks right, but apps never get them:brand.muteddark is{colors.yellow.7 00}. The reference doesn't resolve, so there's no colour.black.*/white.*alpha shades are dropped, because Chakra's singleblack/whitevalue wins the merge. As a resultbg.mutedis broken in both modes.bg/fgnever override Chakra's in light mode. The theme writes them withbase, and Chakra's_lightvalue wins. In dark mode they worked untilDEFAULT→default(feat: expand semantic tokens and add theme-lint enhancements #49) stopped the override.Toast,TextandHeadingare capitalised, but Chakra readstoast,textandheading, so none of them apply.'IntelOne Mono', but @fontsource registers'Intel One Mono'.The design system site never showed these because it works around them. For example, its
Toasterhand-sets colours on every toast, while apps rendering a plain<Toast.Root>get Chakra's default colours.What
brand.mutedreference. Move the alpha shades to Chakra's names,blackAlpha.*/whiteAlpha.*.bg.DEFAULT(gray.50 / gray.950) andfg.DEFAULT(=content.primary), using_lightso they win.bg.defaultstays as an alias.bg.panel(white / gray.900) and put thelinetable rows on it, so cards, dialogs, menus and table rows stay one step off the page. Chakra's darkbg.panelis gray.950, which now matches the page.text/heading;fgprovides it, so text inside an Alert or Button keeps its parent's colour.'Intel One Mono';theme-lintrecognises both spellings.system.test.ts, which builds the merged system and checks that every token ships as declared in both modes and that every recipe key is one Chakra reads. It fails onmain.Visible changes in apps (no API breaks, but every app looks different):
#09090B→ gray.950 in dark mode, which is the biggest change.bg.panel): gray.950 → gray.900 in dark mode. Table rows move from the page colour to white / gray.900.bg.inverted): near-black → gray.800 in light mode.bg.muted, used by inputs, tracks, skeletons, tabs and tables: gray.100 → 8% black in light mode, and transparent → 8% white in dark mode.warning.solidis lighter than Chakra's. Contrast of the solid colours will follow up in a separate PR after this PR is merged.Apps that override these tokens in their own theme keep their values.
colors.black.*/colors.white.*becomecolors.blackAlpha.*/colors.whiteAlpha.*; the old names never resolved, so nothing breaks. Suggested release: 1.5.0, or 2.0.0 if visible default changes count as breaking.Test plan
pnpm lint:allpassestscpasses inthemeandtestingpnpm test:unitpasses (theme 55, site 116)bg.muted,brand.muted, mono font, real toastsScreenshots
brand.muted(dark)