mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-04 00:49:39 +08:00
b95d5674fa
* feat: color picker * chore: improve component logic * test: update snapshots * test: update snapshots * fix: remove unuse code * fix: adjusting the UI * fix: hairy edge in dark mode * fix: demo case * chore: rollback file * fix: improve code logic * perf: improve code * test: add test case * refactor: trigger use Popover instead * test: add test case * refactor: improve code logic * test: update snapshots * refactor: improve code * docs: add overview img * feat: style * chore: update snapshot * chore: code clean * chore: code clean * chore: fix lint * chore: update snapshot * feat: color block * chore: pure render * refactor: hex input number reduced to 6 digits * fix: rename React to react * refactor: trigger demo * docs: remove disabled demo --------- Co-authored-by: MadCcc <1075746765@qq.com>
21 lines
756 B
TypeScript
21 lines
756 B
TypeScript
import type { ColorGenInput } from '@rc-component/color-picker';
|
|
import { getRoundNumber } from '@rc-component/color-picker/lib/util';
|
|
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 getAlphaColor = (color: Color) => getRoundNumber(color.toHsb().a * 100);
|
|
|
|
export const toHexFormat = (value?: string, alpha?: boolean) =>
|
|
value?.replace(/[^\w/]/gi, '').slice(0, alpha ? 8 : 6) || '';
|
|
|
|
export const getHex = (value?: string, alpha?: boolean) => (value ? toHexFormat(value, alpha) : '');
|