diff --git a/apps/web/src/shared/assets/svgs/close_icon.svg b/apps/web/src/shared/assets/svgs/close_icon.svg new file mode 100644 index 0000000..37bdd6a --- /dev/null +++ b/apps/web/src/shared/assets/svgs/close_icon.svg @@ -0,0 +1,3 @@ + + + diff --git a/apps/web/src/shared/assets/svgs/menu_icon.svg b/apps/web/src/shared/assets/svgs/menu_icon.svg new file mode 100644 index 0000000..f4e1040 --- /dev/null +++ b/apps/web/src/shared/assets/svgs/menu_icon.svg @@ -0,0 +1,3 @@ + + + diff --git a/apps/web/src/shared/components/layout/header/header.css.ts b/apps/web/src/shared/components/layout/header/header.css.ts index 588ffee..d5c241d 100644 --- a/apps/web/src/shared/components/layout/header/header.css.ts +++ b/apps/web/src/shared/components/layout/header/header.css.ts @@ -1,4 +1,4 @@ -import { style } from '@vanilla-extract/css'; +import { style, styleVariants } from '@vanilla-extract/css'; import { globalTheme } from '../../../styles/globalTheme.css'; export const headerStyle = style({ @@ -31,3 +31,84 @@ export const navStyle = style({ gap: '4rem', color: globalTheme.colors.blue_33, }); + +// under 700 style + +export const under700headerStyle = style({ + display: 'flex', + flexDirection: 'column', + borderBottom: `1px solid ${globalTheme.colors.gray_stroke}`, + zIndex: 10, + overflow: 'hidden', +}); + +export const under700topDivStyle = style({ + display: 'flex', + justifyContent: 'space-between', + alignItems: 'center', + paddingLeft: '2.8rem', + paddingRight: '2rem', + minHeight: '6rem', +}); + +export const under700topRightDivStyle = style({ + display: 'flex', + alignItems: 'center', + gap: 19, +}); + +const under700commonButtonStyle = style({ + ...globalTheme.fonts.mobileBodyMed16, + padding: '0.4rem 2.1rem', + borderRadius: 40, +}); + +export const under700buttonStyle = styleVariants({ + primary: [ + under700commonButtonStyle, + { + backgroundColor: globalTheme.colors.blue_main, + color: globalTheme.colors.white, + }, + ], + secondary: [ + under700commonButtonStyle, + { + backgroundColor: globalTheme.colors.gray_bg_04, + color: globalTheme.colors.gray_19, + }, + ], +}); + +export const under700ulCommonStyle = style({ + borderBottom: `1px solid ${globalTheme.colors.gray_stroke}`, + width: '100%', + position: 'absolute', + overflow: 'hidden', + transition: 'max-height 0.5s ease, opacity 0.5s ease', +}); + +export const under700ulStyle = styleVariants({ + open: [ + under700ulCommonStyle, + { + maxHeight: '30rem', + opacity: 1, + }, + ], + close: [ + under700ulCommonStyle, + { + maxHeight: '0', + opacity: 0, + }, + ], +}); + +export const under700listStyle = style({ + ...globalTheme.fonts.mobileBodyReg16, + padding: '1.8rem 2.7rem', + width: '100%', + color: globalTheme.colors.gray_19, + backgroundColor: globalTheme.colors.white, +}); diff --git a/apps/web/src/shared/components/layout/header/header.tsx b/apps/web/src/shared/components/layout/header/header.tsx index 4c4a88e..5f83588 100644 --- a/apps/web/src/shared/components/layout/header/header.tsx +++ b/apps/web/src/shared/components/layout/header/header.tsx @@ -1,34 +1,131 @@ 'use client'; import Link from 'next/link'; +import React, { useRef, useState } from 'react'; import { useGetUserInfo } from '@/shared/apis/auth/queries'; +import CloseIcon from '@/shared/assets/svgs/close_icon.svg'; import Logo from '@/shared/assets/svgs/logo_sm.svg'; +import HamburgerIcon from '@/shared/assets/svgs/menu_icon.svg'; import CircleImage from '../../circleImage/circleImage'; -import { contentStyle, headerStyle, navStyle } from './header.css'; +import { + contentStyle, + headerStyle, + navStyle, + under700headerStyle, + under700listStyle, + under700buttonStyle, + under700ulStyle, + under700topDivStyle, + under700topRightDivStyle, +} from './header.css'; const Header = () => { + const [isUnder700, setIsUnder700] = useState(false); + const [isMenuOpen, setIsMenuOpen] = useState(false); + const [isLoggedIn, setIsLoggedIn] = useState(false); + const handleToggleMenu = () => setIsMenuOpen((prev) => !prev); + const handleMenuClose = () => setIsMenuOpen(false); + const { data } = useGetUserInfo(); const profileLink = data ? `/user/${data.username}` : '/auth?step=github'; + const menuRef = useRef(null); + + React.useEffect(() => { + const handleResize = () => { + if (window.innerWidth <= 700) { + console.log('화면 너비가 700px 이하입니다.'); + setIsUnder700(true); + } else { + console.log('화면 너비가 700px 초과입니다.'); + setIsUnder700(false); + } + }; + + window.addEventListener('resize', handleResize); + handleResize(); // 초기 렌더링 시 체크 + + return () => { + window.removeEventListener('resize', handleResize); + }; + }, []); + return ( - - - - - - - school rank - regional rank - board - about - - - - - - - + <> + {!isUnder700 ? ( + + + + + + + school rank + regional rank + board + about + + + + + + + + ) : ( + + + + + + + + + + {isLoggedIn ? '내 정보' : '로그인'} + + + + + {isMenuOpen ? : } + + + + + + + + + school rank + + + + + + region rank + + + + + + board + + + + + + about + + + + + + )} + > ); };