forked from git.gladyson/openmonetis
refactor: substituir topbar por navbar componentizada
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
31
components/navbar/nav-pill.tsx
Normal file
31
components/navbar/nav-pill.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
"use client";
|
||||
|
||||
import { usePathname } from "next/navigation";
|
||||
import { cn } from "@/lib/utils/ui";
|
||||
import { NavLink } from "./nav-link";
|
||||
import { linkActive, linkBase, linkIdle } from "./nav-styles";
|
||||
|
||||
type NavPillProps = {
|
||||
href: string;
|
||||
preservePeriod?: boolean;
|
||||
children: React.ReactNode;
|
||||
};
|
||||
|
||||
export function NavPill({ href, preservePeriod, children }: NavPillProps) {
|
||||
const pathname = usePathname();
|
||||
|
||||
const isActive =
|
||||
href === "/dashboard"
|
||||
? pathname === href
|
||||
: pathname === href || pathname.startsWith(`${href}/`);
|
||||
|
||||
return (
|
||||
<NavLink
|
||||
href={href}
|
||||
preservePeriod={preservePeriod}
|
||||
className={cn(linkBase, isActive ? linkActive : linkIdle)}
|
||||
>
|
||||
{children}
|
||||
</NavLink>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user