Skip to content

Commit

Permalink
patch to fix facebook#601
Browse files Browse the repository at this point in the history
A quick patch to fix facebook#601
  • Loading branch information
zetavg committed Jun 8, 2024
1 parent ac61226 commit 0f13f18
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/shared/src/stylex-create-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default function styleXCreateTheme(
}

return [
{ $$css: true, [themeVars.__themeName__]: overrideClassName },
{ $$css: true, [themeVars.__themeName__]: overrideClassName, __overrideRootVars__: `${classNamePrefix}vars` },
stylesToInject,
];
}
4 changes: 3 additions & 1 deletion packages/shared/src/stylex-define-vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export default function styleXDefineVars<Vars: VarsConfig>(
const injectableStyles = constructCssVariablesString(
variablesMap,
themeNameHash,
classNamePrefix,
);

const injectableTypes: { +[string]: InjectableStyle } = objMap(
Expand All @@ -88,6 +89,7 @@ export default function styleXDefineVars<Vars: VarsConfig>(
function constructCssVariablesString(
variables: { +[string]: { +nameHash: string, +value: VarsConfigValue } },
themeNameHash: string,
classNamePrefix: string,
): { [string]: InjectableStyle } {
const rulesByAtRule: { [string]: Array<string> } = {};

Expand All @@ -99,7 +101,7 @@ function constructCssVariablesString(
for (const [atRule, value] of Object.entries(rulesByAtRule)) {
const suffix = atRule === 'default' ? '' : `-${createHash(atRule)}`;

let ltr = `:root{${value.join('')}}`;
let ltr = `:root,.${classNamePrefix}vars{${value.join('')}}`;
if (atRule !== 'default') {
ltr = wrapWithAtRules(ltr, atRule);
}
Expand Down

0 comments on commit 0f13f18

Please sign in to comment.