Skip to content
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

Merged
merged 8 commits into from
Nov 15, 2024

Conversation

jcardus
Copy link
Contributor

@jcardus jcardus commented Nov 10, 2024

before:
Captura de ecrã 2024-11-10, às 12 56 40

after:
Captura de ecrã 2024-11-10, às 12 56 56

before:
Captura de ecrã 2024-11-10, às 13 25 00

after:
Captura de ecrã 2024-11-10, às 13 24 49

before:
Captura de ecrã 2024-11-10, às 13 27 34

after:
Captura de ecrã 2024-11-10, às 13 27 18

Captura de ecrã 2024-11-10, às 13 26 45

@tananaev
Copy link
Member

I don't think it looks good visually.

@@ -27,7 +27,8 @@ const useStyles = makeStyles((theme) => ({
flexDirection: 'column',
},
desktopDrawer: {
width: theme.dimensions.drawerWidthDesktop,
maxWidth: theme.dimensions.drawerWidthDesktop,
position: 'relative !important',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw why do we need this?

Copy link
Contributor Author

@jcardus jcardus Nov 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise the right content will use the full width and the Drawer will float on top of it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Emulator page also puts "position: relative".
For the !important, don't know why but it doesn't work without it.

@jcardus
Copy link
Contributor Author

jcardus commented Nov 10, 2024

Another option would be to add a collapse button to show only the icons. It would help a lot, especially when you start adding columns to reports.

@tananaev
Copy link
Member

Report columns are usually configurable.

@jcardus
Copy link
Contributor Author

jcardus commented Nov 10, 2024

Yes I known, what I mean is that we quickly get an horizontal scroll bar when we start adding columns to a report.

@tananaev
Copy link
Member

Would be great if we can make them manually adjustable, but current size by default.

@jcardus
Copy link
Contributor Author

jcardus commented Nov 11, 2024

ok, and what about a collapse button on the side bar to gain space?

@tananaev
Copy link
Member

I guess it works if it looks good.

@jcardus
Copy link
Contributor Author

jcardus commented Nov 11, 2024

ok, I'll work on that

@jcardus jcardus reopened this Nov 14, 2024
@jcardus
Copy link
Contributor Author

jcardus commented Nov 14, 2024

Screen.Recording.2024-11-14.at.12.16.06.mov

@@ -22,7 +22,7 @@ const MenuItem = ({
}) => (
<ListItemButton key={link} component={Link} to={link} selected={selected}>
<ListItemIcon>{icon}</ListItemIcon>
<ListItemText primary={title} />
<ListItemText primary={title} sx={{ whiteSpace: 'nowrap' }} />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for? Also probably it should be set as a class.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we change the width of the sidebar, multi word items break the line and then the height of the item grows

const theme = useTheme();
const navigate = useNavigate();

const desktop = useMediaQuery(theme.breakpoints.up('md'));

const [openDrawer, setOpenDrawer] = useState(false);

const toggleDrawer = () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be inlined.

<PageTitle breadcrumbs={breadcrumbs} />
</>
)}
<IconButton color="inherit" edge="start" sx={{ ml: miniVariant ? -2 : 'auto' }} onClick={toggleDrawer}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to be reformatted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which part?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should probably apply classes here as well for readability.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I followed the same pattern as the upper IconButton

@@ -2,6 +2,7 @@ export default {
sidebarWidth: '28%',
sidebarWidthTablet: '52px',
drawerWidthDesktop: '360px',
miniDrawerWidthDesktop: '56px',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some standard size we can use from MUI?

@@ -27,7 +29,11 @@ const useStyles = makeStyles((theme) => ({
flexDirection: 'column',
},
desktopDrawer: {
width: theme.dimensions.drawerWidthDesktop,
width: (props) => (props.miniVariant ? `calc(${theme.spacing(7)} + 1px)` : theme.dimensions.drawerWidthDesktop),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

calc(${theme.spacing(7)} + 1px) doesn't seem right. I know there is a version of a collapsed sidebar. Can we somehow use the size from there?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe even use it as is instead of implementing our own thing.

https://mui.com/material-ui/react-drawer/#mini-variant-drawer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's exactly where that was taken from

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2024-11-14 at 18 12 47

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But can we re-use the component instead of just copy-pasting the style?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a component, it's an example how to do the mini variant.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I didn't realize that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I used the size they use for small screens (spacing(7)) in the example because using the other (spacing(8)) our icons wouldn't be centered. To use the mui example we should use spacing(8). Here's the difference:

using 7:
Screenshot 2024-11-14 at 20 28 55

using 8:
Screenshot 2024-11-14 at 20 28 13

whiteSpace: 'nowrap',
},
});

const MenuItem = ({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can extract it as a common component to avoid duplication?

Comment on lines 9 to 13
const classes = makeStyles({
menuItemText: {
whiteSpace: 'nowrap',
},
});
Copy link
Member

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.

@tananaev tananaev merged commit 62d85d9 into traccar:master Nov 15, 2024
1 check passed
@jcardus jcardus deleted the drawer-width branch November 15, 2024 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants