From be61ffb6fe500cdbfa83b9cd131b8e72779f23c2 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Wed, 4 Oct 2023 18:17:35 +0200 Subject: refactor(components): rewrite BackToTop component * replace `link` prop with `anchor` prop * add a `label` prop to let consumer handle the accessible name --- .../molecules/buttons/back-to-top/back-to-top.tsx | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/components/molecules/buttons/back-to-top/back-to-top.tsx (limited to 'src/components/molecules/buttons/back-to-top/back-to-top.tsx') diff --git a/src/components/molecules/buttons/back-to-top/back-to-top.tsx b/src/components/molecules/buttons/back-to-top/back-to-top.tsx new file mode 100644 index 0000000..83e2161 --- /dev/null +++ b/src/components/molecules/buttons/back-to-top/back-to-top.tsx @@ -0,0 +1,45 @@ +import type { FC } from 'react'; +import { + ButtonLink, + type ButtonLinkProps, + Icon, + VisuallyHidden, +} from '../../../atoms'; +import styles from './back-to-top.module.scss'; + +export type BackToTopProps = Omit< + ButtonLinkProps, + 'children' | 'isExternal' | 'kind' | 'to' +> & { + /** + * Define the anchor. + */ + anchor: string; + /** + * Define an accessible label for the button. + */ + label: string; +}; + +/** + * BackToTop component + * + * Render a back to top link. + */ +export const BackToTop: FC = ({ + anchor, + className = '', + label, + shape = 'square', + ...props +}) => { + const btnClass = `${styles.link} ${className}`; + + return ( + + {/* eslint-disable-next-line react/jsx-no-literals -- Config allowed */} + + {label} + + ); +}; -- cgit v1.2.3