mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-12 11:55:26 +08:00
f1f89191ee
修复相互依赖的报错
36 lines
1.1 KiB
Vue
36 lines
1.1 KiB
Vue
/* eslint-disable import/prefer-default-export */
|
|
import type { CSSObject } from '../_util/cssinjs';
|
|
import type { AliasToken, PresetColorKey } from '../theme/internal';
|
|
import { PresetColors } from '../theme/interface';
|
|
import type { TokenWithCommonCls } from '../theme/util/genComponentStyleHook';
|
|
|
|
interface CalcColor {
|
|
/** token[`${colorKey}-1`] */
|
|
lightColor: string;
|
|
/** token[`${colorKey}-3`] */
|
|
lightBorderColor: string;
|
|
/** token[`${colorKey}-6`] */
|
|
darkColor: string;
|
|
/** token[`${colorKey}-7`] */
|
|
textColor: string;
|
|
}
|
|
|
|
type GenCSS = (colorKey: PresetColorKey, calcColor: CalcColor) => CSSObject;
|
|
|
|
export function genPresetColor<Token extends TokenWithCommonCls<AliasToken>>(
|
|
token: Token,
|
|
genCss: GenCSS,
|
|
): CSSObject {
|
|
return PresetColors.reduce((prev: CSSObject, colorKey: PresetColorKey) => {
|
|
const lightColor = token[`${colorKey}-1`];
|
|
const lightBorderColor = token[`${colorKey}-3`];
|
|
const darkColor = token[`${colorKey}-6`];
|
|
const textColor = token[`${colorKey}-7`];
|
|
|
|
return {
|
|
...prev,
|
|
...genCss(colorKey, { lightColor, lightBorderColor, darkColor, textColor }),
|
|
};
|
|
}, {} as CSSObject);
|
|
}
|