|
| 1 | +import * as Common from "@frontend/common"; |
| 2 | +import { Box, Stack, styled, Typography } from "@mui/material"; |
| 3 | +import * as React from "react"; |
| 4 | +import { Link, useLocation } from "react-router-dom"; |
| 5 | + |
| 6 | +import { HamburgerButton } from "./HamburgerButton"; |
| 7 | +import { MobileLanguageToggle } from "./MobileLanguageToggle"; |
| 8 | +import { MobileNavigation } from "./MobileNavigation"; |
| 9 | +import { useAppContext } from "../../../../contexts/app_context"; |
| 10 | + |
| 11 | +interface MobileHeaderProps { |
| 12 | + isNavigationOpen?: boolean; |
| 13 | + onToggleNavigation?: () => void; |
| 14 | +} |
| 15 | + |
| 16 | +export const MobileHeader: React.FC<MobileHeaderProps> = ({ isNavigationOpen = false, onToggleNavigation }) => { |
| 17 | + const { siteMapNode, language } = useAppContext(); |
| 18 | + const location = useLocation(); |
| 19 | + const [internalNavigationOpen, setInternalNavigationOpen] = React.useState(false); |
| 20 | + |
| 21 | + const navigationOpen = onToggleNavigation ? isNavigationOpen : internalNavigationOpen; |
| 22 | + const toggleNavigation = onToggleNavigation || (() => setInternalNavigationOpen(!internalNavigationOpen)); |
| 23 | + |
| 24 | + const isMainPath = location.pathname === "/"; |
| 25 | + |
| 26 | + const handleLanguageChange = (newLanguage: string) => { |
| 27 | + // TODO: 언어 변경 로직 구현 |
| 28 | + console.log("Language changed to:", newLanguage); |
| 29 | + }; |
| 30 | + |
| 31 | + return ( |
| 32 | + <> |
| 33 | + <MobileHeaderContainer isOpen={navigationOpen} isMainPath={isMainPath}> |
| 34 | + <LeftContent> |
| 35 | + <HamburgerButton isOpen={navigationOpen} onClick={toggleNavigation} isMainPath={isMainPath} /> |
| 36 | + <LogoAndTextContainer> |
| 37 | + <Link to="/" style={{ textDecoration: "none" }}> |
| 38 | + <Stack direction="row" alignItems="center" spacing={0.375}> |
| 39 | + <Common.Components.PythonKorea style={{ width: 29, height: 29 }} /> |
| 40 | + <Typography |
| 41 | + variant="h6" |
| 42 | + sx={{ |
| 43 | + color: isMainPath ? "white" : "rgba(18, 109, 127, 0.6)", |
| 44 | + fontSize: 18, |
| 45 | + fontWeight: 600, |
| 46 | + }} |
| 47 | + > |
| 48 | + 파이콘 한국 2025 |
| 49 | + </Typography> |
| 50 | + </Stack> |
| 51 | + </Link> |
| 52 | + </LogoAndTextContainer> |
| 53 | + </LeftContent> |
| 54 | + |
| 55 | + <MobileLanguageToggle currentLanguage={language} onLanguageChange={handleLanguageChange} isMainPath={isMainPath} /> |
| 56 | + </MobileHeaderContainer> |
| 57 | + |
| 58 | + <MobileNavigation isOpen={navigationOpen} onClose={() => toggleNavigation()} siteMapNode={siteMapNode} /> |
| 59 | + </> |
| 60 | + ); |
| 61 | +}; |
| 62 | + |
| 63 | +const MobileHeaderContainer = styled("header")<{ isOpen: boolean; isMainPath: boolean }>(({ theme, isOpen, isMainPath }) => ({ |
| 64 | + position: "fixed", |
| 65 | + top: 0, |
| 66 | + left: 0, |
| 67 | + right: 0, |
| 68 | + |
| 69 | + display: isOpen ? "none" : "flex", |
| 70 | + alignItems: "center", |
| 71 | + justifyContent: "space-between", |
| 72 | + |
| 73 | + width: "100%", |
| 74 | + height: 60, |
| 75 | + |
| 76 | + padding: "15px 23px", |
| 77 | + |
| 78 | + backgroundColor: isMainPath ? "rgba(182, 216, 215, 0.1)" : "#B6D8D7", |
| 79 | + backdropFilter: "blur(8px)", |
| 80 | + WebkitBackdropFilter: "blur(8px)", |
| 81 | + color: isMainPath ? "white" : "rgba(18, 109, 127, 0.6)", |
| 82 | + |
| 83 | + zIndex: theme.zIndex.appBar + 100000, |
| 84 | +})); |
| 85 | + |
| 86 | +const LeftContent = styled(Box)({ |
| 87 | + display: "flex", |
| 88 | + alignItems: "center", |
| 89 | + gap: 17, |
| 90 | +}); |
| 91 | + |
| 92 | +const LogoAndTextContainer = styled(Box)({ |
| 93 | + display: "flex", |
| 94 | + alignItems: "center", |
| 95 | +}); |
0 commit comments