index.tsx 2.3 KB

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