diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-09-20 16:38:54 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-09-20 16:38:54 +0200 |
| commit | f861e6a269ba9f62700776d3cd13b644a9e836d4 (patch) | |
| tree | a5a107e7a6e4ff8b4261fe04349357bc00b783ee /src/components/atoms/buttons/button-link.tsx | |
| parent | 03331c44276ec56e9f235e4d5ee75030455a753f (diff) | |
refactor: use named export for everything except pages
Next expect a default export for pages so only those components should
use default exports. Everything else should use named exports to
reduce the number of import statements.
Diffstat (limited to 'src/components/atoms/buttons/button-link.tsx')
| -rw-r--r-- | src/components/atoms/buttons/button-link.tsx | 33 |
1 files changed, 6 insertions, 27 deletions
diff --git a/src/components/atoms/buttons/button-link.tsx b/src/components/atoms/buttons/button-link.tsx index 7182d94..c8180c9 100644 --- a/src/components/atoms/buttons/button-link.tsx +++ b/src/components/atoms/buttons/button-link.tsx @@ -1,25 +1,13 @@ import Link from 'next/link'; -import { FC, ReactNode } from 'react'; +import { AnchorHTMLAttributes, FC, ReactNode } from 'react'; import styles from './buttons.module.scss'; -export type ButtonLinkProps = { - /** - * ButtonLink accessible label. - */ - 'aria-label'?: string; - /** - * One or more ids that refer to the accessible label. - */ - 'aria-labelledby'?: string; +export type ButtonLinkProps = AnchorHTMLAttributes<HTMLAnchorElement> & { /** * The button link body. */ children: ReactNode; /** - * Set additional classnames to the button link. - */ - className?: string; - /** * True if it is an external link. Default: false. */ external?: boolean; @@ -42,7 +30,7 @@ export type ButtonLinkProps = { * * Use a button-like link as call to action. */ -const ButtonLink: FC<ButtonLinkProps> = ({ +export const ButtonLink: FC<ButtonLinkProps> = ({ children, className, target, @@ -53,24 +41,15 @@ const ButtonLink: FC<ButtonLinkProps> = ({ }) => { const kindClass = styles[`btn--${kind}`]; const shapeClass = styles[`btn--${shape}`]; + const btnClass = `${styles.btn} ${kindClass} ${shapeClass} ${className}`; return external ? ( - <a - href={target} - className={`${styles.btn} ${kindClass} ${shapeClass} ${className}`} - {...props} - > + <a {...props} className={btnClass} href={target}> {children} </a> ) : ( - <Link - {...props} - className={`${styles.btn} ${kindClass} ${shapeClass} ${className}`} - href={target} - > + <Link {...props} className={btnClass} href={target}> {children} </Link> ); }; - -export default ButtonLink; |
