# All files / src/layouts/ApplicationLayout index.tsx

48.28% Statements 14/29
0% Branches 0/12
0% Functions 0/2
48.15% Lines 13/27

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    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
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x

    1x

    1x

     import type { FC } from 'react';
    import { Heading } from '@cutting/component-library';
    import cs from 'classnames';
    import { useRef, useEffect } from 'react';
    import { Footer } from 'src/components/Footer';
    import { Header } from 'src/components/Header';
    import { useScrollToTop } from '@cutting/hooks';
    import { CuttingEdge } from 'src/constants';
    import { useLocation } from 'react-router';
    import { Covid19 } from 'src/urls';
    import { Helmet } from 'react-helmet';
    import { ApplicationLayoutWithRouterScroll } from '@cutting/component-library';

    import styles from './ApplicationLayout.module.scss';

    export interface ApplicationLayoutProps {
      heading?: string;
      italicise?: boolean;
      center?: boolean;
      className?: string;
      showFooter?: boolean;
    }

    export const ApplicationLayout: FC<ApplicationLayoutProps> = ({
      heading,
      italicise,
      center,
      className,
      showFooter = true,
      children,
    }) => {
      const root = useRef<HTMLDivElement>(null);

      useScrollToTop({ ref: root });
      const { pathname } = useLocation();

      useEffect(() => {
        if (__BROWSER__ && pathname.indexOf(Covid19) > -1) {
          document.body.classList.add('covid');
        } else {
          document.body.classList.remove('covid');
        }
      }, [pathname]);

      return (
        <ApplicationLayoutWithRouterScroll
          className={className}
          heading={
            heading && (
              <Heading
                className={cs({
                  [styles.italic]: italicise,
                  [styles.center]: center,
                })}
              >
                {heading}
              </Heading>
            )
          }
          Header={
            <>
              <Helmet title={heading || CuttingEdge}>
                <meta charSet="utf-8" />
                <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
              </Helmet>
              <Header />
            </>
          }
          Footer={showFooter ? <Footer /> : undefined}
        >
          <>{children}</>
        </ApplicationLayoutWithRouterScroll>
      );
    };