mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
init
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
import Link from 'next/link';
|
||||
import { Icon } from '@iconify/react';
|
||||
|
||||
import { cn } from '@/lib/helper';
|
||||
|
||||
interface MenuItemProps {
|
||||
title: string;
|
||||
href?: string;
|
||||
icon?: string;
|
||||
active?: boolean;
|
||||
onClick?: () => void;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const MenuItem = ({
|
||||
title,
|
||||
href,
|
||||
icon,
|
||||
active = false,
|
||||
className,
|
||||
onClick,
|
||||
}: MenuItemProps) => {
|
||||
const menuItemBaseClassName = cn(
|
||||
'group px-3 py-2 text-base text-black font-semibold flex flex-row items-center rounded-md',
|
||||
{ 'bg-gray-100 border-l-2 border-l-primary': active },
|
||||
className
|
||||
);
|
||||
|
||||
const menuItemContent = (
|
||||
<>
|
||||
{icon && (
|
||||
<Icon
|
||||
icon={icon}
|
||||
width={20}
|
||||
height={20}
|
||||
className={cn({
|
||||
'text-gray-400': !active,
|
||||
'text-black': active,
|
||||
})}
|
||||
/>
|
||||
)}
|
||||
|
||||
<span
|
||||
className={cn({ 'opacity-40': !active }, 'group-active:opacity-100')}
|
||||
>
|
||||
{title}
|
||||
</span>
|
||||
</>
|
||||
);
|
||||
|
||||
return (
|
||||
<li onClick={onClick}>
|
||||
{href && (
|
||||
<Link href={href} className={menuItemBaseClassName}>
|
||||
{menuItemContent}
|
||||
</Link>
|
||||
)}
|
||||
|
||||
{!href && <a className={menuItemBaseClassName}>{menuItemContent}</a>}
|
||||
</li>
|
||||
);
|
||||
};
|
||||
|
||||
export default MenuItem;
|
||||
Reference in New Issue
Block a user