MarkupTools.tsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import React from 'react';
  2. import { useTranslation } from 'react-i18next';
  3. // import Button from '../components/Button';
  4. // import ExpansionPanel from '../components/ExpansionPanel';
  5. // import Icon from '../components/Icon';
  6. import HighlightTools from './HighlightTools';
  7. import FreehandTools from './FreehandTools';
  8. import TextTools from './FreeTextTools';
  9. import StickyNoteTools from './StickyNoteTools';
  10. import ShapeTools from './ShapeTools';
  11. import WatermarkTool from './WatermarkTool';
  12. import useActions from '../actions';
  13. import useStore from '../store';
  14. const MarkupTools: React.FC = () => {
  15. const { t } = useTranslation('sidebar');
  16. const [{ sidebarState }, dispatch] = useStore();
  17. const { setSidebar } = useActions(dispatch);
  18. // const onClickSidebar = (state: string): void => {
  19. // if (state === sidebarState) {
  20. // setSidebar('');
  21. // } else {
  22. // setSidebar(state);
  23. // }
  24. // };
  25. const onClickTool = (state: string): void => {
  26. if (state === sidebarState) {
  27. setSidebar('');
  28. } else {
  29. setSidebar(state);
  30. }
  31. };
  32. // useEffect(() => {
  33. // if (sidebarState !== 'markup-tools') {
  34. // setSidebar('');
  35. // }
  36. // }, []);
  37. // const Label = (
  38. // <Button
  39. // shouldFitContainer
  40. // align="left"
  41. // onClick={(): void => {
  42. // onClickSidebar('markup-tools');
  43. // }}
  44. // >
  45. // <Icon glyph="markup-tools" style={{ marginRight: '10px' }} />
  46. // {t('markupTool')}
  47. // </Button>
  48. // );
  49. return (
  50. <>
  51. <HighlightTools
  52. title={t('annotate')}
  53. isActive={sidebarState === 'highlight'}
  54. onClick={(): void => {
  55. onClickTool('highlight');
  56. }}
  57. />
  58. <FreehandTools
  59. title={t('freehand')}
  60. isActive={sidebarState === 'freehand'}
  61. onClick={(): void => {
  62. onClickTool('freehand');
  63. }}
  64. />
  65. <TextTools
  66. title={t('textBox')}
  67. isActive={sidebarState === 'text'}
  68. onClick={(): void => {
  69. onClickTool('text');
  70. }}
  71. />
  72. <StickyNoteTools
  73. title={t('stickyNote')}
  74. isActive={sidebarState === 'sticky'}
  75. onClick={(): void => {
  76. onClickTool('sticky');
  77. }}
  78. />
  79. <ShapeTools
  80. title={t('shape')}
  81. isActive={sidebarState === 'shape'}
  82. onClick={(): void => {
  83. onClickTool('shape');
  84. }}
  85. />
  86. <WatermarkTool />
  87. </>
  88. );
  89. };
  90. export default MarkupTools;