feat: redesign admin sidebar with grouped sections

- Add Management and Moderation sections with labeled groups
- Section labels: muted uppercase micro text
- Section dividers: horizontal on desktop, vertical on mobile
- Active state: bg-primary/10 text-primary rounded-lg
- Widen desktop sidebar from md:w-48 to md:w-56
- Add desktop-only Admin Panel header with LayoutDashboardIcon
- Expand nav to cover all 6 admin pages (users, hardware, games,
  reports, benchmarks, comments)
- Update admin layout description to 'Manage your platform'
This commit is contained in:
2026-04-28 08:47:03 +08:00
parent 635e9fa46c
commit b4db4d8ab8
2 changed files with 61 additions and 12 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ export default async function AdminLayout({
<div className='max-w-7xl mx-auto'> <div className='max-w-7xl mx-auto'>
<h1 className='text-2xl sm:text-3xl font-bold'>Admin</h1> <h1 className='text-2xl sm:text-3xl font-bold'>Admin</h1>
<p className='text-sm text-text/60 mt-1'> <p className='text-sm text-text/60 mt-1'>
Manage users, hardware, and games Manage your platform
</p> </p>
</div> </div>
</div> </div>
+60 -11
View File
@@ -2,31 +2,80 @@
import Link from "next/link" import Link from "next/link"
import { usePathname } from "next/navigation" import { usePathname } from "next/navigation"
import { UsersIcon, CpuIcon, Gamepad2Icon, MessageSquareIcon } from "lucide-react" import {
UsersIcon,
CpuIcon,
Gamepad2Icon,
MessageSquareIcon,
FlagIcon,
BarChart3Icon,
LayoutDashboardIcon,
} from "lucide-react"
const adminNavItems = [ type NavItem =
{ href: "/admin/users", label: "Users", icon: UsersIcon }, | { type: "section"; label: string }
{ href: "/admin/hardware", label: "Hardware", icon: CpuIcon }, | { type: "divider" }
{ href: "/admin/games", label: "Games", icon: Gamepad2Icon }, | { type: "link"; href: string; label: string; icon: React.ElementType }
{ href: "/admin/comments", label: "Comments", icon: MessageSquareIcon },
const navItems: NavItem[] = [
{ type: "section", label: "Management" },
{ type: "link", href: "/admin/users", label: "Users", icon: UsersIcon },
{ type: "link", href: "/admin/hardware", label: "Hardware", icon: CpuIcon },
{ type: "link", href: "/admin/games", label: "Games", icon: Gamepad2Icon },
{ type: "divider" },
{ type: "section", label: "Moderation" },
{ type: "link", href: "/admin/reports", label: "Reports", icon: FlagIcon },
{ type: "link", href: "/admin/benchmarks", label: "Benchmarks", icon: BarChart3Icon },
{ type: "link", href: "/admin/comments", label: "Comments", icon: MessageSquareIcon },
] ]
export function AdminSidebar() { export function AdminSidebar() {
const pathname = usePathname() const pathname = usePathname()
return ( return (
<nav className="md:w-48 shrink-0"> <nav className="md:w-56 shrink-0">
<div className="flex md:flex-col gap-1 overflow-x-auto md:overflow-visible pb-2 md:pb-0 md:border-r md:border-border"> {/* Desktop header */}
{adminNavItems.map((item) => { <div className="hidden md:flex items-center gap-2 px-3 py-2 mb-2 text-sm font-semibold text-text/70">
<LayoutDashboardIcon className="h-4 w-4" />
Admin Panel
</div>
<div className="flex md:flex-col gap-1 overflow-x-auto md:overflow-visible pb-2 md:pb-0 md:border-r md:border-border md:pr-3">
{navItems.map((item, index) => {
if (item.type === "section") {
return (
<div
key={`section-${item.label}`}
className="hidden md:block px-3 py-1 text-[10px] font-semibold uppercase tracking-widest text-text/30"
>
{item.label}
</div>
)
}
if (item.type === "divider") {
return [
<div
key={`div-m-${index}`}
className="w-px bg-border shrink-0 self-stretch md:hidden"
/>,
<div
key={`div-d-${index}`}
className="hidden md:block h-px bg-border"
/>,
]
}
const isActive = const isActive =
pathname === item.href || pathname.startsWith(item.href + "/") pathname === item.href || pathname.startsWith(item.href + "/")
return ( return (
<Link <Link
key={item.href} key={item.href}
href={item.href} href={item.href}
className={`flex items-center gap-2 px-4 py-2.5 text-sm font-medium transition-colors whitespace-nowrap rounded-lg md:rounded-none md:border-l-2 md:border-r-0 md:border-transparent ${ className={`flex items-center gap-2 px-4 md:px-3 py-2.5 text-sm font-medium transition-colors whitespace-nowrap rounded-lg ${
isActive isActive
? "bg-primary/10 text-primary md:border-l-primary" ? "bg-primary/10 text-primary"
: "text-text/50 hover:text-text/70 hover:bg-text/5" : "text-text/50 hover:text-text/70 hover:bg-text/5"
}`} }`}
> >