-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Add drawer menu desktop #2195
Add drawer menu desktop #2195
Conversation
15cd0d8
to
2c5239b
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.
I found a couple small issues and also have a few ideas/questions/suggestions/ Take them all with a grain of salt though as I'm new to the codebase! Let me know if any of them don't make sense or you want to chat about them.
sections/header.liquid
Outdated
{%- endfor -%} | ||
</ul> | ||
</nav> | ||
{%- if section.settings.menu_type_desktop != 'drawer' -%} |
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.
Non blocking: You could also do this with CSS by conditionally giving nav
a class of drawer
, and using a rule like
@media screen and (min-width: 990px) {
.header__inline-menu:not(.drawer) {
display: block;
}
I'm not sure it matters much, but it would be consistent with what we do for small screens where the nav
is part of the DOM but not displayed.
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.
Thanks for other opinion. Both ways work for me but the current one seems more consistent to me within header.liquid
file.
Let's see what other devs think.
assets/base.css
Outdated
.header--middle-left { | ||
grid-template-areas: 'heading navigation icons'; | ||
grid-template-columns: auto auto 1fr; | ||
grid-template-columns: minmax(3.2rem, auto) auto 1fr; |
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.
Non blocking: What is the 3.2rem
space? Looks like a magic number here, would it be helpful to put it in a named variable?
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.
3.2rem
is a size of<summary>
element. When I move the element to the left outside of the grid I need the column in the grid to stay the same size.- I agree that we could put in a named variable, on the other hand, as I can see in this file we use named variables only for color properties and parameters we set the vales in JS. I would keep it simple as is.
assets/base.css
Outdated
left: 0; | ||
height: calc(var(--viewport-height, 100vh) - (var(--header-bottom-position, 100%))); | ||
height: calc(var(--viewport-height, 100vh) - (var(--header-bottom-position, 100%)) - 1px); |
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.
I found a small issue if I change screen size from small to large while the menu drawer is open. The overlay appears partially overtop of the nav bar. Is the header bottom position set with JS or something? If so you might need to add a media query change listener.
Screen.Recording.2023-01-11.at.10.02.45.AM.mov
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.
@eugenekasimov I thought that this was happening on the editor + fixed, let's make sure it is not happening on the store.
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.
Good catch @stufreen, thanks. Actually I found that it's also happening from large to small screen changing but the issue appears at the bottom. I'm going to fix it.
Updated
I fixed the bug and added a description of my approach into the decision log (4).
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.
On mobile, it looks like some styles are not applied properly. Some of the menu items remain highlighted and it's confusing, as I don't know if they're highlighted because they're visited links, or because they're selected.
Never mind, I see this is happening on main
too
drawer.menu.mobile.mp4
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.
LGTM with a couple small changes made ✨
assets/global.js
Outdated
this.onResize = () => { | ||
document.documentElement.style.setProperty('--header-bottom-position', `${parseInt(this.header.getBoundingClientRect().bottom - this.borderOffset)}px`); | ||
document.documentElement.style.setProperty('--viewport-height', `${window.innerHeight}px`); | ||
}; |
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.
I can see that what we did yesterday didn't work (onResize() {
) because this
wasn't bound. However I think it's cleaner to use a class method with an arrow function, which is also valid and will automatically bind this
:
onResize = () => {
...
}
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.
Yeah, and I even tried .bind(this)
and it didn't work. But I didn't try to use an arrow function instead of a normal one. Now this works and looks better I agree. Thanks.
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.
Always using arrow functions prevents these kinds of bugs. You don't have to think whether you need to .bind(this)
or not and if you need to omit .bind(this)
so that this
refers to something else, you're probably writing a code smell (IMO). In that case, it'd be better to move function outside of class. All on*
functions should be arrow functions. For the sake of consistency, you could have all JS class functions be arrow functions. There's probably ESLint rule that you can enable for this.
EDIT: I didn't find the ESLint rule. Maybe there's one, I just didn't spend too much time looking into this.
@@ -430,13 +435,18 @@ class HeaderDrawer extends MenuDrawer { | |||
}); | |||
|
|||
summaryElement.setAttribute('aria-expanded', true); | |||
window.addEventListener('resize', this.onResize); |
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.
Just summarizing a conversation we had yesterday:
resize
listener can be a bit heavy since it's called repeatedly when you resize a window; however- it's appropriate here because the overlay needs to be resized along with the browser. There's no getting around redrawing the overlay each time the browser is resized vertically.
As you pointed out, there's a bug in production where the overlay gets cut off if the user enlarges the browser window vertically. This will fix it.
display: none; | ||
} | ||
|
||
.menu-drawer__utility-links:has(ul:empty) { |
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.
I guess the alternative would be to do something like @LucasLacerdaUX did here where we check in Liquid if the social icons are set and if so omit the whole area: #2226
Personally I am OK with a progressive enhancement here. It will work for almost all buyers and not look terribly broken for the rest.
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.
Just setting it to request changes
so we can fix some of the issues I found
0e887ed
848ef5a
to
ae042a3
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.
🚀
@eugenekasimov I found a bug that I think is related to that merge. Page section has lost its width reference, becoming too wide for readable content. Video reference Do you prefer I open a new issue and take it from there? |
* shopify/main: Improve image sizes in the multicolumn section (Shopify#2349) Fix the Page section's width. (Shopify#2364) Update 12 translation files (Shopify#2366) Removing "my" from cart popup notification (Shopify#2353) [Cart.js] Fix fetch url so it's not hard coded (Shopify#2357) (Shopify#2365) Update 1 translation file (Shopify#2352) Default Follow on Shop to on [Header] Add localization selectors (Shopify#2258) Remove async CSS pattern where it may introduce layout shifts (Shopify#2270) Change rich text section heading to be of type inline_richtext, also moved rte styling into base.css (Shopify#2326) Add drawer menu desktop (Shopify#2195) Make header image preload and proper width (Shopify#2307)
* Add drawer option to the menu settings * Add logic and styles for drawer menu * Add a new breakpoint for desktop layout. Implement movement of close button for the drawer. * Change a css rule order * Minor changes in css to position close-button correctly * Minor changes in css to position close-button correctly * Minor changes in base.css and header.liquid * Fix resizing issue for open drawer * Clean up JS logic. * Remove repositioning of closing button X. Align log-in icon and nav. Decrease the header padding for tablet. * Remove unnecessary css rule. * Minor refactoring * Hide login in the drawer for tablet/desktop. * Refactoring css * Change naming for grid system * Refactor header.liquid. Remove else and add elsif. * Polish css. Add role navigation for drawer-menu. * Remove role navigation and add nav tag * Remove nav * Change order of conditional classes. Correct indentation. * Minor chnages in grid system. * Move the cart-notification according to the menu type. * Fix typo in comment. * Minor fix for middle-center logo position. * Add condition for .header-middle-center for drawer * Minor changes in css for .header__search * Refactor and polish css. * Update 20 translation files --------- Co-authored-by: translation-platform[bot] <34770790+translation-platform[bot]@users.noreply.github.com>
PR Summary:
This PR adds a new desktop menu type "Drawer".
Key updates:
32px
.50px
to32px
. The header is not perfectly aligned with a content anymore.closing X
button,nav
andlog in
icon have been aligned for desktop and tablet layouts.nav
andlog in
icon have been aligned for mobile layout.Why are these changes introduced?
Fixes #1455.
Decision log
margin-left: -0.75rem
forheader__heading-link
and it's applied all the time no matter where theheader__heading-link
was positioned . I made it more targeted for left positions only.header__heading-link
when it's positioned in the center.width
andheight
in real time.height
andwidth
of the window. I had to deal with resizing a browser.height
but for thewidth
we need to know when it passes a threshold of990px
back-and-forward only. Since I couldn't find any good way to listen forheight
changes only the event listener listens for changes in both directions. But I believe that it's a very edge case itself and it should not cost a problem.Visual impact on existing themes
Before
After
Testing steps/scenarios
Top left
andMiddle left
are supposed to look the same.Demo links
Checklist