DrawerToggler.tsx 586 B

12345678910111213141516171819202122232425262728
  1. import React, { FC } from 'react';
  2. import { useDrawerOpened } from '~/stores/ui';
  3. type Props = {
  4. iconClass?: string,
  5. }
  6. const DrawerToggler: FC<Props> = (props: Props) => {
  7. const { data: isOpened, mutate } = useDrawerOpened();
  8. const iconClass = props.iconClass || 'icon-menu';
  9. return (
  10. <button
  11. className="grw-drawer-toggler btn btn-secondary"
  12. type="button"
  13. aria-expanded="false"
  14. aria-label="Toggle navigation"
  15. onClick={() => mutate(!isOpened)}
  16. >
  17. <i className={iconClass}></i>
  18. </button>
  19. );
  20. };
  21. export default DrawerToggler;