Skip to content

Commit 9ebdb6a

Browse files
authored
[Feat] Header 컴포넌트 구현 (#36)
1 parent 4c8e6e1 commit 9ebdb6a

File tree

3 files changed

+74
-1
lines changed

3 files changed

+74
-1
lines changed

src/pages/home/home-page.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import * as styles from './home-page.css';
2+
import Header from '../../shared/components/header/header';
23

34
const HomePage = () => {
4-
return <div className={styles.title}>홈 페이지</div>;
5+
return (
6+
<>
7+
<Header />
8+
<div className={styles.title}>홈 페이지</div>
9+
</>
10+
);
511
};
612

713
export default HomePage;
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { vars } from '../../../styles/theme.css';
2+
import { style } from '@vanilla-extract/css';
3+
4+
export const headerContainer = style({
5+
width: '100%',
6+
height: '6.4rem',
7+
position: 'fixed',
8+
top: 0,
9+
left: 0,
10+
background: 'white',
11+
borderBottom: `1px solid ${vars.color.gray300}`,
12+
display: 'flex',
13+
alignItems: 'center',
14+
justifyContent: 'space-between',
15+
zIndex: 10,
16+
padding: '0 10rem',
17+
});
18+
19+
export const logo = style({
20+
fontSize: '2.4rem',
21+
fontWeight: 'bold',
22+
color: vars.color.gray800,
23+
cursor: 'pointer',
24+
userSelect: 'none',
25+
});
26+
27+
export const logout = style({
28+
width: 'auto',
29+
padding: '0',
30+
border: 'none',
31+
backgroundColor: 'transparent',
32+
color: vars.color.gray800,
33+
fontSize: vars.size.xs,
34+
fontWeight: vars.weight.regular,
35+
cursor: 'pointer',
36+
userSelect: 'none',
37+
});
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import * as styles from './header.css';
2+
import { useNavigate } from 'react-router-dom';
3+
import { logout } from '../../api/auth';
4+
5+
const Header = () => {
6+
const navigate = useNavigate();
7+
8+
const handleLogout = async () => {
9+
try {
10+
await logout();
11+
localStorage.removeItem('accessToken');
12+
navigate('/login', { replace: true });
13+
} catch (e) {
14+
console.error('Logout failed:', e);
15+
}
16+
};
17+
18+
return (
19+
<div className={styles.headerContainer}>
20+
<div className={styles.logo} onClick={() => navigate('/')}>
21+
FINI
22+
</div>
23+
<button className={styles.logout} onClick={handleLogout}>
24+
로그아웃
25+
</button>
26+
</div>
27+
);
28+
};
29+
30+
export default Header;

0 commit comments

Comments
 (0)