-
Notifications
You must be signed in to change notification settings - Fork 146
fix!: AppHeader の言語選択 UI に IntlProvider で渡した locale や availableLocales が反映されるようにする #5848
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: master
Are you sure you want to change the base?
Conversation
commit: |
IntlProvider を再定義してしまっていたのを削除
export type Locale = keyof typeof locales | ||
|
||
export const localeMap: Record<Locale, string> = { |
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.
ここが locale の型の SSoT。
locales 内のファイル名を key としている
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.
Pull Request Overview
This PR fixes the AppHeader language selection UI to properly use locale and availableLocales from IntlProvider instead of requiring them as separate props, making the API more consistent and centralized.
- Refactors AppHeader's locale props to only require the
onSelectLocale
callback, removingselectedLocale
- Updates language selection UI to filter available languages based on IntlProvider's
availableLocales
- Consolidates locale type definitions and removes duplicate locale mapping logic
Reviewed Changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
packages/smarthr-ui/src/types/index.ts | Removes unused LocaleMap export |
packages/smarthr-ui/src/types/Locale.ts | Removes LocaleMap type definition |
packages/smarthr-ui/src/intl/localeMap.ts | Updates locale map with proper typing and reordering |
packages/smarthr-ui/src/intl/IntlProvider.tsx | Updates type references to use centralized Locale type |
packages/smarthr-ui/src/components/Header/stories/LanguageSwitcher.stories.tsx | Updates to use centralized locale map and fixes typo |
packages/smarthr-ui/src/components/Header/LanguageSwitcher/LanguageSwitcher.tsx | Updates to filter languages by availableLocales |
packages/smarthr-ui/src/components/AppHeader/types.ts | Simplifies LocaleProps to only include onSelectLocale |
packages/smarthr-ui/src/components/AppHeader/stories/args.tsx | Updates story args to match new API |
packages/smarthr-ui/src/components/AppHeader/stories/VRTAppHeader.stories.tsx | Updates VRT stories to use globals instead of args |
packages/smarthr-ui/src/components/AppHeader/multilingualization/types.ts | Removes redundant type definitions |
packages/smarthr-ui/src/components/AppHeader/multilingualization/index.ts | Removes redundant exports |
packages/smarthr-ui/src/components/AppHeader/hooks/useLocale.tsx | Removes unused locale context hook |
packages/smarthr-ui/src/components/AppHeader/components/mobile/UserInfo.tsx | Updates to pass locale prop directly instead of using context |
packages/smarthr-ui/src/components/AppHeader/components/mobile/MobileHeader.tsx | Updates to pass locale prop to child components |
packages/smarthr-ui/src/components/AppHeader/components/mobile/LanguageSelector.tsx | Updates to use IntlProvider's locale and availableLocales |
packages/smarthr-ui/src/components/AppHeader/components/desktop/DesktopHeader.tsx | Updates to use IntlProvider's locale and pass localeProps |
packages/smarthr-ui/src/components/AppHeader/AppHeader.tsx | Removes IntlProvider wrapper and locale context |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
関連URL
https://smarthr.atlassian.net/browse/MCBPJ-16
概要
AppHeader コンポーネントに、IntlProvider で定義した locale や availableLocales が渡っておらず、AppHeader に個別に props として渡さないといけない状態だったのを、IntlProvider に渡した props だけで完結するようにした。
これに伴い、AppHeader の props の locale の型が、
{ selectedLocale, onSelectLocale }
から{ onSelectLocale }
に変更になるため、Breaking Change としています。変更内容
確認方法
packages/smarthr-ui/.storybook/preview.tsx:93
で、IntlProvider にavailableLocales={['ja', 'en-us', 'ja-easy']}
のように使用する言語を渡して、Storybook 上で AppHeader を閲覧して、availableLocales に渡した言語のみ言語選択 UI に表示されていることを確認するキャプチャ