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

Completely hide sidebar in mobile mode #7481

Merged
merged 4 commits into from Sep 2, 2021

Conversation

kaedroho
Copy link
Contributor

This PR completely hides the sidebar on mobile, and adds a hamburger icon to allow toggling it.

image
image

Extracted from #7362
Based on #7469

@squash-labs
Copy link

squash-labs bot commented Aug 31, 2021

Manage this branch in Squash

Test this branch here: https://kaedrohosidebar-mobile-enhance-0cyl7.squash.io

@kaedroho kaedroho force-pushed the sidebar-mobile-enhancements-2 branch from 201e0aa to d62915c Compare August 31, 2021 09:20
Copy link
Member

@jacobtoppm jacobtoppm left a comment

Choose a reason for hiding this comment

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

Some thoughts:

  • Is it necessary for open to be separate from collapsed? A few scenarios.
    • I'm working solely on mobile, whether open==collapsed doesn't affect me
    • I'm working solely at desktop width, similarly unaffected
    • I'm resizing my screen. Now, if I have the opened/wide menu at mobile width and I expand again, the menu collapses, which feels weird. I feel like just using the isMobile and collapsed we could do away with open alltogether, but I may be missing some reason it's essential.

Generally this is looking great though, and worked very well when I was testing

@@ -180,8 +184,9 @@ export const Sidebar: React.FunctionComponent<SidebarProps> = (
<aside
Copy link
Member

Choose a reason for hiding this comment

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

Question: would <nav> be more appropriate than <aside> here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

<aside> is what we use for the existing sidebar. But perhaps we should be using <nav> for the main menu portion of it?

Copy link
Member

Choose a reason for hiding this comment

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

That feels right to me

// 'open' indicates whether the sidebar is visible or not.
// this is meant to be used to show/hide the menu on small screens.
// it only has effect on small screens.
const [open, setOpen] = React.useState(false);
Copy link
Member

Choose a reason for hiding this comment

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

Could we rename open to something more intuitive here? I feel like the set of variables we've got to describe the menu state is getting slightly confusing with this addition (since I'd probably expect open to be eg the opposite of collapsed, but they're really describing different things). Maybe visible?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, good point! Yep I've renamed this to visibleOnMobile

wagtail/admin/templates/wagtailadmin/admin_base.html Outdated Show resolved Hide resolved
@kaedroho kaedroho force-pushed the sidebar-mobile-enhancements-2 branch from d62915c to 8b3d3ad Compare August 31, 2021 11:54
@kaedroho kaedroho force-pushed the sidebar-mobile-enhancements-2 branch from 8b3d3ad to 59c33de Compare September 1, 2021 09:46
* Rename 'open' to 'visibleOnMobile'
* Don't initialise 'collapsed' state based on screen size (old code)
* Remove main.sidebar--open (not used)
@kaedroho
Copy link
Contributor Author

kaedroho commented Sep 1, 2021

Is it necessary for open to be separate from collapsed? A few scenarios.

I think so, since collapsed is persisted in a cookie but I don't think we want to do this with open

@kaedroho kaedroho merged commit 45b7788 into wagtail:main Sep 2, 2021
@kaedroho kaedroho deleted the sidebar-mobile-enhancements-2 branch September 2, 2021 15:38
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.

None yet

3 participants