ant-design/components/color-picker/util.ts
afc163 67d0462ca9
refactor: resolve Circular dependency (#42750)
* test: detect dependency cycle

* chore: open eslint import/no-cycle rule

close #42804

* chore: Upgrade react-component

* Apply suggestions from code review

* refactor: add getRoundNumber

* chore: Update package.json
2023-06-25 15:38:22 +08:00

17 lines
537 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);