2024-09-10 19:00:27 -04:00
|
|
|
import React, { FC, forwardRef } from 'react';
|
2023-10-03 16:28:19 +02:00
|
|
|
import { cn } from '~/utils/';
|
|
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
|
svg: () => JSX.Element;
|
|
|
|
|
text: string;
|
2024-09-10 19:00:27 -04:00
|
|
|
clickHandler?: React.MouseEventHandler<HTMLButtonElement>;
|
2023-10-03 16:28:19 +02:00
|
|
|
className?: string;
|
2024-05-10 03:16:16 +05:30
|
|
|
disabled?: boolean;
|
2023-10-03 16:28:19 +02:00
|
|
|
}
|
|
|
|
|
|
2024-08-16 15:09:03 -04:00
|
|
|
const NavLink: FC<Props> = forwardRef<HTMLButtonElement, Props>((props, ref) => {
|
2024-05-10 03:16:16 +05:30
|
|
|
const { svg, text, clickHandler, disabled, className = '' } = props;
|
2023-10-03 16:28:19 +02:00
|
|
|
const defaultProps: {
|
|
|
|
|
className: string;
|
2024-09-10 19:00:27 -04:00
|
|
|
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
2023-10-03 16:28:19 +02:00
|
|
|
} = {
|
|
|
|
|
className: cn(
|
2024-09-22 04:45:50 +02:00
|
|
|
'w-full flex gap-2 rounded p-2.5 text-sm cursor-pointer group items-center transition-colors duration-200 text-text-primary',
|
2023-10-03 16:28:19 +02:00
|
|
|
className,
|
2024-05-10 03:16:16 +05:30
|
|
|
{
|
|
|
|
|
'opacity-50 pointer-events-none': disabled,
|
|
|
|
|
},
|
2023-10-03 16:28:19 +02:00
|
|
|
),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (clickHandler) {
|
|
|
|
|
defaultProps.onClick = clickHandler;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
2024-08-16 15:09:03 -04:00
|
|
|
<button {...defaultProps} ref={ref}>
|
2023-10-03 16:28:19 +02:00
|
|
|
{svg()}
|
|
|
|
|
{text}
|
2024-08-16 15:09:03 -04:00
|
|
|
</button>
|
2023-10-03 16:28:19 +02:00
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export default NavLink;
|