index.tsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import React from 'react';
  2. import Icon from '../Icon';
  3. import Button from '../Button';
  4. import Typography from '../Typography';
  5. import ColorSelect from '../ColorSelector';
  6. import SliderWithTitle from '../SliderWithTitle';
  7. import { Group, Item } from '../../global/toolStyled';
  8. type Props = {
  9. type: string;
  10. setType: (arg: string) => void;
  11. color: string;
  12. setColor: (arg: string) => void;
  13. opacity: number;
  14. handleOpacity: (arg: number) => void;
  15. width: number;
  16. handleWidth: (arg: number) => void;
  17. };
  18. const FreehandOption = ({
  19. type,
  20. setType,
  21. color,
  22. setColor,
  23. opacity,
  24. handleOpacity,
  25. width,
  26. handleWidth,
  27. }: Props): React.ReactElement => (
  28. <>
  29. <Typography variant="subtitle" style={{ marginTop: '4px' }} align="left">Tools</Typography>
  30. <Group>
  31. <Item
  32. size="small"
  33. selected={type === 'pen'}
  34. onClick={(): void => { setType('pen'); }}
  35. >
  36. <Icon glyph="freehand" />
  37. </Item>
  38. <Item
  39. size="small"
  40. selected={type === 'eraser'}
  41. onClick={(): void => { setType('eraser'); }}
  42. >
  43. <Icon glyph="eraser" />
  44. </Item>
  45. <Item size="small">
  46. <Icon glyph="redo" />
  47. </Item>
  48. <Item size="small">
  49. <Icon glyph="undo" />
  50. </Item>
  51. </Group>
  52. <ColorSelect
  53. showTitle
  54. color={color}
  55. onClick={setColor}
  56. />
  57. <SliderWithTitle
  58. title="Opacity"
  59. value={opacity}
  60. tips={`${opacity}%`}
  61. onSlide={handleOpacity}
  62. />
  63. <SliderWithTitle
  64. title="Width"
  65. value={width}
  66. tips={`${width} pt`}
  67. onSlide={handleWidth}
  68. maximum={40}
  69. />
  70. <Group style={{ marginTop: '20px', paddingRight: '40px' }}>
  71. <Button
  72. appearance="danger-hollow"
  73. shouldFitContainer
  74. >
  75. <Icon glyph="clear" style={{ marginRight: '5px' }} />
  76. Clear all
  77. </Button>
  78. </Group>
  79. </>
  80. );
  81. export default FreehandOption;