import React from 'react'; import { ChromePicker } from 'react-color'; import Icon from '../Icon'; import Typography from '../Typography'; import { Group, Item, Circle, PickerContainer, Blanket, } from '../../global/toolStyled'; import data from './data'; type Props = { title?: string; selectedColor?: string; onClick: (color: string) => void; mode?: 'normal' | 'shape' | 'watermark'; isCollapse: boolean; pickerToggle: (e: React.MouseEvent) => void; }; type ColorItem = { key: string | number | undefined; color: string; icon?: string; }; const ColorSelector: React.FC = ({ title = '', mode = 'normal', selectedColor = '', onClick, pickerToggle, isCollapse, }: Props) => { const colorList: ColorItem[] = data[mode]; return ( <> {title ? ( {title} ) : null} {colorList.map((ele: ColorItem) => ( { onClick(ele.color); }} > {ele.icon ? ( ) : ( )} ))} {!isCollapse ? ( { event.preventDefault(); onClick(color.hex); }} /> ) : null} ); }; export default ColorSelector;