mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-05 21:48:19 +08:00
7f189d56e5
* style: remove redundant code * feat(style): add preset colour style generation method (cherry picked from commit 1266e42ba27accb48a6544e3eddaa4a94daef00c) * feat: uniform preset colour generation css selector method (cherry picked from commit 5af87e8d5ffcfd23e755946167f200c0565f8222) * chore: merge preset colors (cherry picked from commit 05040dfb703f60a3ea1715326748c508acbf41a6) * chore: update (cherry picked from commit 241b40a1361469487a6a3e8f1ad07a25d250463d) * chore: remove Badge preset inverse colors * chore: remove fix 删除的这部分其实一个 Bug,但是为了给 PR 减负(尽可能单一, 后面新开一个 PR 来修复这个问题 * suggestions accepted Update components/style/presetColor.tsx Co-authored-by: MadCcc <1075746765@qq.com> Co-authored-by: MadCcc <1075746765@qq.com>
35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
import type { PresetColorKey } from '../theme/interface';
|
|
import { PresetColors } from '../theme/interface';
|
|
|
|
type InverseColor = `${PresetColorKey}-inverse`;
|
|
const inverseColors = PresetColors.map<InverseColor>((color) => `${color}-inverse`);
|
|
|
|
export const PresetStatusColorTypes = [
|
|
'success',
|
|
'processing',
|
|
'error',
|
|
'default',
|
|
'warning',
|
|
] as const;
|
|
|
|
export type PresetColorType = PresetColorKey | InverseColor;
|
|
|
|
export type PresetStatusColorType = typeof PresetStatusColorTypes[number];
|
|
|
|
/**
|
|
* determine if the color keyword belongs to the `Ant Design` {@link PresetColors}.
|
|
* @param color color to be judged
|
|
* @param includeInverse whether to include reversed colors
|
|
*/
|
|
export function isPresetColor(color?: any, includeInverse = true) {
|
|
if (includeInverse) {
|
|
return [...inverseColors, ...PresetColors].includes(color);
|
|
}
|
|
|
|
return PresetColors.includes(color);
|
|
}
|
|
|
|
export function isPresetStatusColor(color?: any): color is PresetStatusColorType {
|
|
return PresetStatusColorTypes.includes(color);
|
|
}
|