2026-08-15 17:53:48 +07:00
|
|
|
"use client";
|
|
|
|
|
|
2026-08-15 19:23:17 +07:00
|
|
|
import { LayoutDashboard } from "lucide-react";
|
2026-08-15 20:03:55 +07:00
|
|
|
import { usePathname, useRouter } from "next/navigation";
|
|
|
|
|
import { isActivePath, navItems } from "@/lib/navigation";
|
2026-08-15 17:53:48 +07:00
|
|
|
import { cn } from "@/lib/utils";
|
2026-08-15 19:23:17 +07:00
|
|
|
|
|
|
|
|
function NavItem({
|
|
|
|
|
href,
|
|
|
|
|
label,
|
|
|
|
|
active,
|
|
|
|
|
Icon,
|
|
|
|
|
}: {
|
|
|
|
|
href: string;
|
|
|
|
|
label: string;
|
|
|
|
|
active: boolean;
|
|
|
|
|
Icon: React.ComponentType<React.SVGProps<SVGSVGElement>>;
|
|
|
|
|
}) {
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
return (
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
aria-label={label}
|
|
|
|
|
aria-current={active ? "page" : undefined}
|
|
|
|
|
onClick={() => router.push(href)}
|
|
|
|
|
className={cn(
|
|
|
|
|
"group relative flex size-11 items-center justify-center rounded-[13px] transition-all",
|
|
|
|
|
active
|
|
|
|
|
? "bg-signal/15 text-signal"
|
|
|
|
|
: "text-ink-faint hover:bg-white/5 hover:text-ink-soft",
|
|
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
{active && (
|
|
|
|
|
<span className="absolute -left-3 h-6 w-1 rounded-full bg-signal shadow-[0_0_12px_var(--color-signal-glow)]" />
|
|
|
|
|
)}
|
|
|
|
|
<Icon className="size-[18px]" strokeWidth={active ? 2.4 : 2} />
|
|
|
|
|
</button>
|
|
|
|
|
);
|
|
|
|
|
}
|
2026-08-15 17:53:48 +07:00
|
|
|
|
|
|
|
|
export function NavRail() {
|
|
|
|
|
const pathname = usePathname();
|
2026-08-15 19:23:17 +07:00
|
|
|
const path = pathname ?? "/";
|
|
|
|
|
|
2026-08-15 17:53:48 +07:00
|
|
|
return (
|
|
|
|
|
<nav className="glass m-3 mr-0 flex w-[68px] flex-col items-center gap-1 rounded-[18px] py-4">
|
2026-08-15 19:23:17 +07:00
|
|
|
<NavItem
|
2026-08-15 17:53:48 +07:00
|
|
|
href="/dashboard"
|
2026-08-15 19:23:17 +07:00
|
|
|
label="Dashboard"
|
|
|
|
|
active={path === "/dashboard" || path === "/dashboard/"}
|
|
|
|
|
Icon={LayoutDashboard}
|
|
|
|
|
/>
|
2026-08-15 17:53:48 +07:00
|
|
|
<div className="flex flex-1 flex-col gap-1">
|
2026-08-15 19:23:17 +07:00
|
|
|
{navItems.map((item) => (
|
|
|
|
|
<NavItem
|
|
|
|
|
key={item.href}
|
|
|
|
|
href={item.href}
|
|
|
|
|
label={item.label}
|
|
|
|
|
active={isActivePath(path, item.matchPrefix)}
|
|
|
|
|
Icon={item.icon}
|
|
|
|
|
/>
|
|
|
|
|
))}
|
2026-08-15 17:53:48 +07:00
|
|
|
</div>
|
|
|
|
|
</nav>
|
|
|
|
|
);
|
|
|
|
|
}
|