summaryrefslogtreecommitdiffstats
path: root/src/components/Footer/Footer.tsx
blob: 4aa980d6cb51e931c331d9fc97a085700a6a2dcb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { ButtonLink } from '@components/Buttons';
import Copyright from '@components/Copyright/Copyright';
import FooterNav from '@components/FooterNav/FooterNav';
import { ArrowIcon } from '@components/Icons';
import { useEffect, useState } from 'react';
import { useIntl } from 'react-intl';
import styles from './Footer.module.scss';

const Footer = () => {
  const intl = useIntl();
  const [backToTopClasses, setBackToTopClasses] = useState(
    `${styles['back-to-top']} ${styles['back-to-top--hidden']}`
  );

  const handleScroll = () => {
    const currentScrollY = window.scrollY;

    if (currentScrollY > 300) {
      setBackToTopClasses(
        `${styles['back-to-top']} ${styles['back-to-top--visible']}`
      );
    } else {
      setBackToTopClasses(
        `${styles['back-to-top']} ${styles['back-to-top--hidden']}`
      );
    }
  };

  useEffect(() => {
    window.addEventListener('scroll', handleScroll);
    return () => window.removeEventListener('scroll', handleScroll);
  }, []);

  return (
    <footer className={styles.wrapper}>
      <Copyright />
      <FooterNav />
      <div className={backToTopClasses}>
        <ButtonLink target="#top" position="center">
          <span className="screen-reader-text">
            {intl.formatMessage({
              defaultMessage: 'Back to top',
              description: 'Footer: Back to top button',
            })}
          </span>
          <ArrowIcon direction="top" />
        </ButtonLink>
      </div>
    </footer>
  );
};

export default Footer;
required: false, }, }, data: { description: 'The page data.', type: { name: 'object', required: true, value: {}, }, }, expanded: { control: { type: null, }, description: 'Default widget state (expanded or collapsed).', table: { category: 'Options', defaultValue: { summary: true }, }, type: { name: 'boolean', required: false, }, }, level: { control: { type: 'number', min: 1, max: 6, }, description: 'The heading level.', table: { category: 'Options', defaultValue: { summary: 2 }, }, type: { name: 'number', required: false, }, }, media: { control: { type: null, }, description: 'An array of active and ordered sharing medium.', type: { name: 'string', required: true, }, }, }, } as ComponentMeta<typeof SharingWidget>; const Template: ComponentStory<typeof SharingWidget> = (args) => ( <SharingWidget {...args} /> ); /** * Widgets Stories - Sharing */ export const Sharing = Template.bind({}); Sharing.args = { data: { excerpt: 'Alias similique eius ducimus laudantium aspernatur. Est rem ut eum temporibus sit reprehenderit aut non molestias. Vel dolorem expedita labore quo inventore aliquid nihil nam. Possimus nobis enim quas corporis eos.', title: 'Accusantium totam nostrum', url: 'https://www.example.test', }, media: ['diaspora', 'facebook', 'linkedin', 'twitter', 'email'], };