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
Conversation
Manage this branch in SquashTest this branch here: https://kaedrohosidebar-mobile-enhance-0cyl7.squash.io |
201e0aa
to
d62915c
Compare
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.
Some thoughts:
- Is it necessary for
open
to be separate fromcollapsed
? 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
andcollapsed
we could do away withopen
alltogether, but I may be missing some reason it's essential.
- I'm working solely on mobile, whether
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 |
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.
Question: would <nav>
be more appropriate than <aside>
here?
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.
<aside>
is what we use for the existing sidebar. But perhaps we should be using <nav>
for the main menu portion of it?
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.
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); |
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.
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
?
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.
Oh, good point! Yep I've renamed this to visibleOnMobile
d62915c
to
8b3d3ad
Compare
8b3d3ad
to
59c33de
Compare
* Rename 'open' to 'visibleOnMobile' * Don't initialise 'collapsed' state based on screen size (old code) * Remove main.sidebar--open (not used)
I think so, since |
This PR completely hides the sidebar on mobile, and adds a hamburger icon to allow toggling it.
Extracted from #7362
Based on #7469