mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 11:10:01 +08:00
fix: align with the less algorithm for generating css variable value (#37064)
This commit is contained in:
parent
af73ba7530
commit
96759a1113
@ -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();
|
||||
|
||||
|
@ -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 ================
|
||||
|
Loading…
Reference in New Issue
Block a user