Passed
Push — hotfix/pin-babel-plugin-remove... ( 5322a8...20c83a )
by Kevin Van
03:23
created

src/layouts/index.js   A

Complexity

Total Complexity 4
Complexity/F 2

Size

Lines of Code 53
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 44
mnd 2
bc 2
fnc 2
dl 0
loc 53
bpm 1
cpm 2
noi 0
c 0
b 0
f 0
rs 10

2 Functions

Rating   Name   Duplication   Size   Complexity  
A Layout.render 0 16 1
A Layout.componentDidMount 0 21 3
1
import React, { Component, Fragment } from "react"
2
3
// import './index.scss'
4
import PageHeader from "../components/page-header"
5
import { PageHeaderMobile } from "../components/page-header"
6
import PageFooter from "../components/page-footer"
7
8
class Layout extends Component {
9
  render() {
10
    const { children } = this.props
11
12
    return (
13
      <Fragment>
14
        <div className={"off-canvas-wrapper"}>
15
          <PageHeaderMobile />
16
          <PageHeader />
17
18
          <main className={"off-canvas-content"} data-off-canvas-content>
19
            {children}
20
          </main>
21
22
          <PageFooter />
23
        </div>
24
      </Fragment>
25
    )
26
  }
27
28
  componentDidMount() {
29
    const $ = require("jquery")
30
    // eslint-disable-next-line
31
    const foundation = require("foundation-sites")
32
    $(document).foundation()
33
34
    $(".main-nav a").on("click", function () {
35
      if (
36
        $(this).attr("href").indexOf(window.location.pathname) === 0 &&
37
        window.location.hash
38
      ) {
39
        const url = $(this).attr("href")
40
        const hash = url.substring(url.indexOf("#"))
41
42
        $(`.team-sub_navigation a[href="${hash}"]`).click()
43
      }
44
    })
45
46
    if (window.location.hash) {
47
      $(`.team-sub_navigation a[href="${window.location.hash}"]`).click()
48
    }
49
  }
50
}
51
52
export default Layout
53