mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-02 03:59:01 +08:00
502dac12aa
* docs: fix code * feat: lint * feat: prettier * feat: test * feat: review * feat: format html * feat: format html
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);
|
|
}
|