This repository has been archived by the owner on Sep 6, 2024. It is now read-only.
forked from facebook/create-react-app
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ Simplify structure of localizations components
- Loading branch information
1 parent
375f38d
commit e2ec903
Showing
11 changed files
with
56 additions
and
97 deletions.
There are no files selected for viewing
24 changes: 0 additions & 24 deletions
24
...te/src/modules/core/modules/localization/components/AppLocalizations/AppLocalizations.tsx
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
...cript/template/src/modules/core/modules/localization/components/AppLocalizations/index.ts
This file was deleted.
Oops, something went wrong.
36 changes: 22 additions & 14 deletions
36
...template/src/modules/core/modules/localization/components/Localizations/Localizations.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,27 @@ | ||
import React from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
import { translateSelector } from '@ackee/jerome'; | ||
import type { ReactNode } from 'react'; | ||
import { | ||
intlData, | ||
// @use-antd-module-begin | ||
antdData, | ||
// @use-antd-module-end | ||
} from '../../config'; | ||
|
||
import LocalizationsRaw from '../LocalizationsRaw' | ||
import type { LocalizationsRawProps } from '../LocalizationsRaw' | ||
// @use-antd-module-begin | ||
import { LocalizationsAntd } from '../LocalizationsAntd'; | ||
// @use-antd-module-end | ||
import { LocalizationsRaw } from '../LocalizationsRaw'; | ||
|
||
export interface LocalizationsProps extends Omit<LocalizationsRawProps, 'locale'> { | ||
interface AppLocalizationsProps { | ||
children: ReactNode | ReactNode[]; | ||
} | ||
|
||
const Localizations = (props: LocalizationsProps) => { | ||
const { locale } = useSelector(translateSelector) | ||
|
||
return ( | ||
<LocalizationsRaw locale={locale} {...props} /> | ||
) | ||
} | ||
|
||
export default Localizations; | ||
export const Localizations = ({ children }: AppLocalizationsProps) => ( | ||
// @use-antd-module-begin | ||
<LocalizationsAntd antdLocaleData={antdData}> | ||
{/* // @use-antd-module-end */} | ||
<LocalizationsRaw intlMessages={intlData}>{children}</LocalizationsRaw> | ||
{/* // @use-antd-module-begin */} | ||
</LocalizationsAntd> | ||
// @use-antd-module-end | ||
); |
3 changes: 1 addition & 2 deletions
3
...pescript/template/src/modules/core/modules/localization/components/Localizations/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
export { default } from './Localizations'; | ||
export type { LocalizationsProps } from './Localizations'; | ||
export * from './Localizations'; |
17 changes: 17 additions & 0 deletions
17
.../src/modules/core/modules/localization/components/LocalizationsAntd/LocalizationsAntd.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react'; | ||
import type { ReactNode } from 'react'; | ||
import ConfigProvider from 'antd/es/config-provider'; | ||
import type { Locale as AntdLocaleData } from 'antd/es/locale-provider'; | ||
import { useSelector } from 'react-redux'; | ||
import { translateSelector } from '@ackee/jerome'; | ||
|
||
export interface LocalizationsAntdProps { | ||
antdLocaleData: Record<string, AntdLocaleData>; | ||
children: ReactNode; | ||
} | ||
|
||
export const LocalizationsAntd = ({ antdLocaleData, children }: LocalizationsAntdProps) => { | ||
const { locale } = useSelector(translateSelector); | ||
|
||
return <ConfigProvider locale={antdLocaleData[locale]}>{children}</ConfigProvider>; | ||
}; |
1 change: 1 addition & 0 deletions
1
...ript/template/src/modules/core/modules/localization/components/LocalizationsAntd/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './LocalizationsAntd'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...cript/template/src/modules/core/modules/localization/components/LocalizationsRaw/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
export { default } from './LocalizationsRaw'; | ||
export type { LocalizationsRawProps } from './LocalizationsRaw'; | ||
export * from './LocalizationsRaw'; |
42 changes: 0 additions & 42 deletions
42
...ules/core/modules/localization/components/LocalizationsWithAntd/LocalizationsWithAntd.tsx
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
.../template/src/modules/core/modules/localization/components/LocalizationsWithAntd/index.ts
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
packages/cra-template-typescript/template/src/modules/core/modules/localization/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export { default as Localizations } from './components/AppLocalizations'; | ||
export { Localizations } from './components/Localizations'; | ||
export { default as reducer } from './services/reducer'; | ||
export { saga } from '@ackee/jerome'; |