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';
|
|
|
|
import { FormattedMessage } from 'react-intl';
|
2023-01-31 06:44:07 +01:00
|
|
|
import MobileMenu from './MobileMenu';
|
|
|
|
import Icons from 'components/icons';
|
|
|
|
import styles from './HamburgerButton.module.css';
|
2022-03-01 03:39:37 +01:00
|
|
|
|
|
|
|
const menuItems = [
|
|
|
|
{
|
|
|
|
label: <FormattedMessage id="label.dashboard" defaultMessage="Dashboard" />,
|
|
|
|
value: '/dashboard',
|
|
|
|
},
|
|
|
|
{ label: <FormattedMessage id="label.realtime" defaultMessage="Realtime" />, value: '/realtime' },
|
2023-01-10 08:59:26 +01:00
|
|
|
{
|
2023-01-19 00:05:39 +01:00
|
|
|
label: <FormattedMessage id="label.settings" defaultMessage="AppLayout" />,
|
2023-02-04 17:59:52 +01:00
|
|
|
value: '/input',
|
2023-01-10 08:59:26 +01:00
|
|
|
},
|
2022-03-01 03:39:37 +01:00
|
|
|
{
|
|
|
|
label: <FormattedMessage id="label.profile" defaultMessage="Profile" />,
|
2023-02-04 17:59:52 +01:00
|
|
|
value: '/input/profile',
|
2022-03-01 03:39:37 +01:00
|
|
|
},
|
|
|
|
{ label: <FormattedMessage id="label.logout" defaultMessage="Logout" />, value: '/logout' },
|
|
|
|
];
|
|
|
|
|
|
|
|
export default function HamburgerButton() {
|
|
|
|
const [active, setActive] = useState(false);
|
|
|
|
|
|
|
|
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} />}
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|