|
| 1 | +"use client"; |
| 2 | + |
| 3 | +import { styled } from "styled-components"; |
| 4 | +import { colors } from "@/styles/theme"; |
| 5 | +import { useState } from "react"; |
| 6 | +import { subtitleData, titleData } from "@/lib/navbar/navbarData"; |
| 7 | + |
| 8 | +export default function Navbar() { |
| 9 | + const [openNavbar, setOpenNavbar] = useState(false); |
| 10 | + |
| 11 | + const handleNavbarTrue = () => { |
| 12 | + setOpenNavbar(true); |
| 13 | + }; |
| 14 | + |
| 15 | + const handleNavbarFalse = () => { |
| 16 | + setOpenNavbar(false); |
| 17 | + }; |
| 18 | + |
| 19 | + return ( |
| 20 | + <> |
| 21 | + <Layout> |
| 22 | + <LogoBox> |
| 23 | + <Logo src={"/navbar/kobaco_logo.svg"} alt={"kobaco"} /> |
| 24 | + </LogoBox> |
| 25 | + <TitleBox |
| 26 | + onClick={handleNavbarTrue} |
| 27 | + onMouseEnter={handleNavbarTrue} |
| 28 | + onMouseLeave={handleNavbarFalse} |
| 29 | + > |
| 30 | + {titleData.map((title: string, index: number) => { |
| 31 | + return <Title key={index}>{title}</Title>; |
| 32 | + })} |
| 33 | + </TitleBox> |
| 34 | + <AuthBox> |
| 35 | + <div>로그인</div> |
| 36 | + <div>|</div> |
| 37 | + <div>회원가입</div> |
| 38 | + </AuthBox> |
| 39 | + {openNavbar && ( |
| 40 | + <IndexBox |
| 41 | + onMouseEnter={handleNavbarTrue} |
| 42 | + onMouseLeave={handleNavbarFalse} |
| 43 | + > |
| 44 | + {subtitleData.map((title: string[], index: number) => ( |
| 45 | + <SubtitleBox key={index}> |
| 46 | + {title.map((subtitle: string) => { |
| 47 | + return <Title key={subtitle}>{subtitle}</Title>; |
| 48 | + })} |
| 49 | + </SubtitleBox> |
| 50 | + ))} |
| 51 | + </IndexBox> |
| 52 | + )} |
| 53 | + </Layout> |
| 54 | + </> |
| 55 | + ); |
| 56 | +} |
| 57 | + |
| 58 | +const Layout = styled.div` |
| 59 | + display: flex; |
| 60 | + width: 90%; |
| 61 | + height: 5.5rem; |
| 62 | + justify-content: center; |
| 63 | + align-items: center; |
| 64 | + margin: 0 auto; |
| 65 | + gap: 2rem; |
| 66 | + background: ${colors.background}; |
| 67 | + position: fixed; |
| 68 | + top: 0; |
| 69 | + left: 0; |
| 70 | + right: 0; |
| 71 | + z-index: 999; |
| 72 | +`; |
| 73 | + |
| 74 | +const LogoBox = styled.div` |
| 75 | + width: 20%; |
| 76 | + height: 100%; |
| 77 | + display: flex; |
| 78 | + align-items: center; |
| 79 | + justify-content: center; |
| 80 | +`; |
| 81 | + |
| 82 | +const Logo = styled.img` |
| 83 | + width: 100%; |
| 84 | + height: 100%; |
| 85 | +`; |
| 86 | + |
| 87 | +const TitleBox = styled.div` |
| 88 | + display: flex; |
| 89 | + flex-direction: row; |
| 90 | + width: 100%; |
| 91 | + height: 100%; |
| 92 | + justify-content: center; |
| 93 | + align-items: center; |
| 94 | + cursor: pointer; |
| 95 | +`; |
| 96 | + |
| 97 | +const Title = styled.div` |
| 98 | + color: ${colors.white}; |
| 99 | + font-size: 1rem; |
| 100 | + width: 60%; |
| 101 | + display: flex; |
| 102 | + justify-content: center; |
| 103 | + white-space: nowrap; |
| 104 | +
|
| 105 | + &:hover { |
| 106 | + color: ${colors.mainLight1}; |
| 107 | + transition: 0.1s; |
| 108 | + } |
| 109 | +`; |
| 110 | + |
| 111 | +const AuthBox = styled.div` |
| 112 | + display: flex; |
| 113 | + width: 20%; |
| 114 | + flex-direction: row; |
| 115 | + justify-content: center; |
| 116 | + align-items: center; |
| 117 | + gap: 1rem; |
| 118 | + cursor: pointer; |
| 119 | + div { |
| 120 | + color: ${colors.white}; |
| 121 | + font-size: 0.8rem; |
| 122 | + } |
| 123 | +`; |
| 124 | + |
| 125 | +const IndexBox = styled.div` |
| 126 | + width: 76%; |
| 127 | + height: 18rem; |
| 128 | + display: flex; |
| 129 | + justify-content: center; |
| 130 | + align-items: center; |
| 131 | + background: rgba(26, 26, 26, 0.4); |
| 132 | + backdrop-filter: blur(25px); |
| 133 | + border: 1px solid #333; |
| 134 | + border-radius: 20px; |
| 135 | + margin: 0 auto; |
| 136 | + padding: 0 7rem; |
| 137 | + position: fixed; |
| 138 | + top: 5.5rem; |
| 139 | + left: 0; |
| 140 | + right: 0; |
| 141 | +`; |
| 142 | + |
| 143 | +const SubtitleBox = styled.div` |
| 144 | + width: 100%; |
| 145 | + height: 100%; |
| 146 | + display: flex; |
| 147 | + flex-direction: column; |
| 148 | + width: 100%; |
| 149 | + align-items: center; |
| 150 | + cursor: pointer; |
| 151 | + gap: 2rem; |
| 152 | + padding: 2rem 0; |
| 153 | +`; |
0 commit comments