import { cloneElement, ReactNode, ReactElement, ElementType } from 'react' import cx from 'classnames' import styles from './BumpLink.module.scss' type Props = { children?: ReactNode title: ReactElement | string href: string as?: ElementType<{ className?: string; href: string }> className?: string } export const BumpLink = ({ as, children, href, title, className }: Props) => { const Component = as || 'a' const symbol = let extendedTitle: ReactNode if (typeof title === 'string') { extendedTitle = ( {title} {symbol} ) } else { extendedTitle = cloneElement(title, title.props, title.props.children, symbol) } return ( {extendedTitle} {children} ) }