Skip to content
This repository has been archived by the owner on Jun 10, 2024. It is now read-only.

Commit

Permalink
chore: added active-language prop to language-provider
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuzhy-Deriv committed Dec 4, 2023
1 parent 32bd2fd commit 07ae049
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
5 changes: 4 additions & 1 deletion apps/deriv-hk/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ function CustomApp({ Component, pageProps }: AppProps) {
<SharedLinkProvider DerivLink={NextSharedLink}>
<BreakpointProvider>
<ThemeProvider theme="light">
<LanguageProvider langItems={langItemsHK}>
<LanguageProvider
langItems={langItemsHK}
activeLanguage={langItemsHK.en}
>
<>
<Head>
<meta name="color-scheme" content="light dark" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type Story = StoryObj<typeof meta>;
const Template: Story = {
render: ({ ...args }) => {
return (
<LanguageProvider langItems={langItemsHK}>
<LanguageProvider langItems={langItemsHK} activeLanguage={langItemsHK.en}>
<MainNavigation />
</LanguageProvider>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ type Story = StoryObj<typeof meta>;
const Template: Story = {
render: ({ ...args }) => {
return (
<LanguageProvider langItems={langItemsROW}>
<LanguageProvider
langItems={langItemsROW}
activeLanguage={langItemsROW.en}
>
<MainRowNavigation />
</LanguageProvider>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ export interface LanguageProviderProps {
children: React.ReactNode;
langItems: LangItems;
onLangSelect?: (lang: LangItem) => void;
activeLanguage: LangItem;
}
export const LanguageProvider: React.FC<LanguageProviderProps> = ({
children,
langItems,
onLangSelect,
activeLanguage,
}) => {
const [activeLanguage, setActiveLanguage] = useState(langItems.en);
const [showLangContent, setShowLangContent] = useState(false);
const [showMobileLanguages, setShowMobileLanguages] = useState(false);

Expand All @@ -25,7 +26,6 @@ export const LanguageProvider: React.FC<LanguageProviderProps> = ({
}, []);

const selectLanguage = (item: LangItem) => {
setActiveLanguage(item);
setShowLangContent(false);
onLangSelect?.(item);
};
Expand Down

0 comments on commit 07ae049

Please sign in to comment.