import { ReactNode } from 'react' import { Link } from '@remix-run/react' import { isValidHttpUrl } from '~/helpers/strings' import clsx from 'clsx' import { anchor } from './Anchor.css' export interface AnchorProps { href: string children: ReactNode className?: string onClick?: React.MouseEventHandler } export const Anchor = ({ href, children, className, onClick }: AnchorProps) => { const isExternal = isValidHttpUrl(href) const handleClick: React.MouseEventHandler = e => { if (onClick) { onClick(e) } } if (isExternal) { return ( {children} ) } else { return ( {children} ) } }