Skip to content

Conversation

@lemagnetic
Copy link
Contributor

@lemagnetic lemagnetic commented Jan 7, 2026

What's the purpose of this pull request?

This PR implements a new I18nSelector component 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

  1. I18nSelector Component (packages/core/src/components/i18n/I18nSelector/)

    • Responsive component that switches between Popover (desktop) and SlideOver (mobile) based on screen size
    • Manages language and currency selection state
    • Receives all content (languages, currencies, labels, descriptions) via props
    • Includes a reusable I18nSelectorContent subcomponent for the form fields
  2. I18nButton Component (updated)

    • Button that triggers the I18nSelector
    • Displays current locale and currency (e.g., "EN/BRL")
    • Receives configuration from CMS via Navbar section
    • Uses default English texts when CMS values are not provided

Library Enhancements

  1. Popover Component (enhanced)

    • Added optional portal rendering support via usePortal prop (default: false)
    • Added wrapperProps for customizing the portal wrapper div
    • Uses position: fixed when portal is enabled for accurate viewport positioning
    • Maintains backward compatibility with existing implementations
  2. SlideOver Component (enhanced)

    • Added new bottomSide direction for bottom-to-top animations
    • Supports vertical slide animations with proper CSS transitions
    • Works seamlessly with existing leftSide and rightSide directions

CMS Integration

  1. CMS Configuration (sections.json)
    • Added i18nSelector object in Navbar navigation schema
    • Configurable fields: title, languageLabel, currencyLabel, description, saveLabel
    • All fields have English defaults
    • Separate from i18nButton configuration for better organization

User Experience

  • Desktop: Popover appears below the I18nButton with form fields and save button
  • Mobile: SlideOver slides up from the bottom with header, content, and footer

How to test it?

Link Preview

Starters Deploy Preview

References

@lemagnetic lemagnetic added the enhancement New feature or request label Jan 7, 2026
@codesandbox-ci
Copy link

codesandbox-ci bot commented Jan 7, 2026

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.

@lemagnetic lemagnetic marked this pull request as ready for review January 8, 2026 14:01
@lemagnetic lemagnetic requested a review from a team as a code owner January 8, 2026 14:01
@lemagnetic lemagnetic requested review from gabpaladino and lucasfp13 and removed request for a team January 8, 2026 14:01
@hellofanny hellofanny mentioned this pull request Jan 9, 2026
* Whether to render the Popover using a React portal.
* @default false
*/
usePortal?: boolean
Copy link
Contributor

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?

Suggested change
usePortal?: boolean
enablePortal?: boolean

{i18nButton.shouldDisplayI18nButton && (
<I18nButton icon={i18nButton?.icon} />
{i18nButton?.shouldDisplayI18nButton && (
<I18nButton
Copy link
Contributor

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',
Copy link
Contributor

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);
Copy link
Contributor

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);
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this was a test 🙈
image

Suggested change
color: var(--palette-neutral-color-neutral-4, #999);
color: var(--fs-color-neutral-4, #999);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants