mirror of
https://github.com/felipegcoutinho/openmonetis.git
synced 2026-03-10 13:01:47 +00:00
refactor: desacoplar componentes do top-nav-menu em arquivos separados
- nav-styles.ts: constantes de estilo (linkBase, linkIdle, linkActive, triggerClass) - simple-nav-link.tsx: link direto com estado ativo - dropdown-link-list.tsx: lista de itens de dropdown com tipo DropdownLinkItem - mobile-nav-link.tsx: MobileNavLink e MobileSectionLabel para o Sheet mobile - top-nav-menu.tsx: apenas TopNavMenu, importa dos arquivos acima Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
28
components/topbar/simple-nav-link.tsx
Normal file
28
components/topbar/simple-nav-link.tsx
Normal file
@@ -0,0 +1,28 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { usePathname } from "next/navigation";
|
||||
import { cn } from "@/lib/utils/ui";
|
||||
import { linkActive, linkBase, linkIdle } from "./nav-styles";
|
||||
|
||||
type SimpleNavLinkProps = {
|
||||
href: string;
|
||||
children: React.ReactNode;
|
||||
};
|
||||
|
||||
export function SimpleNavLink({ href, children }: SimpleNavLinkProps) {
|
||||
const pathname = usePathname();
|
||||
const isActive =
|
||||
href === "/dashboard"
|
||||
? pathname === href
|
||||
: pathname === href || pathname.startsWith(`${href}/`);
|
||||
|
||||
return (
|
||||
<Link
|
||||
href={href}
|
||||
className={cn(linkBase, isActive ? linkActive : linkIdle)}
|
||||
>
|
||||
{children}
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user