Skip to content

Commit 353f470

Browse files
committed
style: config-provider
1 parent 73f7f9e commit 353f470

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

components/config-provider/cssVariables.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import devWarning from '../vc-util/devWarning';
99

1010
const dynamicStyleMark = `-ant-${Date.now()}-${Math.random()}`;
1111

12-
export function registerTheme(globalPrefixCls: string, theme: Theme) {
12+
export function getStyle(globalPrefixCls: string, theme: Theme) {
1313
const variables: Record<string, string> = {};
1414

1515
const formatColor = (
@@ -88,15 +88,18 @@ export function registerTheme(globalPrefixCls: string, theme: Theme) {
8888
key => `--${globalPrefixCls}-${key}: ${variables[key]};`,
8989
);
9090

91-
if (canUseDom()) {
92-
updateCSS(
93-
`
91+
return `
9492
:root {
9593
${cssList.join('\n')}
9694
}
97-
`,
98-
`${dynamicStyleMark}-dynamic-theme`,
99-
);
95+
`.trim();
96+
}
97+
98+
export function registerTheme(globalPrefixCls: string, theme: Theme) {
99+
const style = getStyle(globalPrefixCls, theme);
100+
101+
if (canUseDom()) {
102+
updateCSS(style, `${dynamicStyleMark}-dynamic-theme`);
100103
} else {
101104
devWarning(false, 'ConfigProvider', 'SSR do not support dynamic theme with css variables.');
102105
}

0 commit comments

Comments
 (0)