All files / components/footer/BackToTop BackToTop.js

62.5% Statements 5/8
0% Branches 0/2
50% Functions 1/2
62.5% Lines 5/8

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            1x 1x   1x 1x                       1x                      
// @flow
 
import { ArrowWrapper, Wrapper } from "./styled"
import FAIcon from "components/fa-icon"
import React from "react"
 
export const TOP = 0
export const LEFT = 0
 
const BackToTop = (): React$Node => {
  const onClick = () => {
    if (typeof window === "undefined") {
      return
    }
 
    window.scrollTo({
      behavior: "smooth",
      left: LEFT,
      top: TOP
    })
  }
 
  return (
    // eslint-disable-next-line react/jsx-no-bind
    <Wrapper onClick={onClick}>
      <ArrowWrapper>
        <FAIcon fontSize="28px" name="angle-double-up" />
      </ArrowWrapper>
    </Wrapper>
  )
}
 
export default BackToTop