Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 7x 7x 18x 18x 18x 1x 1x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x | /**
* @file HamburgerMenu.tsx
* @module app/HamburgerMenu
*
* @summary
* Hamburger menu (4-line icon) coordinator managing menu state and popover.
* Orchestrates menu content rendering with theme, locale, and logout callbacks.
*
* @enterprise
* - Separates menu state management from content rendering
* - Delegates menu sections to MenuSectionsRenderer
* - Responsive popover menu (scrollable on mobile)
* - Clean separation of concerns
*/
import * as React from 'react';
import {
IconButton,
Menu,
} from '@mui/material';
import MenuIcon from '@mui/icons-material/Menu';
import { useTranslation } from 'react-i18next';
import { MenuSectionsRenderer, LogoutMenuAction } from './MenuContent';
import type { SupportedLocale } from '../../theme';
interface HamburgerMenuProps {
/** Current theme mode (light or dark) */
themeMode: 'light' | 'dark';
/** Callback when theme mode changes */
onThemeModeChange: (mode: 'light' | 'dark') => void;
/** Current locale setting */
locale: SupportedLocale;
/** Callback when locale changes */
onLocaleChange: (locale: SupportedLocale) => void;
/** Callback for logout action */
onLogout: () => void;
}
/**
* Hamburger menu component.
*
* Manages menu popover state and renders all menu sections.
* Comprehensive app options:
* - My Profile (name, email/demo message, role)
* - Appearance (theme toggle, table density)
* - Language & Region (language, date format, number format)
* - Notifications (low-stock alerts)
* - Help & Documentation (links)
* - System Info (environment, backend URL, version)
* - Logout
*
* @param props - Component props
* @returns JSX element rendering hamburger menu with popover
*/
export default function HamburgerMenu({
themeMode,
onThemeModeChange,
locale,
onLocaleChange,
onLogout,
}: HamburgerMenuProps) {
const { t } = useTranslation(['common']);
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
const open = Boolean(anchorEl);
// Open menu when hamburger button is clicked
const handleOpen = (event: React.MouseEvent<HTMLButtonElement>) => {
setAnchorEl(event.currentTarget);
};
// Close menu
const handleClose = () => {
setAnchorEl(null);
};
return (
<>
{/* Hamburger Button */}
<IconButton
onClick={handleOpen}
title={t('actions.menu', 'Menu')}
sx={{
color: 'inherit',
'&:hover': {
bgcolor: 'action.hover',
},
}}
>
<MenuIcon />
</IconButton>
{/* Menu Popover */}
<Menu
anchorEl={anchorEl}
open={open}
onClose={handleClose}
slotProps={{
paper: {
sx: {
maxWidth: 360,
maxHeight: '80vh',
overflowY: 'auto',
bgcolor: 'background.paper',
},
},
}}
transformOrigin={{ horizontal: 'right', vertical: 'top' }}
anchorOrigin={{ horizontal: 'right', vertical: 'bottom' }}
>
{/* Menu Sections with Dividers */}
<MenuSectionsRenderer
themeMode={themeMode}
onThemeModeChange={onThemeModeChange}
locale={locale}
onLocaleChange={onLocaleChange}
onClose={handleClose}
/>
{/* Logout Action */}
<LogoutMenuAction onLogout={onLogout} onClose={handleClose} />
</Menu>
</>
);
}
|