umami/src/components/common/HamburgerButton.tsx

22 lines
621 B
TypeScript
Raw Normal View History

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