Conversation
react-mcu gives way to material-theme-builder, its successor and the package pmndrs/design-system's MD3 registry item installs. Doing the swap on its own leaves that item as a pure question of where the colour layer lives, rather than which package computes it. At the API level it is a rename: --mcu-* becomes --md-sys-color-*, the standard MD3 system-token name. <Mcu> becomes <Mtb> and takes the same props. The --color-* names the @theme mapping declares are identical either way, so every bg-surface, bg-primary-container and text-on-surface-variant keeps working untouched, and the THEME_* env vars behave as before. Two components name the raw variables rather than a Tailwind utility -- Code for its fixed prism colour, Sandpack for its three surface levels -- and are the only component edits. The palette is NOT identical, though. Rendering both packages against this repo's config and resolving to hex: 57 of the 67 roles match exactly, including all 49 standard M3 ones. The 10 that differ all belong to the five `blend: true` custom colours, and the two harmonize differently -- material-theme-builder pulls a custom colour further toward the seed the further its hue sits from it. note #a0caff -> #a1c9fd note-container #00497e -> #1b4975 tip #71dba5 -> #90d5ae on-tip-container #8ef7c0 -> #abf2c9 on-important #1f00a5 -> #2c2960 important-container #372ac0 -> #424078 warning #e5c446 -> #dec56e on-warning-container#ffe174 -> #fbe186 on-caution #670024 -> #561d29 caution-container #900036 -> #72333f So the markdown alerts get more muted backgrounds -- most visibly Important and Caution, whose hues are furthest from the slate seed; Tip and Warning keep their container colour. Chromatic build 292 shows exactly this, on the six pages that render an alert. Verified: full build green, 69 --md-sys-color-* variables server-rendered and no --mcu-* left anywhere. tsc, prettier and the 95 tests clean; lint reports two pre-existing react/no-unescaped-entities in src/stories/Page.tsx, verified against main. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018NUhr59QsGjuq2iACFhxX8
globals.css restated, by hand, two blocks the package already ships: a ~60-line @theme mapping of --color-* onto --md-sys-color-*, and a 31-line :root/.dark remap of shadcn's variables onto M3 roles. Both are now one directive each. @import 'material-theme-builder/shadcn.css'; @plugin 'material-theme-builder/tailwind' { custom-colors: note, tip, important, warning, caution; } The plugin covers all 67 names the mapping declared -- diffed programmatically, zero missing -- and adds surface-tint, surface-variant and the ref-palette shades. It also takes the custom colour names, which a static stylesheet could not: each of the five expands to its four roles, so the twenty hand-written alert lines go too, and with them the failure they invited. A name declared in the config and forgotten in the mapping emitted no rule and no error. The shadcn remap was byte-identical to the package's shadcn.css, so the import is pure dedup. Its selectors are doubled -- :root:root, .dark.dark -- so it outranks shadcn's own blocks by specificity rather than by source order, which is why it can sit up with the other imports. Net: globals.css loses 95 lines and every --md-sys-color- reference. Verified. The emitted CSS is rule-for-rule identical before and after, bar one indirection: each of the 38 differing rules is the same selector and property with var(--color-surface-dim) become var(--md-sys-color-surface-dim). The @layer theme block loses exactly the 18 --color-* aliases and nothing else. In the running build the five alerts compute byte-identical backgrounds in both themes -- dark rgb(27,73,117) / rgb(0,82,52) / rgb(66,64,120) / rgb(85,69,0) / rgb(114,51,63), light rgb(210,228,255) / rgb(171,242,201) / rgb(227,223,255) / rgb(251,225,134) / rgb(255,217,221) -- and shadcn's --background, --primary, --border and --ring all resolve to their M3 roles rather than shadcn's stock oklch, confirming the doubled selector wins. --radius is untouched: shadcn.css defines no non-colour. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018NUhr59QsGjuq2iACFhxX8
The `:root` and `.dark` blocks shadcn vendors are still in the file, and every colour in them is overridden by the `shadcn.css` import above -- doubled selectors, so it wins wherever it sits. Only `--radius` is live; that import defines no non-colour. They stay verbatim rather than get trimmed: it is what the CLI writes, and hand-editing it would come back on every future run. But a reader had no way to tell the live values from the dead ones, so the block now says which it is. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018NUhr59QsGjuq2iACFhxX8
Merged
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.
Extracted from #571, which was doing this swap in passing while also moving the colour layer to
pmndrs/design-system. Two separable things: which package computes the palette, and where the layer that maps it lives. This is the first. #571 now sits on top of it and is the second alone.react-mcugives way tomaterial-theme-builder, its successor — and the package the design system's MD3 registry item installs, which is why it has to happen either way.At the API level, it is a rename
--mcu-*becomes--md-sys-color-*, the standard MD3 system-token name.<Mcu>becomes<Mtb>and takes the same props.The
--color-*names the@thememapping declares are identical either way, so everybg-surface,bg-primary-containerandtext-on-surface-variantin the codebase keeps working untouched. TheTHEME_*env vars — seed, scheme, contrast and the five alert colours — behave exactly as before.Two components name the raw variables rather than a Tailwind utility:
Codefor its fixed prism colour,Sandpackfor its three surface levels. Those four lines are the only component edits.The palette is not identical, though
blend: trueharmonizes the five alert colours against the seed, and the two packages harmonize differently. Rendered both against this repo's config and resolved to hex: 57 of the 67 roles match exactly, including all 49 standard M3 ones. The 10 that differ all belong to the custom colours.note#a0caff#a1c9fdnote-container#00497e#1b4975tip#71dba5#90d5aeon-tip-container#8ef7c0#abf2c9on-important#1f00a5#2c2960important-container#372ac0#424078warning#e5c446#dec56eon-warning-container#ffe174#fbe186on-caution#670024#561d29caution-container#900036#72333fThe pattern: material-theme-builder pulls a custom colour further toward the seed the further its hue sits from it.
noteis already near the slate's blue and barely moves;important(violet) andcaution(red) move a lot.So the markdown alerts get more muted backgrounds — visibly for Important and Caution. Tip and Warning keep their container colour; only their foreground roles shift, which nothing renders.
Chromatic build 292 shows exactly this: 12 changes over the six pages that render an alert, and in the diff only the Important and Caution panels are flagged.
This is the one visible change in this PR — worth a decision rather than an accept-all, since both packages are ours. If react-mcu's harmonization was the intended one, the fix belongs upstream in
material-theme-builder, not here.It also stops restating the layer
globals.csswas hand-writing two blocks the package already ships. Both are now one directive each:The plugin covers all 67 names the
@thememapping declared — diffed programmatically, zero missing — and addssurface-tint,surface-variantand the ref-palette shades. It also takes the custom colour names, which a static stylesheet could not: each of the five expands to its four roles, so the twenty hand-written alert lines go too — and with them the failure they invited, where a name declared in the config and forgotten in the mapping emitted no rule and no error.The shadcn remap was byte-identical to the package's
shadcn.css, so that import is pure dedup. Its selectors are doubled —:root:root, .dark.dark— so it outranks shadcn's own blocks by specificity rather than by source order, which is why it sits up with the other imports.--radiusis untouched:shadcn.cssdefines no non-colour.globals.cssloses 95 lines and every--md-sys-color-reference.Note
v5.0.0 removed
material-theme-builder/tailwind.css; it no longer resolves. The@pluginform is the replacement and the only way to map custom colours.Verified
var(--color-surface-dim)becomevar(--md-sys-color-surface-dim). The@layer themeblock loses exactly the 18--color-*aliases and nothing else.rgb(27,73,117)/rgb(0,82,52)/rgb(66,64,120)/rgb(85,69,0)/rgb(114,51,63), lightrgb(210,228,255)/rgb(171,242,201)/rgb(227,223,255)/rgb(251,225,134)/rgb(255,217,221). shadcn's--background,--primary,--borderand--ringall resolve to their M3 roles rather than shadcn's stockoklch, confirming the doubled selector wins.tonalSpot, contrast 0, the five blended alerts),--md-sys-color-*resolved through--md-ref-palette-*to hex, then compared name by name.next buildgreen, and the built HTML carries 69--md-sys-color-*variables server-rendered, with no--mcu-*left anywhere in the output.tscclean,prettier --checkclean, 95 tests green.lintreports tworeact/no-unescaped-entitiesinsrc/stories/Page.tsx; both pre-date this branch, verified againstmain.🤖 Generated with Claude Code
https://claude.ai/code/session_018NUhr59QsGjuq2iACFhxX8