-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
feat(theme-classic): show current locale in mobile language selector #7409
base: main
Are you sure you want to change the base?
feat(theme-classic): show current locale in mobile language selector #7409
Conversation
… mobile navbar locale label
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
⚡️ Lighthouse report for the deploy preview of this PR
|
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.
TBH, the UX is not great as I see it. The same label is repeated twice, which is what we are trying to avoid, both here and for the versions dropdown. What's lacking is the active link highlight color:
In addition to the gray background, we need to apply the primary color. The problem is that the dropdown__link--active
is overridden by menu__link
:
We need to use menu__link--active
instead of dropdown__link--active
on mobile, as we did for the regular navbar dropdowns (through the getInfimaClassName
function)
@massoudmaboudi Do you think highlighting the current locale with the primary color is enough for you?
See also #7430 |
#7430 is a good workaround. but as we have the same issue (duplication of same labels) in the desktop version also, I want to mention that as you noticed, the site maybe is Chinese or Farsi, but suddenly a I have another suggestion which I want to know your opinion also. I don't like my suggestion honestly and I prefer to see duplicate labels still with the current locale duplicated. |
What about adding a |
Too long and again there will be an English word. |
If you translate your theme, neither "current" nor "languages" will be English.
We have the same UX for the versions dropdown as well. If anything, we need to sync the two places. I don't know why we had it in the first place, though. |
so what's your final suggestion, Josh? |
I don't really know😅 I'll be holding my opinion and let @slorber make the call. In the meantime, you can always swizzle your own component. It's a pretty minor change. |
yes yes, I did it already, but lets wait for him then. |
Apparently I introduced these different labels in mobile:
Can't remember exactly what was the motivation, but this UX looks good to me 🤷♂️ I don't mind changing it, but the best UX is quite subjective: I'd suggest to poll our user-base on this first before deciding if it's worth pursuing. It's not because you like it @massoudmaboudi that others will do to. At worst (if community disagree), we could make it easier to swizzle the dropdown label so that you can render it the same on desktop/mobile |
Created a poll to ask our community:
We'll see what users prefer |
@massoudmaboudi I believe there is a misunderstanding here, after reading your tweet: https://twitter.com/MaboudiMassoud/status/1529765739053580289 Of course, it does not look very good to have a "Languages" label in English, when the site is in Farsi. The only reason it's not translated is that... you forgot to translate it here: https://github.com/facebook/docusaurus/blob/main/packages/docusaurus-theme-translations/locales/fa/theme-common.json#L55 The real question is not "Languages" vs "فارسی" But rather: "زبان ها" vs "فارسی" Does it make more sense? |
It looks like there's no clear winner in the poll atm: Some facts:
Some arguments to keep 1) Another arg that make sense and confirms that having different label/ux for desktop/mobile looks better: Considering this, I'd rather keep using 1) as the default implementation. If we allow 2, that would either be with swizzle or with an opt-in option. Using 2) as default would be more complicated for users to move to 1), particularly if we drop the existing localized label by default. Should we close this PR, or do you want to update it and make it easier to enable 2) ? |
You are right, that's what I explained in the reply to my tweet. There is a third option to keep Versions as it is, but change |
I prefer to add an But I should read your technical implementation on how to add it in docusarous.config.js |
Why not then 👍 How do we design this API? Note if this option only applies to the mobile drawer, we should make it clear it only applies on mobile. Eventually, providing 2 options for flexibility and consistency? For example: {
type: 'docsVersionDropdown',
mobileLabelType: "static" | "dynamic",
desktopLabelType: "static" | "dynamic",
} Any opinion on this API @Josh-Cena @massoudmaboudi ? Do you want to implement it yourself? |
There's quite the same idea in #5415. I'm personally in favor of it. |
But to solve this a different design would be needed as you need as the current one use a union type while the other issue probably needs more freedom to pass arbitrary labels: |
😵💫 |
Oh I get what you mean. Yeah yeah, what about |
That's also why I'd prefer to have a 2nd enum string value: to keep it by default. But I'm not a fan to mix string enums with string type, as somehow it implies that some values are "magical" |
Right, hence |
|
What about using |
Honestly, I like the option to change in both mobile and desktop. But I doubt my implementation be as professional as yours since I am a backend developer :) |
mobileLabelType: undefined | "current-choice" | { text: string } => defaults to undefined
desktopLabelType: undefined | "current-choice" | { text: string } => defaults to "current-choice" Is this good enough?
For Desktop, which is using "current-choice" by default (ie default value), if the user wants to display the "static" label instead, I'm not sure passing "undefined" is a good idea, nor that it will play well with Joi default value that will keep being applied.
No problem, just tell us to work on it if you won't |
Please take care of this feature request like the others :) |
Pre-flight checklist
Motivation
Test Plan
Test links
Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/
Related issues/PRs
fix #7404