Passed
Push — release/20222023-design-rework ( 2d9f50 )
by Kevin Van
09:40 queued 03:39
created

src/layouts/index.tsx   A

Complexity

Total Complexity 4
Complexity/F 0

Size

Lines of Code 54
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 45
mnd 4
bc 4
fnc 0
dl 0
loc 54
rs 10
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
1
import $ from "jquery"
2
import React, { Fragment, useEffect, PropsWithChildren } from "react"
3
import { forceCheck } from "react-lazyload"
4
5
import { PageFooter } from "../components/PageFooter"
6
import { PageHeader, PageHeaderMobile } from "../components/PageHeader"
7
8
declare global {
9
  interface JQuery {
10
    foundation(): void
11
  }
12
}
13
14
const Layout = ({ children }: PropsWithChildren) => {
15
  useEffect(() => {
16
    // eslint-disable-next-line
17
    const foundation = require(`foundation-sites`)
18
    $(document).foundation()
19
20
    $(`.main-nav a`).on(`click`, function () {
21
      if ($(this)?.attr(`href`)?.indexOf(window.location.pathname) === 0 && window.location.hash) {
22
        const url = $(this).attr(`href`) || ``
23
        const hash = url.substring(url.indexOf(`#`))
24
25
        $(`.team__sub_navigation a[href="${hash}"]`).trigger(`click`, [true])
26
      }
27
    })
28
29
    if (window.location.hash) {
30
      $(`.team__sub_navigation a[href="${window.location.hash}"]`).trigger(`click`, [true])
31
    }
32
    $(`.widget__filter, .team__sub_navigation__tabs`).on(`change.zf.tabs`, function () {
33
      forceCheck()
34
    })
35
  }, [])
36
37
  return (
38
    <Fragment>
39
      <div className={`off-canvas-wrapper`}>
40
        <PageHeaderMobile />
41
        <PageHeader />
42
43
        <main className={`off-canvas-content`} data-off-canvas-content>
44
          {children}
45
        </main>
46
47
        <PageFooter />
48
      </div>
49
    </Fragment>
50
  )
51
}
52
53
export default Layout
54