import { useState } from 'react';
import { Link } from 'react-router-dom'
import { Box, Drawer, ToggleButton, ToggleButtonGroup, Toolbar, Typography, IconButton } from '@mui/material';
import ChecklistIcon from '@mui/icons-material/Checklist';
import InfoIcon from '@mui/icons-material/Info';
import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
import MenuIcon from '@mui/icons-material/Menu';
import './SideMenu.css';
export default function SideMenu() {
const [open, setOpen] = useState(true);
const [selectedButton, setSelectedButton] = useState('home');
const toggleDrawer = (x: boolean) => () => {
setOpen(x);
};
const handleSelection = (event: React.MouseEvent<HTMLElement>, newSelection: string) => {
if (newSelection !== null) {
setSelectedButton(newSelection);
}
};
return (
<Box sx={{ display: 'flex' }}>
<IconButton id='hideMenuButton' onClick={toggleDrawer(true)}>
<MenuIcon />
</IconButton>
<Drawer variant="persistent" open={open} className='sideMenu'>
<Toolbar className='menuHeader'>
<Typography variant="h6" color='info'>Items</Typography>
<IconButton onClick={toggleDrawer(false)}>
<ChevronLeftIcon />
</IconButton>
</Toolbar>
<ToggleButtonGroup
orientation="vertical"
value={selectedButton}
exclusive
onChange={handleSelection}
aria-label="navigation menu"
>
<ToggleButton
value="home"
component={Link}
to="/"
aria-label="home"
>
<ChecklistIcon color='success' />
Home
</ToggleButton>
<ToggleButton
value="about"
component={Link}
to="/about"
aria-label="about"
>
<InfoIcon color='warning' />
About
</ToggleButton>
</ToggleButtonGroup>
</Drawer>
</Box>
)
}
|