aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/molecules/buttons/back-to-top.tsx
blob: bd1925a91f818b091b32a458c122a32658faf2b0 (plain)
1
2
3
4
5
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .
import ButtonLink, {
  type ButtonLinkProps,
} from '@components/atoms/buttons/button-link';
import Arrow from '@components/atoms/icons/arrow';
import { FC } from 'react';
import { useIntl } from 'react-intl';
import styles from './back-to-top.module.scss';

export type BackToTopProps = Pick<ButtonLinkProps, 'target'> & {
  /**
   * Set additional classnames to the button wrapper.
   */
  className?: string;
};

/**
 * BackToTop component
 *
 * Render a back to top link.
 */
const BackToTop: FC<BackToTopProps> = ({ className = '', target }) => {
  const intl = useIntl();
  const linkName = intl.formatMessage({
    defaultMessage: 'Back to top',
    description: 'BackToTop: link text',
    id: 'm+SUSR',
  });

  return (
    <div className={`${styles.wrapper} ${className}`}>
      <ButtonLink
        shape="square"
        target={`#${target}`}
        aria-label={linkName}
        className={styles.link}
      >
        <Arrow direction="top" />
      </ButtonLink>
    </div>
  );
};

export default BackToTop;