-
Notifications
You must be signed in to change notification settings - Fork 193
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
Support for menu on mobile #120
Comments
Besides cleaning up the CSS, I'm also not a fan of the non-compliance for closing the menu. It looks like @andybrewer had some opinions as well in #21. This is nice so long as it's not opinionated regarding styling, etc. Can we look into making the menu compliant and then I can take a sweep on removing CSS that was copy/pasted and isn't needed? |
Thank you for the feedback! Full thought, in order (click to toggle)
Anyway, thanks for the feedback again! Gives me some nice action points. |
On revisiting this one weekend later, I realized there are actually two consecutive use-cases
I think that use-case 1. should be resolved first, to give a uniform way the menu should look on smaller (mobile) screens without any hiding. If/When that has been resolved, it would be trivial to create a toggle button. Whether that should then be part of core MVP.css is still up for debate. With styling for smaller screens, it might not even be needed... The smallest CSS I could come up with, in order to display the menu on smaller screens, is: @media (max-width: 768px) {
nav {
flex-wrap: wrap; /* Allow the links to drop below the logo */
}
nav ul li {
width: calc(100% - 1em); /* Make sure each link has enough room to have a separate line */
}
nav ul li ul {
display: block; /* Make the sub-menus visible (as there is no "hover" on mobile) */
}
} The result (as can be seen on https://codepen.io/potherca/pen/abgRpGQ) is:
Various minor tweaks could be made, for instance:
I've added these tweaks commented out in the linked CodePen, so they can be played around with. @ChristopherBilg Do you think I've missed anything? |
This is great. I agree that the first point is more important for MVP.css and that the second point, in my opinion, doesn't make sense to add unless it can be added in with the same level of seamlessness that you implemented the first point. As far as this codepen goes, it looks great. I think for the minor tweaks, definitely the first for removing borders. I'm not in favor nor against the second minor tweaks, although as I play with the codepen, I'm wondering if we can make this functional for recursive depths of nested lists. I'm seeing distortion adding in another level. |
Yeah, I just did a re-run with more (sub-)menu items and I think the This will cause a large menu. The question then becomes whether that is okay or that a Regarding shadows, without looks better IMHO.
Anyway, that would give us: @media (max-width: 768px) {
nav {
flex-wrap: wrap; /* Allow the links to drop below the logo */
}
nav ul li {
width: calc(100% - 1em); /* Make sure each link has enough room to have a separate line */
}
nav ul li ul {
border: none; box-shadow: none; /* Remove the shadow */
display: block; /* Make the sub-menus visible (as there is no "hover" on mobile) */
position: static; /* Make the menu-items stretch the whole width (excluding padding/margin */
}
} |
Fantastic! Want to open this in a PR and I'll get it approved right away? I think not having a max-height for an MVP makes sense, and if user's want a max-height they can trivially add that in. What are your thoughts on that? |
Agreed. I've opened #124 to add the proposed styles. |
As I mentioned in #21, having generic support for the menu on mobile would be most awesome.
So I had a stab at making a backward-compatible, CSS only, plug-and-play implementation.
It can be seen in action at https://contrib.pother.ca/MetroJS/examples/
(Make sure to resize the screen to less than 800px or increase the font-size x8.
Part of the CSS could be removed, as it is copy-pasted from existing mvp.css code.
The CSS is thus (click to toggle)
To activate it, a
<button>
needs to be added in the<nav>
. This can be an empty button:A
--menu-label
is added to allow easy changing the toggle button text.A fully fledge (almost) aria compliant button could also be used:
The only thing that doesn't comply is that the close button can not be tabbed to.
Everything else "just works" as the menu is not opened unless tabbed to.
So... Thoughts?
The text was updated successfully, but these errors were encountered: