|
|
|
@ -9,20 +9,21 @@ export const NavbarNavItem: React.FC<{
|
|
|
|
|
name: string;
|
|
|
|
|
className?: ClassValue;
|
|
|
|
|
to?: string;
|
|
|
|
|
showPill?: boolean;
|
|
|
|
|
onClick?: () => void;
|
|
|
|
|
}> = React.memo((props) => {
|
|
|
|
|
const { name, className, to } = props;
|
|
|
|
|
const { name, className, to, showPill = false } = props;
|
|
|
|
|
const location = useLocation();
|
|
|
|
|
const isActive = typeof to === 'string' && location.pathname.startsWith(to);
|
|
|
|
|
|
|
|
|
|
const inner = (
|
|
|
|
|
let inner = (
|
|
|
|
|
<Tooltip
|
|
|
|
|
title={<div className="font-bold px-1.5 py-0.5">{name}</div>}
|
|
|
|
|
placement="right"
|
|
|
|
|
>
|
|
|
|
|
<div
|
|
|
|
|
className={clsx(
|
|
|
|
|
'w-12 h-12 hover:rounded-lg transition-all cursor-pointer flex items-center justify-center overflow-hidden',
|
|
|
|
|
'w-12 h-12 hover:rounded-lg transition-all duration-300 cursor-pointer flex items-center justify-center overflow-hidden',
|
|
|
|
|
className,
|
|
|
|
|
{
|
|
|
|
|
'rounded-1/2': !isActive,
|
|
|
|
@ -37,9 +38,29 @@ export const NavbarNavItem: React.FC<{
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (typeof to === 'string') {
|
|
|
|
|
return <Link to={to}>{inner}</Link>;
|
|
|
|
|
inner = <Link to={to}>{inner}</Link>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return inner;
|
|
|
|
|
return (
|
|
|
|
|
<div className="w-full px-3 relative group">
|
|
|
|
|
{showPill && (
|
|
|
|
|
<div
|
|
|
|
|
className="absolute w-2 left-0 top-0 bottom-0 flex items-center"
|
|
|
|
|
style={{ marginLeft: -4 }}
|
|
|
|
|
>
|
|
|
|
|
<span
|
|
|
|
|
className={clsx(
|
|
|
|
|
'bg-white w-2 h-2 rounded transition-all duration-300',
|
|
|
|
|
{
|
|
|
|
|
'h-2 group-hover:h-5': !isActive,
|
|
|
|
|
'h-10': isActive,
|
|
|
|
|
}
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
{inner}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
NavbarNavItem.displayName = 'NavbarNavItem';
|
|
|
|
|