ConceptPortal-public/rsconcept/frontend/src/components/Common/TextURL.tsx

39 lines
675 B
TypeScript
Raw Normal View History

2023-07-15 17:46:19 +03:00
import { Link } from 'react-router-dom';
2023-07-15 17:46:19 +03:00
interface TextURLProps {
text: string
tooltip?: string
href?: string
2023-12-08 19:24:08 +03:00
color?: string
onClick?: () => void
2023-07-15 17:46:19 +03:00
}
function TextURL({ text, href, tooltip, color='clr-text-url', onClick }: TextURLProps) {
2023-12-08 19:24:08 +03:00
const design = `cursor-pointer hover:underline ${color}`;
if (href) {
return (
<Link
2023-12-08 19:24:08 +03:00
className={design}
title={tooltip}
to={href}
2023-12-08 19:24:08 +03:00
tabIndex={-1}
>
2023-07-15 17:46:19 +03:00
{text}
</Link>
);
} else if (onClick) {
return (
<span
2023-12-08 19:24:08 +03:00
className={design}
onClick={onClick}
2023-12-08 19:24:08 +03:00
tabIndex={-1}
>
{text}
</span>);
} else {
return null;
}
2023-07-15 17:46:19 +03:00
}
export default TextURL;