import React from 'react'; import Icon from '../Icon'; import Typography from '../Typography'; import ColorPicker from '../ColorPicker'; import Portal from '../Portal'; 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' | 'freehand' | 'watermark'; isCollapse: boolean; pickerToggle: (e?: React.MouseEvent) => void; throughPortal: boolean; }; type ColorItem = { key: string | number | undefined; color: string; icon?: string; }; const ColorSelector: React.FC = ({ title = '', mode = 'normal', selectedColor = '', onClick, pickerToggle, isCollapse, throughPortal, }: Props) => { const colorList: ColorItem[] = data[mode]; let ColorPickerGenerator = ( { pickerToggle(); onClick(color.hex); }} /> ); if (throughPortal) { ColorPickerGenerator = {ColorPickerGenerator}; } return ( <> {title ? ( {title} ) : null} {colorList.map((ele: ColorItem) => ( { onClick(ele.color); }} > {ele.icon ? ( ) : ( )} ))} selectedColor === ele.color)} > {!isCollapse ? ColorPickerGenerator : null} ); }; export default ColorSelector;