2023-01-06 11:06:46 +08:00
|
|
|
import type { PresetColorKey } from '../theme/interface';
|
|
|
|
import { PresetColors } from '../theme/interface';
|
|
|
|
|
|
|
|
type InverseColor = `${PresetColorKey}-inverse`;
|
|
|
|
const inverseColors = PresetColors.map<InverseColor>((color) => `${color}-inverse`);
|
|
|
|
|
2022-12-13 14:57:40 +08:00
|
|
|
export const PresetStatusColorTypes = [
|
|
|
|
'success',
|
|
|
|
'processing',
|
|
|
|
'error',
|
|
|
|
'default',
|
|
|
|
'warning',
|
|
|
|
] as const;
|
2019-03-31 20:21:20 +08:00
|
|
|
|
2023-01-06 11:06:46 +08:00
|
|
|
export type PresetColorType = PresetColorKey | InverseColor;
|
2022-12-13 14:57:40 +08:00
|
|
|
|
|
|
|
export type PresetStatusColorType = typeof PresetStatusColorTypes[number];
|
2023-01-06 11:06:46 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
}
|