Skip to content

Conversation

nabeliwo
Copy link
Member

@nabeliwo nabeliwo commented Sep 21, 2025

関連URL

https://smarthr.atlassian.net/browse/MCBPJ-16

概要

AppHeader コンポーネントに、IntlProvider で定義した locale や availableLocales が渡っておらず、AppHeader に個別に props として渡さないといけない状態だったのを、IntlProvider に渡した props だけで完結するようにした。

これに伴い、AppHeader の props の locale の型が、{ selectedLocale, onSelectLocale } から { onSelectLocale } に変更になるため、Breaking Change としています。

変更内容

  • AppHeader の props から locale 関連のものを削除して、言語選択 UI で言語を選択した際のコールバックのみ渡せるようにした
  • 言語選択 UI の言語一覧を、すべての言語が出てしまっていたのを IntlProvider に渡した言語のみ表示するようにした

確認方法

  • packages/smarthr-ui/.storybook/preview.tsx:93 で、IntlProvider に availableLocales={['ja', 'en-us', 'ja-easy']} のように使用する言語を渡して、Storybook 上で AppHeader を閲覧して、availableLocales に渡した言語のみ言語選択 UI に表示されていることを確認する
  • その他、意図しないデグレがないことをさらっと見ていただけますと 🙏

キャプチャ

デスクトップ モバイル
image image

Copy link

pkg-pr-new bot commented Sep 21, 2025

Open in StackBlitz

npm i https://pkg.pr.new/kufu/smarthr-ui@5848

commit: 4928d7e

@nabeliwo nabeliwo changed the title WIP AppHeader 多言語化対応 fix: AppHeader の言語選択 UI に IntlProvider で渡した availableLocales が反映されるようにする Sep 21, 2025
@nabeliwo nabeliwo changed the title fix: AppHeader の言語選択 UI に IntlProvider で渡した availableLocales が反映されるようにする fix!: AppHeader の言語選択 UI に IntlProvider で渡した availableLocales が反映されるようにする Sep 22, 2025
@nabeliwo nabeliwo changed the title fix!: AppHeader の言語選択 UI に IntlProvider で渡した availableLocales が反映されるようにする fix!: AppHeader の言語選択 UI に IntlProvider で渡した locale や availableLocales が反映されるようにする Sep 22, 2025
Comment on lines +3 to +5
export type Locale = keyof typeof locales

export const localeMap: Record<Locale, string> = {
Copy link
Member Author

Choose a reason for hiding this comment

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

ここが locale の型の SSoT。
locales 内のファイル名を key としている

@nabeliwo nabeliwo marked this pull request as ready for review September 22, 2025 00:48
@nabeliwo nabeliwo requested a review from a team as a code owner September 22, 2025 00:48
@nabeliwo nabeliwo requested review from oti, schktjm, Qs-F, ntfd0, NoTouch1665 and Copilot and removed request for a team, oti and schktjm September 22, 2025 00:48
Copy link

@Copilot Copilot AI left a 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, removing selectedLocale
  • 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant