-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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
fix: wrong padding for single row mobile nav #1191
fix: wrong padding for single row mobile nav #1191
Conversation
Deploy preview for docusaurus-preview ready! Built with commit 908cac2 |
86a86e5
to
1b16063
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.
This looks good, pending some review comments to be addressed before we can merge this 😄
v1/lib/core/Site.js
Outdated
const hasLanguageDropdown = | ||
env.translation.enabled && env.translation.enabledLanguages().length > 1; | ||
const ordinaryHeaderLinks = headerLinks.filter( | ||
link => !link.languages && !link.search, |
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.
Can you change this to link.languages || link.search
? It's easier to read.
v1/lib/core/Site.js
Outdated
link => !link.languages && !link.search, | ||
); | ||
const hasOrdinaryHeaderLinks = ordinaryHeaderLinks.length > 1; | ||
return !hasLanguageDropdown && !hasOrdinaryHeaderLinks; |
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.
This too.
v1/lib/core/Site.js
Outdated
mobileNavHasOneRow(headerLinks) { | ||
const hasLanguageDropdown = | ||
env.translation.enabled && env.translation.enabledLanguages().length > 1; | ||
const ordinaryHeaderLinks = headerLinks.filter( |
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.
Change to headerLinks.some()
and you don't need to check for .length > 1
.
1b16063
to
908cac2
Compare
@yangshun fixed! |
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.
Awesome, thank you!
Motivation
Fix #1187. Padding for certain components assumed that there will always be two rows in the nav bar in mobile view. Here we handle the case where the nav bar only has a single row on mobile devices.
I'm not 100% certain if
Site.js
is the best place to check whether the mobile nav bar occupies a single row, or if I'm applying thesingleRowMobileNav
class at the most suitable place. Please do let me know if there is a better way to achieve this!Have you read the Contributing Guidelines on pull requests?
Yes.
Test Plan
We test for the cases where there are two rows in the mobile nav bar (at least 1 doc/blog/page/href/language link) and when there is one row in the mobile nav bar (no doc/blog/page/href/language link).
Padding for mobile devices should be correct when there are two rows in the mobile nav bar:
Padding for mobile devices should be correct when there is one row in the mobile nav bar:
Padding for full screen devices should be correct when there are two rows in the mobile nav bar:
Padding for full screen devices should be correct when there is one row in the mobile nav bar