style: config-provider
parent
73f7f9e3b9
commit
353f470c11
|
@ -9,7 +9,7 @@ import devWarning from '../vc-util/devWarning';
|
||||||
|
|
||||||
const dynamicStyleMark = `-ant-${Date.now()}-${Math.random()}`;
|
const dynamicStyleMark = `-ant-${Date.now()}-${Math.random()}`;
|
||||||
|
|
||||||
export function registerTheme(globalPrefixCls: string, theme: Theme) {
|
export function getStyle(globalPrefixCls: string, theme: Theme) {
|
||||||
const variables: Record<string, string> = {};
|
const variables: Record<string, string> = {};
|
||||||
|
|
||||||
const formatColor = (
|
const formatColor = (
|
||||||
|
@ -88,15 +88,18 @@ export function registerTheme(globalPrefixCls: string, theme: Theme) {
|
||||||
key => `--${globalPrefixCls}-${key}: ${variables[key]};`,
|
key => `--${globalPrefixCls}-${key}: ${variables[key]};`,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (canUseDom()) {
|
return `
|
||||||
updateCSS(
|
|
||||||
`
|
|
||||||
:root {
|
:root {
|
||||||
${cssList.join('\n')}
|
${cssList.join('\n')}
|
||||||
}
|
}
|
||||||
`,
|
`.trim();
|
||||||
`${dynamicStyleMark}-dynamic-theme`,
|
}
|
||||||
);
|
|
||||||
|
export function registerTheme(globalPrefixCls: string, theme: Theme) {
|
||||||
|
const style = getStyle(globalPrefixCls, theme);
|
||||||
|
|
||||||
|
if (canUseDom()) {
|
||||||
|
updateCSS(style, `${dynamicStyleMark}-dynamic-theme`);
|
||||||
} else {
|
} else {
|
||||||
devWarning(false, 'ConfigProvider', 'SSR do not support dynamic theme with css variables.');
|
devWarning(false, 'ConfigProvider', 'SSR do not support dynamic theme with css variables.');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue