This commit is contained in:
1 parent
7b67ef893c
commit
adbd651350
2 files changed
+62
-3
No files matched your search
@@ -3,6 +3,7 @@ import { redirect } from "next/navigation";
|
|||||||
import type { ReactNode } from "react";
|
import type { ReactNode } from "react";
|
||||||
import { getTranslations } from "next-intl/server";
|
import { getTranslations } from "next-intl/server";
|
||||||
import { AdminNavLink } from "@/components/admin/admin-nav-link";
|
import { AdminNavLink } from "@/components/admin/admin-nav-link";
|
||||||
|
import { AdminMobileWrapper } from "@/components/admin/admin-mobile-wrapper";
|
||||||
import { requireStaff } from "@/lib/admin/guard";
|
import { requireStaff } from "@/lib/admin/guard";
|
||||||
import { prisma } from "@/lib/prisma";
|
import { prisma } from "@/lib/prisma";
|
||||||
import { siteSettings } from "@/lib/services/site-settings";
|
import { siteSettings } from "@/lib/services/site-settings";
|
||||||
@@ -163,13 +164,12 @@ export default async function AdminLayout({ children }: { children: ReactNode })
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="grid grid-cols-1 lg:grid-cols-[260px_minmax(0,1fr)] min-h-screen bg-[var(--admin-canvas)]">
|
<AdminMobileWrapper sidebar={<Sidebar staff={staff} />}>
|
||||||
<Sidebar staff={staff} />
|
|
||||||
<div className="flex flex-col min-w-0 p-5 lg:p-6">
|
<div className="flex flex-col min-w-0 p-5 lg:p-6">
|
||||||
<Topbar staff={staff} />
|
<Topbar staff={staff} />
|
||||||
<section className="admin-page flex-1">{children}</section>
|
<section className="admin-page flex-1">{children}</section>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</AdminMobileWrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useState, useEffect, type ReactNode } from "react";
|
||||||
|
import { Menu, X } from "lucide-react";
|
||||||
|
|
||||||
|
export function AdminMobileWrapper({
|
||||||
|
sidebar,
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
sidebar: ReactNode;
|
||||||
|
children: ReactNode;
|
||||||
|
}) {
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!open) return;
|
||||||
|
const handler = (e: KeyboardEvent) => {
|
||||||
|
if (e.key === "Escape") setOpen(false);
|
||||||
|
};
|
||||||
|
document.addEventListener("keydown", handler);
|
||||||
|
return () => document.removeEventListener("keydown", handler);
|
||||||
|
}, [open]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="min-h-screen bg-[var(--admin-canvas)] flex flex-col lg:flex-row">
|
||||||
|
{/* Mobile header */}
|
||||||
|
<div className="lg:hidden sticky top-0 z-50 flex items-center gap-3 px-4 py-3 border-b" style={{ backgroundColor: "var(--admin-sidebar-background)", borderColor: "var(--admin-border)" }}>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => setOpen(!open)}
|
||||||
|
className="flex items-center justify-center w-9 h-9 rounded-lg transition-colors hover:bg-black/10"
|
||||||
|
style={{ color: "var(--admin-text-muted)" }}
|
||||||
|
>
|
||||||
|
{open ? <X size={18} /> : <Menu size={18} />}
|
||||||
|
</button>
|
||||||
|
<span className="text-sm font-bold" style={{ color: "var(--admin-sidebar-text-readable)" }}>Admin Panel</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Backdrop */}
|
||||||
|
{open && (
|
||||||
|
<div className="fixed inset-0 z-40 lg:hidden bg-black/50" onClick={() => setOpen(false)} />
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Sidebar */}
|
||||||
|
<div
|
||||||
|
className={`fixed inset-y-0 left-0 z-50 w-[260px] transform transition-transform duration-300 ease-in-out lg:!relative lg:!translate-x-0 lg:!min-h-screen ${
|
||||||
|
open ? "translate-x-0" : "-translate-x-full"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{sidebar}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Content */}
|
||||||
|
<div className="flex flex-col flex-1 min-w-0">
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in new issue
Block a user