Sidebar.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import React from 'react';
  2. import { useTranslation } from 'react-i18next';
  3. import Typography from '../components/Typography';
  4. import FormTools from './FormTools';
  5. import MarkupTools from './MarkupTools';
  6. import ImageTool from './ImageTool';
  7. import WatermarkTool from './WatermarkTool';
  8. import InsertCursor from './InsertCursor';
  9. import useStore from '../store';
  10. import useActions from '../actions';
  11. import { SidebarWrapper } from '../global/otherStyled';
  12. const Sidebar: React.FC = () => {
  13. const { t } = useTranslation('sidebar');
  14. const [{ sidebarState }, dispatch] = useStore();
  15. const { setSidebar } = useActions(dispatch);
  16. const handleClickSidebar = (state: string): void => {
  17. if (state === sidebarState) {
  18. setSidebar('');
  19. } else {
  20. setSidebar(state);
  21. }
  22. };
  23. return (
  24. <SidebarWrapper>
  25. <Typography
  26. light
  27. style={{ marginLeft: '30px', marginTop: '46px' }}
  28. align="left"
  29. >
  30. {t('mainMenu')}
  31. </Typography>
  32. <MarkupTools
  33. sidebarState={sidebarState}
  34. onClickSidebar={handleClickSidebar}
  35. />
  36. <FormTools
  37. sidebarState={sidebarState}
  38. onClickSidebar={handleClickSidebar}
  39. />
  40. <ImageTool onClickSidebar={handleClickSidebar} />
  41. <WatermarkTool onClickSidebar={handleClickSidebar} />
  42. <InsertCursor />
  43. </SidebarWrapper>
  44. );
  45. };
  46. export default Sidebar;