Files
myeasycms-v2/apps/web/app/(marketing)/_components/site-navigation-item.tsx
giancarlo 6ff82ec5ef Improve site header account and navigation item styling
The styling of the site header account sign-up button and navigation items has been updated. Class names and transition durations were adjusted for better visualization and usability. The changes particularly enhance the hover effect on the sign-up button and navigation items.
2024-04-20 02:24:00 +08:00

39 lines
1010 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 px-2.5 py-2 border rounded-lg border-transparent transition-colors duration-100`,
{
'hover:border-border dark:text-gray-400 text-gray-600 hover:text-current 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>
);
}