mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-02 20:19:44 +08:00
c377457104
* feat: implement disabledAlpha api * refactor: add genAlphaColor and optimization code * chore: clean code * refactor: add warning and optimization code * chore: clean code * docs: modify version number * fix: fix prettier
23 lines
689 B
TypeScript
23 lines
689 B
TypeScript
import type { ColorGenInput } from '@rc-component/color-picker';
|
|
import type { Color } from './color';
|
|
import { ColorFactory } from './color';
|
|
|
|
export const customizePrefixCls = 'ant-color-picker';
|
|
|
|
export const generateColor = (color: ColorGenInput<Color>): Color => {
|
|
if (color instanceof ColorFactory) {
|
|
return color;
|
|
}
|
|
return new ColorFactory(color);
|
|
};
|
|
|
|
export const getRoundNumber = (value: number) => Math.round(Number(value || 0));
|
|
|
|
export const getAlphaColor = (color: Color) => getRoundNumber(color.toHsb().a * 100);
|
|
|
|
export const genAlphaColor = (color: Color, alpha?: number) => {
|
|
const hsba = color.toHsb();
|
|
hsba.a = alpha || 1;
|
|
return generateColor(hsba);
|
|
};
|