Files
liandong-crm/src/components/app/sidebar.tsx
T

60 lines
2.0 KiB
TypeScript
Raw Normal View History

"use client";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { cn } from "@/lib/utils";
import { copyright } from "@/lib/brand";
import { BrandLogo } from "./brand-logo";
import { navSections, activeHref } from "./nav";
export function Sidebar() {
const pathname = usePathname();
const active = activeHref(pathname);
return (
<aside className="flex w-60 shrink-0 flex-col bg-[var(--color-sidebar)] text-[var(--color-sidebar-foreground)]">
{/* 品牌 */}
<div className="flex h-16 items-center px-5">
<Link href="/">
<BrandLogo size={36} invert />
</Link>
</div>
<nav className="flex-1 space-y-6 overflow-y-auto px-3 py-4">
{navSections.map((section) => (
<div key={section.title}>
<div className="px-3 pb-2 text-[11px] font-medium uppercase tracking-wider text-[var(--color-sidebar-muted)]">
{section.title}
</div>
<div className="space-y-1">
{section.items.map((item) => {
const Icon = item.icon;
const isActive = active === item.href;
return (
<Link
key={item.href}
href={item.href}
className={cn(
"flex items-center gap-3 rounded-lg px-3 py-2 text-sm transition-colors",
isActive
? "bg-[var(--color-primary)] text-white shadow-sm"
: "text-[var(--color-sidebar-muted)] hover:bg-[var(--color-sidebar-hover)] hover:text-white"
)}
>
<Icon className="h-[18px] w-[18px]" />
{item.label}
</Link>
);
})}
</div>
</div>
))}
</nav>
<div className="px-5 py-4 text-[11px] text-[var(--color-sidebar-muted)]">
{copyright()}
</div>
</aside>
);
}