Skip to content

Commit 19de817

Browse files
authored
fix(color-context tokens): only apply when .calcite-mode-auto is applied (#8344)
**Related Issue:** #8343 ## Summary Resolves bug where the @media query, which applied light and dark color-context tokens on prefers-color-scheme in CSS, was applied at `:root` instead of `.calcite-mode-auto`
1 parent c8230d0 commit 19de817

File tree

1 file changed

+5
-4
lines changed
  • packages/calcite-design-tokens/support/token-transformer/styleDictionary/formatter/utils

1 file changed

+5
-4
lines changed

packages/calcite-design-tokens/support/token-transformer/styleDictionary/formatter/utils/formatExtraOutput.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,18 @@ export function formatExtraOutput(
3636
? index.mixin.map(([mixinName, output]) => {
3737
const m = ensureIfArray(outputObject[`${output}.${args.platform}`]);
3838
return Array.isArray(m)
39-
? `@mixin ${mixinName} {\n\t${m.map((o) => `${o}`.replace("$", "--")).join("\n\t")}\n}`
39+
? `@mixin ${mixinName} {\n\t${m.map((o) => `${o}`.replaceAll("$", "--")).join("\n\t")}\n}`
4040
: "";
4141
})
4242
: [];
4343
const medias = index.media
4444
? index.media.map(([mediaSchemed, output]) => {
4545
const m = ensureIfArray(outputObject[`${output}.${args.platform}`]);
46+
const cssProps = m.map((o) => `${o}`.replaceAll("$", "--"));
4647
return Array.isArray(m)
47-
? `@media (${mediaSchemed}) {\n\t:root {\n\t\t${m
48-
.map((o) => `${o}`.replace("$", "--"))
49-
.join("\n\t\t")}\n\t}\n}`
48+
? `${
49+
output === "light" ? `:root {\n\t${cssProps.join("\n\t")}\n}\n` : ""
50+
}@media (${mediaSchemed}) {\n\t.calcite-mode-auto {\n\t\t${cssProps.join("\n\t\t")}\n\t}\n}`
5051
: "";
5152
})
5253
: [];

0 commit comments

Comments
 (0)