2023-08-31 16:11:47 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { Link, useLocation } from 'react-router-dom';
|
|
|
|
import clsx from 'clsx';
|
|
|
|
|
|
|
|
export const NavItem: React.FC<{
|
|
|
|
to: string;
|
|
|
|
label: string;
|
|
|
|
}> = React.memo((props) => {
|
|
|
|
const location = useLocation();
|
|
|
|
|
2023-10-07 09:29:01 +00:00
|
|
|
const isCurrent = location.pathname.startsWith(props.to);
|
2023-08-31 16:11:47 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Link to={props.to}>
|
|
|
|
<div
|
2024-03-22 16:45:21 +00:00
|
|
|
className={clsx('border-b-2 leading-[3.75rem]', {
|
|
|
|
'border-blue-500 text-gray-950 dark:text-gray-200': isCurrent,
|
|
|
|
'border-transparent text-gray-900 hover:border-blue-500 hover:text-gray-950 dark:text-gray-400':
|
2023-08-31 16:11:47 +00:00
|
|
|
!isCurrent,
|
|
|
|
})}
|
|
|
|
>
|
|
|
|
{props.label}
|
|
|
|
</div>
|
|
|
|
</Link>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
NavItem.displayName = 'NavItem';
|