2022-12-27 01:57:59 +01:00
|
|
|
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';
|
2023-04-08 07:03:52 +02:00
|
|
|
import useMessages from 'hooks/useMessages';
|
2023-01-31 06:44:07 +01:00
|
|
|
import styles from './HamburgerButton.module.css';
|
2022-03-01 03:39:37 +01:00
|
|
|
|
|
|
|
export default function HamburgerButton() {
|
2023-04-08 07:03:52 +02:00
|
|
|
const { formatMessage, labels } = useMessages();
|
2022-03-01 03:39:37 +01:00
|
|
|
const [active, setActive] = useState(false);
|
|
|
|
|
2023-04-08 07:03:52 +02:00
|
|
|
const menuItems = [
|
|
|
|
{
|
|
|
|
label: formatMessage(labels.dashboard),
|
|
|
|
value: '/dashboard',
|
|
|
|
},
|
|
|
|
{ label: formatMessage(labels.realtime), value: '/realtime' },
|
|
|
|
{
|
|
|
|
label: formatMessage(labels.settings),
|
|
|
|
value: '/settings',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: formatMessage(labels.profile),
|
|
|
|
value: '/settings/profile',
|
|
|
|
},
|
|
|
|
{ label: formatMessage(labels.logout), value: '/logout' },
|
|
|
|
];
|
|
|
|
|
2022-03-01 03:39:37 +01:00
|
|
|
function handleClick() {
|
|
|
|
setActive(state => !state);
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleClose() {
|
|
|
|
setActive(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2022-12-27 01:57:59 +01:00
|
|
|
<Button className={styles.button} onClick={handleClick}>
|
2023-01-31 06:44:07 +01:00
|
|
|
<Icon>{active ? <Icons.Close /> : <Icons.Menu />}</Icon>
|
2022-12-27 01:57:59 +01:00
|
|
|
</Button>
|
2022-03-01 03:39:37 +01:00
|
|
|
{active && <MobileMenu items={menuItems} onClose={handleClose} />}
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|