Skip to content

Commit 5b8c6c6

Browse files
authored
Merge pull request #24 from DeveloperBlog-Devflow/feature/layout
feat: 사이드바 구현
2 parents 80dc922 + 06a9f25 commit 5b8c6c6

4 files changed

Lines changed: 95 additions & 3 deletions

File tree

components/auth/LoginForm.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const LoginForm = ({ handleOpenModal }: LoginFormProps) => {
3636
);
3737
const user = result.user;
3838
// console.log('로그인 성공 : ', user);
39-
router.push('/main');
39+
router.push('/');
4040
} catch (err: unknown) {
4141
if (err instanceof Error) {
4242
}
@@ -65,7 +65,7 @@ const LoginForm = ({ handleOpenModal }: LoginFormProps) => {
6565
password
6666
);
6767
// console.log('로그인 성공!', userCredential.user);
68-
router.push('/main');
68+
router.push('/');
6969
} catch (err) {
7070
// console.error('로그인 에러:', err);
7171
setError('이메일 또는 비밀번호가 잘못되었습니다.');

components/common/Sidebar.tsx

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,86 @@
1+
'use client';
2+
3+
import Link from 'next/link';
4+
import { usePathname, useRouter } from 'next/navigation';
5+
import {
6+
Home,
7+
ClipboardList,
8+
CalendarPlus,
9+
CopyPlus,
10+
LogOut,
11+
} from 'lucide-react';
12+
import { signOut } from 'firebase/auth';
13+
import { auth } from '@/lib/firebase';
14+
15+
const navItems = [
16+
{ label: '홈', href: '/', icon: Home },
17+
{ label: '개발 일지', href: '/logs', icon: ClipboardList },
18+
{ label: '새 계획 만들기', href: '/plans/new', icon: CalendarPlus },
19+
{ label: '새 페이지 만들기', href: '/pages/new', icon: CopyPlus },
20+
];
21+
122
const Sidebar = () => {
2-
return <div className="w-48 bg-white"></div>;
23+
const pathname = usePathname();
24+
const router = useRouter();
25+
26+
const handleLogout = async (): Promise<void> => {
27+
try {
28+
await signOut(auth);
29+
router.replace('/landing');
30+
router.refresh(); // 서버 컴포넌트/세션 UI 갱신
31+
} catch (err) {
32+
console.error('로그아웃 실패:', err);
33+
alert('로그아웃에 실패했습니다.');
34+
}
35+
};
36+
37+
return (
38+
<div className="fixed flex h-screen w-48 flex-col bg-white">
39+
<div className="flex items-center gap-2 px-6 py-5">
40+
<span className="text-primary text-lg font-bold">&lt;/&gt;</span>
41+
<span>DevFlow</span>
42+
</div>
43+
<hr className="border-slate-300" />
44+
<nav className="mt-4 px-4">
45+
<ul className="space-y-2">
46+
{navItems.map(({ label, href, icon: Icon }) => {
47+
const isActive = pathname === href;
48+
49+
return (
50+
<li key={href}>
51+
<Link
52+
href={href}
53+
className={[
54+
'flex items-center gap-3 rounded-lg px-4 py-3 text-sm font-medium transition',
55+
isActive
56+
? 'bg-slate-200 text-slate-900'
57+
: 'text-slate-700 hover:bg-slate-100',
58+
].join(' ')}
59+
>
60+
<Icon
61+
className={[
62+
'h-5 w-5',
63+
isActive ? 'text-slate-900' : 'text-slate-600',
64+
].join(' ')}
65+
/>
66+
{label}
67+
</Link>
68+
</li>
69+
);
70+
})}
71+
</ul>
72+
</nav>
73+
<div className="absolute bottom-0 w-full border-t border-slate-200 p-4">
74+
<button
75+
className="flex items-center gap-3 rounded-lg px-4 py-3 text-sm font-medium text-slate-700 hover:bg-slate-100"
76+
onClick={handleLogout}
77+
>
78+
<LogOut className="h-5 w-5 text-slate-600" />
79+
로그아웃
80+
</button>
81+
</div>
82+
</div>
83+
);
384
};
485

586
export default Sidebar;

package-lock.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"dependencies": {
1212
"clsx": "^2.1.1",
1313
"firebase": "^12.7.0",
14+
"lucide-react": "^0.562.0",
1415
"next": "16.1.1",
1516
"react": "19.2.3",
1617
"react-dom": "19.2.3",

0 commit comments

Comments
 (0)