Sidebar.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import React from 'react';
  2. import Button from '../components/Button';
  3. import Typography from '../components/Typography';
  4. import Icon from '../components/Icon';
  5. import MarkupTools from '../components/MarkupTools';
  6. import CreateForm from '../components/CreateForm';
  7. import Watermark from './Watermark';
  8. import useActions from '../actions';
  9. import useStore from '../store';
  10. import { BtnWrapper } from '../global/toolStyled';
  11. import { SidebarWrapper } from '../global/otherStyled';
  12. const Sidebar: React.FunctionComponent = () => {
  13. const [{ sidebarState }, dispatch] = useStore();
  14. const { switchSidebar } = useActions(dispatch);
  15. const onClick = (state: string): void => {
  16. if (state === sidebarState) {
  17. switchSidebar('');
  18. } else {
  19. switchSidebar(state);
  20. }
  21. };
  22. const transferProps = {
  23. onClick,
  24. sidebarState,
  25. };
  26. return (
  27. <SidebarWrapper>
  28. <Typography light style={{ marginLeft: '30px', marginTop: '46px' }}>Main Menu</Typography>
  29. <MarkupTools {...transferProps} />
  30. <CreateForm {...transferProps} />
  31. <BtnWrapper>
  32. <Button shouldFitContainer align="left" onClick={(): void => { onClick('add-image'); }}>
  33. <Icon glyph="add-image" style={{ marginRight: '10px' }} />
  34. Add Image
  35. </Button>
  36. </BtnWrapper>
  37. <Watermark />
  38. </SidebarWrapper>
  39. );
  40. };
  41. export default Sidebar;