umami/src/components/common/HamburgerButton.tsx

23 lines
652 B
TypeScript
Raw Normal View History

import { Button, Icon } from 'react-basics';
2022-03-01 03:39:37 +01:00
import { useState } from 'react';
2023-01-31 06:44:07 +01:00
import MobileMenu from './MobileMenu';
import Icons from 'components/icons';
2022-03-01 03:39:37 +01:00
2023-11-14 06:36:52 +01:00
export function HamburgerButton({ menuItems }: { menuItems: any[] }) {
2022-03-01 03:39:37 +01:00
const [active, setActive] = useState(false);
2023-04-10 05:22:28 +02:00
const handleClick = () => setActive(state => !state);
const handleClose = () => setActive(false);
2022-03-01 03:39:37 +01:00
return (
<>
2023-04-10 05:22:28 +02:00
<Button variant="quiet" onClick={handleClick}>
2023-01-31 06:44:07 +01:00
<Icon>{active ? <Icons.Close /> : <Icons.Menu />}</Icon>
</Button>
2022-03-01 03:39:37 +01:00
{active && <MobileMenu items={menuItems} onClose={handleClose} />}
</>
);
}
2023-04-21 17:00:42 +02:00
export default HamburgerButton;