import { IconNames } from '@blueprintjs/icons'; import classNames from 'classnames'; import type { ReactNode, AnchorHTMLAttributes } from 'react'; import { Icon } from '../icon'; type LinkProps = AnchorHTMLAttributes & { children?: ReactNode; }; /** * Form an HTML link tag */ export const Link = ({ className, children, ...props }: LinkProps) => { const anchorClassName = classNames(className, { underline: typeof children === 'string', 'cursor-pointer': props['aria-disabled'] !== true, 'opacity-50 pointer-events-none': props['aria-disabled'] === true, }); const shared = { role: 'link', 'data-testid': 'link', referrerPolicy: 'strict-origin' as const, className: anchorClassName, }; // if no href is passed just render a span, this is so that we can wrap an // element with our links styles with a react router link compoment if (!props.href) { return ( {children} ); } return ( {children} ); }; Link.displayName = 'Link'; export const ExternalLink = ({ children, className, ...props }: LinkProps) => ( {typeof children === 'string' ? ( <> {children} ) : ( children )} ); ExternalLink.displayName = 'ExternalLink';