Skip to content

Commit 4bc0be5

Browse files
committed
feat : 모바일 UI 언어 전환 기능 추가
1 parent 825f727 commit 4bc0be5

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

apps/pyconkr/src/components/layout/Header/Mobile/MobileHeader.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface MobileHeaderProps {
1414
}
1515

1616
export const MobileHeader: React.FC<MobileHeaderProps> = ({ isNavigationOpen = false, onToggleNavigation }) => {
17-
const { siteMapNode, language } = useAppContext();
17+
const { siteMapNode } = useAppContext();
1818
const location = useLocation();
1919
const [internalNavigationOpen, setInternalNavigationOpen] = React.useState(false);
2020

@@ -23,11 +23,6 @@ export const MobileHeader: React.FC<MobileHeaderProps> = ({ isNavigationOpen = f
2323

2424
const isMainPath = location.pathname === "/";
2525

26-
const handleLanguageChange = (newLanguage: string) => {
27-
// TODO: 언어 변경 로직 구현
28-
console.log("Language changed to:", newLanguage);
29-
};
30-
3126
return (
3227
<>
3328
<MobileHeaderContainer isOpen={navigationOpen} isMainPath={isMainPath}>
@@ -52,7 +47,7 @@ export const MobileHeader: React.FC<MobileHeaderProps> = ({ isNavigationOpen = f
5247
</LogoAndTextContainer>
5348
</LeftContent>
5449

55-
<MobileLanguageToggle currentLanguage={language} onLanguageChange={handleLanguageChange} isMainPath={isMainPath} />
50+
<MobileLanguageToggle isMainPath={isMainPath} />
5651
</MobileHeaderContainer>
5752

5853
<MobileNavigation isOpen={navigationOpen} onClose={() => toggleNavigation()} siteMapNode={siteMapNode} />

apps/pyconkr/src/components/layout/Header/Mobile/MobileLanguageToggle.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
import { ButtonBase, styled } from "@mui/material";
22
import * as React from "react";
33

4+
import { LOCAL_STORAGE_LANGUAGE_KEY } from "../../../../consts/local_stroage";
5+
import { useAppContext } from "../../../../contexts/app_context";
6+
47
interface MobileLanguageToggleProps {
5-
currentLanguage: string;
6-
onLanguageChange: (newLanguage: string) => void;
78
isMainPath?: boolean;
89
}
910

10-
export const MobileLanguageToggle: React.FC<MobileLanguageToggleProps> = ({ currentLanguage, onLanguageChange, isMainPath = true }) => {
11+
export const MobileLanguageToggle: React.FC<MobileLanguageToggleProps> = ({ isMainPath = true }) => {
12+
const { language, setAppContext } = useAppContext();
13+
14+
const handleLanguageChange = (newLanguage: "ko" | "en") => {
15+
localStorage.setItem(LOCAL_STORAGE_LANGUAGE_KEY, newLanguage);
16+
setAppContext((ps) => ({ ...ps, language: newLanguage }));
17+
};
1118
return (
1219
<ToggleContainer isMainPath={isMainPath}>
13-
<LanguageButton isActive={currentLanguage === "ko"} isMainPath={isMainPath} onClick={() => onLanguageChange("ko")}>
20+
<LanguageButton isActive={language === "ko"} isMainPath={isMainPath} onClick={() => handleLanguageChange("ko")}>
1421
KO
1522
</LanguageButton>
16-
<LanguageButton isActive={currentLanguage === "en"} isMainPath={isMainPath} onClick={() => onLanguageChange("en")}>
23+
<LanguageButton isActive={language === "en"} isMainPath={isMainPath} onClick={() => handleLanguageChange("en")}>
1724
EN
1825
</LanguageButton>
1926
</ToggleContainer>

apps/pyconkr/src/components/layout/Header/Mobile/MobileNavigation.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import * as R from "remeda";
88

99
import { HamburgerButton } from "./HamburgerButton";
1010
import { MobileLanguageToggle } from "./MobileLanguageToggle";
11-
import { useAppContext } from "../../../../contexts/app_context";
1211
import { SignInButton } from "../../SignInButton";
1312

1413
type MenuType = BackendAPISchemas.NestedSiteMapSchema;
@@ -29,7 +28,6 @@ interface NavigationState {
2928
}
3029

3130
export const MobileNavigation: React.FC<MobileNavigationProps> = ({ isOpen, onClose, siteMapNode }) => {
32-
const { language } = useAppContext();
3331
const location = useLocation();
3432
const [navState, setNavState] = React.useState<NavigationState>({
3533
level: "depth1",
@@ -80,11 +78,6 @@ export const MobileNavigation: React.FC<MobileNavigationProps> = ({ isOpen, onCl
8078
resetNavigation();
8179
};
8280

83-
const handleLanguageChange = (newLanguage: string) => {
84-
// TODO: 언어 변경 로직 구현
85-
console.log("Language changed to:", newLanguage);
86-
};
87-
8881
const renderDepth1Menu = () => {
8982
if (!siteMapNode) return null;
9083

@@ -198,7 +191,7 @@ export const MobileNavigation: React.FC<MobileNavigationProps> = ({ isOpen, onCl
198191

199192
<BottomActions isMainPath={isMainPath}>
200193
<Stack direction="row" alignItems="center" spacing={6.25}>
201-
<MobileLanguageToggle currentLanguage={language} onLanguageChange={handleLanguageChange} isMainPath={isMainPath} />
194+
<MobileLanguageToggle isMainPath={isMainPath} />
202195
<SignInButton isMobile={true} isMainPath={isMainPath} />
203196
</Stack>
204197
</BottomActions>

0 commit comments

Comments
 (0)