mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-05 05:28:20 +08:00
18 lines
633 B
TypeScript
18 lines
633 B
TypeScript
import React from 'react';
|
|
import { generate, green, presetPalettes, red } from '@ant-design/colors';
|
|
import { ColorPicker, theme } from 'antd';
|
|
import type { ColorPickerProps } from 'antd';
|
|
|
|
type Presets = Required<ColorPickerProps>['presets'][number];
|
|
|
|
const genPresets = (presets = presetPalettes) =>
|
|
Object.entries(presets).map<Presets>(([label, colors]) => ({ label, colors }));
|
|
|
|
const Demo: React.FC = () => {
|
|
const { token } = theme.useToken();
|
|
const presets = genPresets({ primary: generate(token.colorPrimary), red, green });
|
|
return <ColorPicker presets={presets} defaultValue="#1677ff" />;
|
|
};
|
|
|
|
export default Demo;
|