-
Notifications
You must be signed in to change notification settings - Fork 79
feat: add I18nSelector component #3164
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
base: feat/multilanguage
Are you sure you want to change the base?
Conversation
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
| * Whether to render the Popover using a React portal. | ||
| * @default false | ||
| */ | ||
| usePortal?: boolean |
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.
suggestion: How about using enablePortal instead for this prop?
| usePortal?: boolean | |
| enablePortal?: boolean |
| {i18nButton.shouldDisplayI18nButton && ( | ||
| <I18nButton icon={i18nButton?.icon} /> | ||
| {i18nButton?.shouldDisplayI18nButton && ( | ||
| <I18nButton |
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 was thinking.. what do you think of creating a new section to handle i18nSelector?
so we may use it separately later. Something similar on what we do for (region) RegionButton
|
|
||
| const I18nButton = ({ icon }: { icon: string }) => { | ||
| const MOCK_LANGUAGES: Record<string, string> = { | ||
| 'pt-BR': 'Português', |
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.
question: Is this just for testing purposes right?
Because we already have this information in i18n in discovery.config.
We can retrieve this map from there...
| @@ -0,0 +1,67 @@ | |||
| [data-fs-i18n-selector] { | |||
| --fs-popover-margin: 0; | |||
| --fs-popover-border-radius: var(--fs-border-radius, 2px); | |||
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.
👀 we don't have this fallback value pattern in our codebase. I'm not sure about introducing it now because it can mess with theming.. our current patterns seem to be, if not variable found, the default is used and the user might notice if different and add it. 🤔
| margin-bottom: var(--fs-spacing-3); | ||
| font-size: var(--fs-text-size-1); | ||
| font-weight: var(--fs-text-weight-medium); | ||
| color: var(--palette-neutral-color-neutral-4, #999); |
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.

What's the purpose of this pull request?
This PR implements a new
I18nSelectorcomponent that allows users to select their preferred language and currency. The component provides a seamless experience across devices, using a Popover on desktop and a SlideOver on mobile. All UI texts are configurable through the CMS, making it easy for store administrators to customize the experience for their audience.How it works?
The implementation consists of several key components and enhancements:
Core Components
I18nSelector Component (
packages/core/src/components/i18n/I18nSelector/)I18nSelectorContentsubcomponent for the form fieldsI18nButton Component (updated)
Library Enhancements
Popover Component (enhanced)
usePortalprop (default:false)wrapperPropsfor customizing the portal wrapper divposition: fixedwhen portal is enabled for accurate viewport positioningSlideOver Component (enhanced)
bottomSidedirection for bottom-to-top animationsleftSideandrightSidedirectionsCMS Integration
sections.json)i18nSelectorobject in Navbar navigation schematitle,languageLabel,currencyLabel,description,saveLabeli18nButtonconfiguration for better organizationUser Experience
How to test it?
Link Preview
Starters Deploy Preview
References