diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-03-31 15:30:07 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-03-31 15:30:07 +0200 |
| commit | 351532e9906e32c862bf6810a3871993cde13ba2 (patch) | |
| tree | 09eb36959eac3b6f39b03a489cd47740d0a2ea9b /src/components/atoms/buttons/button-link.tsx | |
| parent | d7d453f7333def28007b94b9c9d872f89224fc91 (diff) | |
chore: add a button link component
Diffstat (limited to 'src/components/atoms/buttons/button-link.tsx')
| -rw-r--r-- | src/components/atoms/buttons/button-link.tsx | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/components/atoms/buttons/button-link.tsx b/src/components/atoms/buttons/button-link.tsx new file mode 100644 index 0000000..c33a4b7 --- /dev/null +++ b/src/components/atoms/buttons/button-link.tsx @@ -0,0 +1,49 @@ +import Link from 'next/link'; +import { FC } from 'react'; +import styles from './buttons.module.scss'; + +type ButtonLinkProps = { + /** + * ButtonLink accessible label. + */ + 'aria-label'?: string; + /** + * True if it is an external link. Default: false. + */ + external?: boolean; + /** + * ButtonLink kind. Default: secondary. + */ + kind?: 'primary' | 'secondary'; + /** + * Define an URL as target. + */ + target: string; +}; + +/** + * ButtonLink component + * + * Use a button-like link as call to action. + */ +const ButtonLink: FC<ButtonLinkProps> = ({ + children, + target, + kind = 'secondary', + external = false, + ...props +}) => { + const kindClass = styles[`btn--${kind}`]; + + return external ? ( + <a href={target} className={`${styles.btn} ${kindClass}`} {...props}> + {children} + </a> + ) : ( + <Link href={target} {...props}> + <a className={`${styles.btn} ${kindClass}`}>{children}</a> + </Link> + ); +}; + +export default ButtonLink; |
