-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize drawer width to reduce wasted space in reports and settings #1295
Changes from 7 commits
15b0e38
547dafb
f4cef90
736f6fd
5e2b79a
9161274
613e7ec
21e598e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import makeStyles from '@mui/styles/makeStyles'; | ||
import { ListItemButton, ListItemIcon, ListItemText } from '@mui/material'; | ||
import { Link } from 'react-router-dom'; | ||
import React from 'react'; | ||
|
||
const MenuItem = ({ | ||
title, link, icon, selected, | ||
}) => { | ||
const classes = makeStyles({ | ||
menuItemText: { | ||
whiteSpace: 'nowrap', | ||
}, | ||
}); | ||
return ( | ||
<ListItemButton key={link} component={Link} to={link} selected={selected}> | ||
<ListItemIcon>{icon}</ListItemIcon> | ||
<ListItemText primary={title} className={classes.menuItemText} /> | ||
</ListItemButton> | ||
); | ||
}; | ||
|
||
export default MenuItem; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ import { | |
} from '@mui/material'; | ||
import makeStyles from '@mui/styles/makeStyles'; | ||
import ArrowBackIcon from '@mui/icons-material/ArrowBack'; | ||
import ChevronLeftIcon from '@mui/icons-material/ChevronLeft'; | ||
import ChevronRightIcon from '@mui/icons-material/ChevronRight'; | ||
import MenuIcon from '@mui/icons-material/Menu'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { useTranslation } from './LocalizationProvider'; | ||
|
@@ -27,7 +29,11 @@ const useStyles = makeStyles((theme) => ({ | |
flexDirection: 'column', | ||
}, | ||
desktopDrawer: { | ||
width: theme.dimensions.drawerWidthDesktop, | ||
width: (props) => (props.miniVariant ? `calc(${theme.spacing(8)} + 1px)` : theme.dimensions.drawerWidthDesktop), | ||
transition: theme.transitions.create('width', { | ||
easing: theme.transitions.easing.sharp, | ||
duration: theme.transitions.duration.enteringScreen, | ||
}), | ||
}, | ||
mobileDrawer: { | ||
width: theme.dimensions.drawerWidthTablet, | ||
|
@@ -66,14 +72,17 @@ const PageTitle = ({ breadcrumbs }) => { | |
}; | ||
|
||
const PageLayout = ({ menu, breadcrumbs, children }) => { | ||
const classes = useStyles(); | ||
const [miniVariant, setMiniVariant] = useState(false); | ||
const classes = useStyles({ miniVariant }); | ||
const theme = useTheme(); | ||
const navigate = useNavigate(); | ||
|
||
const desktop = useMediaQuery(theme.breakpoints.up('md')); | ||
|
||
const [openDrawer, setOpenDrawer] = useState(false); | ||
|
||
const toggleDrawer = () => setMiniVariant(!miniVariant); | ||
|
||
return desktop ? ( | ||
<div className={classes.desktopRoot}> | ||
<Drawer | ||
|
@@ -82,10 +91,17 @@ const PageLayout = ({ menu, breadcrumbs, children }) => { | |
classes={{ paper: classes.desktopDrawer }} | ||
> | ||
<Toolbar> | ||
<IconButton color="inherit" edge="start" sx={{ mr: 2 }} onClick={() => navigate('/')}> | ||
<ArrowBackIcon /> | ||
{!miniVariant && ( | ||
<> | ||
<IconButton color="inherit" edge="start" sx={{ mr: 2 }} onClick={() => navigate('/')}> | ||
<ArrowBackIcon /> | ||
</IconButton> | ||
<PageTitle breadcrumbs={breadcrumbs} /> | ||
</> | ||
)} | ||
<IconButton color="inherit" edge="start" sx={{ ml: miniVariant ? -2 : 'auto' }} onClick={toggleDrawer}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this needs to be reformatted. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. which part? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. got it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should probably apply classes here as well for readability. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I followed the same pattern as the upper IconButton |
||
{miniVariant ? <ChevronRightIcon /> : <ChevronLeftIcon />} | ||
</IconButton> | ||
<PageTitle breadcrumbs={breadcrumbs} /> | ||
</Toolbar> | ||
<Divider /> | ||
{menu} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please move this outside for consistency. Similar to how we have it in other places.