-
const [DARK] = '@media (prefers-color-scheme: dark)';
const color = stylex.defineVars({
accent: {
default: '#1763CF',
[DARK]: '#1763CF',
},
accent2: 'red',
});
const tokens= stylex.defineVars({
'badge-background-color-blue': color.accent,
'badge-background-color-red': color.accent2,
}) |
Beta Was this translation helpful? Give feedback.
Answered by
nmn
Dec 9, 2023
Replies: 1 comment 3 replies
-
|
Yes, this is a supported pattern. Create an issue if you run into issues with this. Note: You still need to define all variables in I would recommend rewriting your code as follows: // <filename>.stylex.ts
const [DARK] = '@media (prefers-color-scheme: dark)';
export const colors = stylex.defineVars({
accent: {
default: '#1763CF',
[DARK]: '#1763CF',
},
accent2: 'red',
});
export const tokens = stylex.defineVars({
badgeBgColorBlue: colors.accent,
badgeBgColorRed': colors.accent2,
});The key names in the |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
nmn
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, this is a supported pattern. Create an issue if you run into issues with this.
Note: You still need to define all variables in
.stylex.tsfiles and export the consts as named exports.I would recommend rewriting your code as follows:
The key names in the
defineVarshave no effect on the generated variables names (they are hashes), so you might as well use keys t…