2026-08-24 16:32:16 +07:00
|
|
|
"use client";
|
|
|
|
|
|
2026-08-25 22:59:19 +07:00
|
|
|
import { useGSAP } from "@gsap/react";
|
|
|
|
|
import gsap from "gsap";
|
2026-08-24 16:32:16 +07:00
|
|
|
import { usePathname } from "next/navigation";
|
2026-08-25 22:59:19 +07:00
|
|
|
import { useRef } from "react";
|
2026-08-24 16:32:16 +07:00
|
|
|
import { isActivePath, navItems } from "@/lib/navigation";
|
|
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
|
|
2026-08-25 22:59:19 +07:00
|
|
|
if (typeof window !== "undefined") {
|
|
|
|
|
gsap.registerPlugin(useGSAP);
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-24 16:32:16 +07:00
|
|
|
function NavItem({
|
|
|
|
|
href,
|
|
|
|
|
label,
|
|
|
|
|
active,
|
|
|
|
|
Icon,
|
2026-08-24 17:35:51 +07:00
|
|
|
index,
|
2026-08-24 16:32:16 +07:00
|
|
|
}: {
|
|
|
|
|
href: string;
|
|
|
|
|
label: string;
|
|
|
|
|
active: boolean;
|
|
|
|
|
Icon: React.ComponentType<React.SVGProps<SVGSVGElement>>;
|
2026-08-24 17:35:51 +07:00
|
|
|
index: number;
|
2026-08-24 16:32:16 +07:00
|
|
|
}) {
|
|
|
|
|
return (
|
|
|
|
|
<a
|
|
|
|
|
href={href}
|
|
|
|
|
aria-label={label}
|
|
|
|
|
aria-current={active ? "page" : undefined}
|
2026-08-24 17:35:51 +07:00
|
|
|
style={{ "--i": index } as React.CSSProperties}
|
2026-08-24 16:32:16 +07:00
|
|
|
className={cn(
|
2026-08-25 22:59:19 +07:00
|
|
|
"nav-dock-item game-nav-item group relative flex size-11 items-center justify-center rounded-[13px] transition-all duration-200",
|
2026-08-24 16:32:16 +07:00
|
|
|
active
|
2026-08-25 22:59:19 +07:00
|
|
|
? "is-active bg-white/10 text-white shadow-sm ring-1 ring-white/20"
|
|
|
|
|
: "text-ink-faint hover:bg-white/5 hover:text-ink-soft hover:scale-105",
|
2026-08-24 16:32:16 +07:00
|
|
|
)}
|
|
|
|
|
>
|
2026-08-24 17:35:51 +07:00
|
|
|
{active && <span className="game-marker -left-3.5" />}
|
|
|
|
|
<span className="game-sweep" aria-hidden="true">
|
|
|
|
|
<i />
|
|
|
|
|
</span>
|
|
|
|
|
<Icon
|
|
|
|
|
className="relative z-10 size-[18px]"
|
|
|
|
|
strokeWidth={active ? 2.4 : 2}
|
|
|
|
|
/>
|
2026-08-25 22:59:19 +07:00
|
|
|
{/* HUD Tooltip on hover */}
|
|
|
|
|
<span className="pointer-events-none absolute left-full z-50 ml-3 hidden whitespace-nowrap rounded-md border border-hairline bg-canvas-2/95 px-2.5 py-1 font-mono text-[11px] font-semibold tracking-wider text-ink opacity-0 shadow-xl backdrop-blur-md transition-all group-hover:translate-x-1 group-hover:opacity-100 md:block">
|
|
|
|
|
<span className="text-signal mr-1.5">›</span>
|
2026-08-24 16:32:16 +07:00
|
|
|
{label}
|
|
|
|
|
</span>
|
|
|
|
|
</a>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function NavRail() {
|
|
|
|
|
const pathname = usePathname();
|
|
|
|
|
const path = pathname ?? "/";
|
2026-08-25 22:59:19 +07:00
|
|
|
const railRef = useRef<HTMLElement>(null);
|
|
|
|
|
|
|
|
|
|
useGSAP(
|
|
|
|
|
() => {
|
|
|
|
|
if (!railRef.current) return;
|
|
|
|
|
const items = railRef.current.querySelectorAll(".nav-dock-item");
|
|
|
|
|
gsap.fromTo(
|
|
|
|
|
items,
|
|
|
|
|
{ opacity: 0, x: -8, scale: 0.9 },
|
|
|
|
|
{
|
|
|
|
|
opacity: 1,
|
|
|
|
|
x: 0,
|
|
|
|
|
scale: 1,
|
|
|
|
|
duration: 0.4,
|
|
|
|
|
stagger: 0.04,
|
|
|
|
|
ease: "power2.out",
|
|
|
|
|
clearProps: "transform",
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
{ scope: railRef },
|
|
|
|
|
);
|
2026-08-24 16:32:16 +07:00
|
|
|
|
|
|
|
|
return (
|
2026-08-25 22:59:19 +07:00
|
|
|
<nav
|
|
|
|
|
ref={railRef}
|
|
|
|
|
className="glass mb-[calc(0.75rem+env(safe-area-inset-bottom))] ml-[calc(0.75rem+env(safe-area-inset-left))] mt-[calc(0.75rem+env(safe-area-inset-top))] hidden w-[68px] flex-col items-center gap-1 rounded-[18px] border border-hairline/80 py-4 shadow-2xl backdrop-blur-xl md:flex"
|
|
|
|
|
>
|
|
|
|
|
<div className="flex flex-1 flex-col gap-1.5">
|
2026-08-24 17:35:51 +07:00
|
|
|
{navItems.map((item, i) => (
|
2026-08-24 16:32:16 +07:00
|
|
|
<NavItem
|
|
|
|
|
key={item.href}
|
|
|
|
|
href={item.href}
|
|
|
|
|
label={item.label}
|
2026-08-24 17:35:51 +07:00
|
|
|
index={i}
|
2026-08-24 16:32:16 +07:00
|
|
|
active={isActivePath(path, item.matchPrefix)}
|
|
|
|
|
Icon={item.icon}
|
|
|
|
|
/>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
</nav>
|
|
|
|
|
);
|
|
|
|
|
}
|