Files
myeasycms-v2/apps/web/app/(marketing)/_components/site-navigation-item.tsx
gbuomprisco 5ee7bacb2a Update site navigation styles and cleanup page imports
The navigation menu item styles were adjusted for better appearance. Also, the spacing in the NavigationMenuList was increased for better user experience. Moreover, a few unused imports in page.tsx were removed to clean up the code. Additionally, the button class formatting was adjusted for better readability and consistency.
2024-07-19 00:00:57 +02:00

38 lines
918 B
TypeScript

'use client';
import Link from 'next/link';
import { usePathname } from 'next/navigation';
import { NavigationMenuItem } from '@kit/ui/navigation-menu';
import { cn, isRouteActive } from '@kit/ui/utils';
const getClassName = (path: string, currentPathName: string) => {
const isActive = isRouteActive(path, currentPathName);
return cn(
`text-sm font-medium transition-colors duration-300 inline-flex w-max`,
{
'dark:text-gray-300 dark:hover:text-white': !isActive,
'dark:text-white text-current': isActive,
},
);
};
export function SiteNavigationItem({
path,
children,
}: React.PropsWithChildren<{
path: string;
}>) {
const currentPathName = usePathname();
const className = getClassName(path, currentPathName);
return (
<NavigationMenuItem key={path}>
<Link className={className} href={path}>
{children}
</Link>
</NavigationMenuItem>
);
}