feat: 관리자 페이지 모바일 반응형 사이드바 토글 추가
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
49
app/admin/components/AdminShell.tsx
Normal file
49
app/admin/components/AdminShell.tsx
Normal file
@@ -0,0 +1,49 @@
|
||||
'use client';
|
||||
|
||||
import { useState } from 'react';
|
||||
import AdminSidebar from './AdminSidebar';
|
||||
|
||||
export default function AdminShell({ children }: { children: React.ReactNode }) {
|
||||
const [sidebarOpen, setSidebarOpen] = useState(false);
|
||||
|
||||
return (
|
||||
<div className="flex h-screen bg-slate-950 overflow-hidden">
|
||||
{/* 모바일 오버레이 */}
|
||||
{sidebarOpen && (
|
||||
<div
|
||||
className="fixed inset-0 z-20 bg-black/60 lg:hidden"
|
||||
onClick={() => setSidebarOpen(false)}
|
||||
/>
|
||||
)}
|
||||
|
||||
<AdminSidebar isOpen={sidebarOpen} onClose={() => setSidebarOpen(false)} />
|
||||
|
||||
<div className="flex-1 flex flex-col overflow-hidden min-w-0">
|
||||
{/* 모바일 상단 헤더 */}
|
||||
<header className="lg:hidden flex items-center justify-between px-4 py-3 bg-slate-900 border-b border-slate-700/60 flex-shrink-0">
|
||||
<button
|
||||
onClick={() => setSidebarOpen(true)}
|
||||
className="p-2 rounded-lg text-slate-400 hover:text-white hover:bg-slate-800 transition"
|
||||
aria-label="메뉴 열기"
|
||||
>
|
||||
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 6h16M4 12h16M4 18h16" />
|
||||
</svg>
|
||||
</button>
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="w-8 h-8 rounded-xl bg-gradient-to-br from-red-500 to-orange-500 flex items-center justify-center text-white font-bold text-sm">
|
||||
관
|
||||
</div>
|
||||
<span className="text-white font-bold text-sm">관리자 패널</span>
|
||||
</div>
|
||||
<div className="w-9" />
|
||||
</header>
|
||||
|
||||
{/* 메인 스크롤 영역 */}
|
||||
<main className="flex-1 overflow-y-auto">
|
||||
{children}
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -68,7 +68,12 @@ const NAV_ITEMS = [
|
||||
},
|
||||
];
|
||||
|
||||
export default function AdminSidebar() {
|
||||
interface AdminSidebarProps {
|
||||
isOpen?: boolean;
|
||||
onClose?: () => void;
|
||||
}
|
||||
|
||||
export default function AdminSidebar({ isOpen = false, onClose }: AdminSidebarProps) {
|
||||
const pathname = usePathname();
|
||||
const router = useRouter();
|
||||
const [loggingOut, setLoggingOut] = useState(false);
|
||||
@@ -80,9 +85,15 @@ export default function AdminSidebar() {
|
||||
}
|
||||
|
||||
return (
|
||||
<aside className="w-60 flex-shrink-0 bg-slate-900 flex flex-col h-screen sticky top-0">
|
||||
<aside className={`
|
||||
w-60 flex-shrink-0 bg-slate-900 flex flex-col h-screen
|
||||
fixed top-0 left-0 z-30 transition-transform duration-300
|
||||
lg:static lg:translate-x-0
|
||||
${isOpen ? 'translate-x-0' : '-translate-x-full'}
|
||||
`}>
|
||||
{/* 로고 */}
|
||||
<div className="px-5 py-5 border-b border-slate-700/60">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="w-9 h-9 rounded-xl bg-gradient-to-br from-red-500 to-orange-500 flex items-center justify-center text-white font-bold text-sm">
|
||||
관
|
||||
@@ -92,6 +103,19 @@ export default function AdminSidebar() {
|
||||
<p className="text-slate-400 text-xs">쟁승메이드</p>
|
||||
</div>
|
||||
</div>
|
||||
{/* 모바일 닫기 버튼 */}
|
||||
{onClose && (
|
||||
<button
|
||||
onClick={onClose}
|
||||
className="lg:hidden p-1.5 rounded-lg text-slate-400 hover:text-white hover:bg-slate-800 transition"
|
||||
aria-label="메뉴 닫기"
|
||||
>
|
||||
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
|
||||
</svg>
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 네비게이션 */}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { Metadata } from 'next';
|
||||
import AdminSidebar from './components/AdminSidebar';
|
||||
import AdminShell from './components/AdminShell';
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: '관리자 패널 — 쟁승메이드',
|
||||
@@ -7,12 +7,5 @@ export const metadata: Metadata = {
|
||||
};
|
||||
|
||||
export default function AdminLayout({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<div className="flex h-screen bg-slate-950 overflow-hidden">
|
||||
<AdminSidebar />
|
||||
<main className="flex-1 overflow-y-auto">
|
||||
{children}
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
return <AdminShell>{children}</AdminShell>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user