index.tsx 882 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import React from 'react';
  2. import Icon from '../Icon';
  3. import Typography from '../Typography';
  4. import { Group, Item, Circle } from '../../global/toolStyled';
  5. import data from './data';
  6. type Props = {
  7. showTitle?: boolean;
  8. color?: string;
  9. onClick: (color: string) => void;
  10. };
  11. const ColorSelector: React.FunctionComponent<Props> = ({
  12. showTitle = false,
  13. color = '',
  14. onClick,
  15. }: Props) => (
  16. <>
  17. { showTitle ? <Typography variant="subtitle" style={{ marginTop: '8px' }}>Color</Typography> : null}
  18. <Group>
  19. {data.map(ele => (
  20. <Item
  21. key={ele.key}
  22. selected={color === ele.color}
  23. onMouseDown={(): void => { onClick(ele.color); }}
  24. >
  25. <Circle color={ele.color} />
  26. </Item>
  27. ))}
  28. <Item>
  29. <Icon glyph="color-picker" />
  30. </Item>
  31. </Group>
  32. </>
  33. );
  34. export default ColorSelector;