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

refactor: move color mode toggle in navbar on mobiles #6976

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lex111
Copy link
Contributor

@lex111 lex111 commented Mar 23, 2022

Motivation

Suggest finally moving the color mode toggle to the navbar itself, instead of the sidebar on mobiles. Since now it represents a compact button, it fits nicely into the navbar area. It's also more consistent with desktop design, and just it's clearer to the user that color scheme of a site can be changed at all.

However there's another, more important reason: the mobile sidebar didn't have much space for long site title, and I saw that some site title couldn't always be fully displayed. Just to give you an example:

Before After
image image

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

Before After
image image

Related PRs

@lex111 lex111 added the pr: polish This PR adds a very minor behavior improvement that users will enjoy. label Mar 23, 2022
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Mar 23, 2022
@lex111 lex111 force-pushed the lex111/color-mode-toggle-mobile branch from a462588 to 516a1b7 Compare March 23, 2022 21:43
@netlify
Copy link

netlify bot commented Mar 23, 2022

[V2]

Name Link
🔨 Latest commit 516a1b7
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/623b94976b1bd90008b9284f
😎 Deploy Preview https://deploy-preview-6976--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions
Copy link

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟠 Performance 63
🟢 Accessibility 100
🟢 Best practices 92
🟢 SEO 100
🟢 PWA 90

Lighthouse ran on https://deploy-preview-6976--docusaurus-2.netlify.app/

@github-actions
Copy link

Size Change: -71 B (0%)

Total Size: 805 kB

Filename Size Change
website/build/assets/css/styles.********.css 104 kB -99 B (0%)
website/build/assets/js/main.********.js 612 kB +49 B (0%)
ℹ️ View Unchanged
Filename Size Change
website/.docusaurus/globalData.json 49.9 kB 0 B
website/build/index.html 38.8 kB -21 B (0%)

compressed-size-action

key="toggle"
className={isMobile ? 'margin-left--sm' : undefined}
/>,
!hasExplicitSearchItem || isMobile ? <SearchBar /> : null,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This needs a key

Comment on lines +69 to +74
if (isMobile) {
[rightMostItems[0], rightMostItems[1]] = [
rightMostItems[1]!,
rightMostItems[0]!,
];
}
Copy link
Collaborator

@Josh-Cena Josh-Cena Mar 24, 2022

Choose a reason for hiding this comment

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

Since the search button just opens a modal, can we not do the swap and always put the search as the rightmost item?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did this intentionally because some custom search input can be expanded by click, so it's probably better to try to freeze the color mode toggle position. I may be wrong though, and it's a completely normal option, just compare:

Option 1 (default) Option 2 (with swapping items on mobiles)
ezgif com-gif-maker (2) ezgif com-gif-maker (1)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see. If there are custom search inputs that don't open a modal then it makes sense

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not so fan of this change in terms of UX and SSR/CSR behavior

This swap of theme/search leads to an issue.

On a mobile with slow connexion:

  • you see first theme/search
  • it then flips to search/theme

Copy link
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

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

The mobile hydration layout change should rather be avoided

This is a quite significant UX change, wonder if we shouldn't poll our community about it?

Some sites might be annoyed by this change, particularly those that want to keep a larger theme toggle instead of a theme switch button (for example https://supabase.com/docs ?)

This is not so easy for users to revert to the old behavior too if they want that.

Wonder if we shouldn't have a broader redesign of the mobile theme design, including the API

For example maybe we should be able to set a smaller label for mobile? or having another array of navbar items dedicated for mobile?

Comment on lines +69 to +74
if (isMobile) {
[rightMostItems[0], rightMostItems[1]] = [
rightMostItems[1]!,
rightMostItems[0]!,
];
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not so fan of this change in terms of UX and SSR/CSR behavior

This swap of theme/search leads to an issue.

On a mobile with slow connexion:

  • you see first theme/search
  • it then flips to search/theme

@lex111
Copy link
Contributor Author

lex111 commented Mar 24, 2022

Yeah, I don't really like the current implementation either, so guess additional refactoring is needed here. And I agree about doing a community poll about the current change.

@slorber slorber marked this pull request as draft March 25, 2022 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: polish This PR adds a very minor behavior improvement that users will enjoy.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants