-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathHeader.tsx
More file actions
59 lines (49 loc) · 1.61 KB
/
Header.tsx
File metadata and controls
59 lines (49 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import * as styles from './Header.css';
import { PATH } from '@/route/path';
const MENUS = [
{ label: '나의 할 일', path: PATH.TODO },
{ label: '나의 만다르트', path: PATH.MANDAL },
{ label: '나의 히스토리', path: PATH.HISTORY },
];
const Header = () => {
const [activeMenu, setActiveMenu] = useState<string>(MENUS[0].label);
const [isLoggedIn, setIsLoggedIn] = useState<boolean>(false);
const navigate = useNavigate();
const handleLogin = () => {
// 로그인 로직 추가하기
setIsLoggedIn(true);
};
const handleMenuClick = (menuLabel: string, path: string) => {
setActiveMenu(menuLabel);
navigate(path);
};
return (
<header className={styles.header}>
<div className={styles.headerInner}>
<h1 className={styles.logo}>NINEDOT</h1>
<nav className={styles.navWrapper}>
{MENUS.map((menu) => (
<button
key={menu.label}
className={`${styles.navItem} ${activeMenu === menu.label ? styles.navItemActive : ''}`}
onClick={() => handleMenuClick(menu.label, menu.path)}
aria-current={activeMenu === menu.label ? 'page' : undefined}
>
{menu.label}
</button>
))}
</nav>
{isLoggedIn ? (
<div className={styles.profilePlaceholder} />
) : (
<button className={styles.loginButton} onClick={handleLogin}>
로그인
</button>
)}
</div>
</header>
);
};
export default Header;