深度优化 ui
This commit is contained in:
+14
-2
@@ -1,5 +1,12 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
LayoutDashboard,
|
||||
Users,
|
||||
Server,
|
||||
Radio,
|
||||
ScrollText,
|
||||
} from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { usePathname } from "next/navigation";
|
||||
|
||||
@@ -10,18 +17,23 @@ type NavItem = {
|
||||
|
||||
export function AdminNav({ items }: { items: NavItem[] }) {
|
||||
const pathname = usePathname();
|
||||
const icons = [LayoutDashboard, Users, Server, Radio, ScrollText];
|
||||
|
||||
return (
|
||||
<nav className="nav-list">
|
||||
{items.map((item) => {
|
||||
const active = pathname === item.href || pathname.startsWith(`${item.href}/`);
|
||||
{items.map((item, index) => {
|
||||
const Icon = icons[index];
|
||||
const active =
|
||||
pathname === item.href || pathname.startsWith(`${item.href}/`);
|
||||
|
||||
return (
|
||||
<Link
|
||||
key={item.href}
|
||||
href={item.href}
|
||||
aria-current={active ? "page" : undefined}
|
||||
className={`nav-link ${active ? "is-active" : ""}`}
|
||||
>
|
||||
<Icon size={16} aria-hidden="true" />
|
||||
<span className="nav-link__label">{item.label}</span>
|
||||
</Link>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user