Conversation
d8fcae4 to
0b1ab50
Compare
|
Thanks for the detailed investigation. I looked deeper into the original theming intent and the earlier history around this behavior. My verdict is that #921 combines two different cases:
Please keep the dark-scale imports, but revert the There are two closely related corrections worth making here:
Radix reference: https://www.radix-ui.com/colors/docs/palette-composition/understanding-the-scale I suggest narrowing #921 to the missing admonition dark scales and treating the select/background portion as the documented configuration from #225. |
|
That's fair, thanks for the review, will action those suggestions shortly. edit: all done for review. |
`globals.css` imported `blue` and `slate` both ways and `grass`, `cyan`, `amber` and `red` light-only. Radix defines a scale's dark steps in a separate file scoped to `.dark, .dark-theme`, so those four had no dark steps to switch to and the tip, info, caution and danger bands kept their light values under `dark-theme`. `note` derives from `slate` and was therefore the one admonition that already looked right. A band is decoration rather than a text background, so what breaks is its relationship to the surface it frames: a subtle tint in light mode (1.17-1.28:1 against white) became a bright block in dark (14.75-16.13:1 against the editor surface), and is a tint again with the dark steps imported (1.28-1.51:1). Light mode is untouched — `*-dark.css` declares nothing on `:root`. Also renames the pre-v3 unhyphenated Radix variables in the dark-theme example (`--cyan4` → `--cyan-4`, and the seven others). With the dark scales imported, that example's admonition overrides now resolve as intended. Adds `src/examples/bug-921.tsx`, which maps `--basePageBg` itself as a consumer does — see mdx-editor#225 — so the story isolates the scales.
Importing a scale's light stylesheet without its dark one leaves the tokens deriving from it unable to follow `dark-theme`, which is the defect behind the four light admonition bands. Reverting the imports makes this fail and name them. It asserts nothing about what a semantic token points at: `--basePageBg` is a mutable alias a consumer maps per colour mode, and a check requiring scale steps would reject that pattern.
0b1ab50 to
d934c8d
Compare
|
🎉 This PR is included in version 4.2.4 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Narrows #921 to the missing admonition dark scales, per your review.
src/styles/globals.cssimportedblueandslateboth ways, andgrass,cyan,amberandredlight-only. Those four feed the tip, info, caution and danger admonition tokens, so underdark-themethe scale had no dark steps to switch to and the four bands kept their light values.notederives fromslate, imported both ways, which is why it was the one admonition that already looked right.@import url('@radix-ui/colors/grass.css'); + @import url('@radix-ui/colors/grass-dark.css'); @import url('@radix-ui/colors/cyan.css'); + @import url('@radix-ui/colors/cyan-dark.css'); @import url('@radix-ui/colors/amber.css'); + @import url('@radix-ui/colors/amber-dark.css'); @import url('@radix-ui/colors/red.css'); + @import url('@radix-ui/colors/red-dark.css');Screenshots
Measured
A band is decoration around the nested editor, not a text background — the admonition's text sits on
--basePageBgand measures 15.60:1 either way. So the thing that breaks is the band's relationship to the surface it frames: a subtle tint in light mode, a bright block in dark.cyan)grass)amber)red)Ratios are sRGB, band step 4 against the editor surface. Radix ships
color(display-p3 …)overrides for every scale, including these four, so a wide-gamut display paints slightly different values — the same caveat that already applies toblueandslate.Light mode is untouched:
*-dark.cssscopes every declaration to.dark, .dark-themeand declares nothing on:root.Also corrected
src/examples/dark-editor.cssused the pre-v3 unhyphenated names —--cyan4,--grass8and so on — which Radix v3 spells--cyan-4,--grass-8. Renamed the eight of them. With the dark scales now imported, that example's admonition overrides resolve as intended.Tests
src/test/theme-tokens.test.tsasserts one invariant: every Radix scale imported light is also imported dark. Reverting the four imports makes it fail and name them:I dropped the second check from the earlier revision. You were right that requiring every semantic colour token to point at a scale step rejects the mutable-alias pattern — which is the pattern
--basePageBgexists to support.Demo
src/examples/bug-921.tsx, following thebug-NNNconvention:dark-theme, a toolbar withBlockTypeSelectandInsertAdmonition, and all five admonitions. The page supplies its background and maps--basePageBg; nothing else is overridden.Checks
npm run typecheck,npm run lint,npm run test:onceandnpm run test:browser -- --project=chromium. Firefox and WebKit not run — not installed here.