1
0
mirror of synced 2026-01-22 09:02:55 -05:00
Files
docs/components/ui/BumpLink/BumpLink.tsx
Kevin Heis d431e86dec Storybook lite (#21040)
* Remove storybook

* Update index.js

* Start a storybook outline

* Start a storybook outline

* Start showing errors

* Update storybook.tsx

* Typescript lint

* Name field

* Responsive

* Update storybook.tsx

* Update storybook.tsx

* Update storybook.tsx

* Add BumpLink to storybook

* Update storybook.tsx
2021-08-30 20:34:14 +00:00

41 lines
996 B
TypeScript

import { cloneElement, ReactNode, ReactElement, ElementType } from 'react'
import cx from 'classnames'
import styles from './BumpLink.module.scss'
export type BumpLinkPropsT = {
children?: ReactNode
title: ReactElement<any> | string
href: string
as?: ElementType<{ className?: string; href: string }>
className?: string
}
export const BumpLink = ({ as, children, href, title, className }: BumpLinkPropsT) => {
const Component = as || 'a'
const symbol = <span className={styles.symbol}></span>
let extendedTitle: ReactNode
if (typeof title === 'string') {
extendedTitle = (
<span className="h4">
{title} {symbol}
</span>
)
} else {
extendedTitle = cloneElement(title, title.props, title.props.children, symbol)
}
return (
<Component
data-testid="bump-link"
className={cx(styles.container, 'no-underline d-block py-1', className)}
href={href}
>
{extendedTitle}
{children}
</Component>
)
}