fix: align with the less algorithm for generating css variable value (#37064)

This commit is contained in:
TrickyPi 2022-09-01 11:34:32 +08:00 committed by GitHub
parent af73ba7530
commit 96759a1113
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 2 deletions

View File

@ -31,6 +31,34 @@ describe('ConfigProvider.Theme', () => {
});
});
it('should generate the same css variable as less algorithm', () => {
const prefixCls = 'test';
const infoColor = {
hover: '#40a9ff',
active: '#096dd9',
deprecatedBg: '#e6f7ff',
deprecatedBorder: '#91d5ff',
};
ConfigProvider.config({
prefixCls,
theme: {
infoColor: '#1890ff',
},
});
const styles: any[] = Array.from(document.querySelectorAll('style'));
const themeStyle = styles.find(style =>
style.getAttribute('rc-util-key').includes('-dynamic-theme'),
);
(Object.keys(infoColor) as Array<keyof typeof infoColor>).forEach(key => {
expect(themeStyle.innerHTML).toContain(
`--${prefixCls}-info-color-${kebabCase(key)}: ${infoColor[key]}`,
);
});
});
it('warning for SSR', () => {
resetWarned();

View File

@ -30,8 +30,8 @@ export function getStyle(globalPrefixCls: string, theme: Theme) {
variables[`${type}-color-hover`] = colorPalettes[4];
variables[`${type}-color-active`] = colorPalettes[6];
variables[`${type}-color-outline`] = baseColor.clone().setAlpha(0.2).toRgbString();
variables[`${type}-color-deprecated-bg`] = colorPalettes[1];
variables[`${type}-color-deprecated-border`] = colorPalettes[3];
variables[`${type}-color-deprecated-bg`] = colorPalettes[0];
variables[`${type}-color-deprecated-border`] = colorPalettes[2];
};
// ================ Primary Color ================