Sidebar.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import React from 'react';
  2. import { withTranslation } from '../i18n';
  3. import Button from '../components/Button';
  4. import Typography from '../components/Typography';
  5. import Icon from '../components/Icon';
  6. import CreateForm from './CreateForm';
  7. import MarkupTools from './MarkupTools';
  8. import WatermarkTool from './WatermarkTool';
  9. import useActions from '../actions';
  10. import useStore from '../store';
  11. import { BtnWrapper } from '../global/toolStyled';
  12. import { SidebarWrapper } from '../global/otherStyled';
  13. type Props = {
  14. t: (key: string) => string;
  15. }
  16. const Sidebar: React.FC<Props> = ({
  17. t,
  18. }: Props) => {
  19. const [{ sidebarState, displayMode }, dispatch] = useStore();
  20. const { setSidebar } = useActions(dispatch);
  21. const onClick = (state: string): void => {
  22. if (state === sidebarState) {
  23. setSidebar('');
  24. } else {
  25. setSidebar(state);
  26. }
  27. };
  28. return (
  29. <SidebarWrapper isHidden={displayMode === 'full'}>
  30. <Typography light style={{ marginLeft: '30px', marginTop: '46px' }} align="left">
  31. {t('mainMenu')}
  32. </Typography>
  33. <MarkupTools />
  34. <CreateForm />
  35. <BtnWrapper>
  36. <Button shouldFitContainer align="left" onClick={(): void => { onClick('add-image'); }}>
  37. <Icon glyph="add-image" style={{ marginRight: '10px' }} />
  38. {t('addImages')}
  39. </Button>
  40. </BtnWrapper>
  41. <WatermarkTool />
  42. </SidebarWrapper>
  43. );
  44. };
  45. export default withTranslation('sidebar')(Sidebar);