-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-browser.js
43 lines (38 loc) · 1.07 KB
/
gatsby-browser.js
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
import React, { Component } from "react";
import Header from "./src/components/Header";
import Layout from "./src/components/layout";
export const wrapPageElement = ({ element, props }) => {
return <PageStatefulWrapper props={props} element={element} />;
};
class PageStatefulWrapper extends Component {
constructor(props) {
super(props);
this.state = {
menuVisibility: false,
activeNavbarItem: "",
};
}
selectMenuItem = e =>
this.setState({
activeNavbarItem: e.target.getAttribute("data-heading"),
});
toggleMenu = e =>
this.setState({
menuVisibility: !this.state.menuVisibility,
});
render() {
const { props, element } = this.props;
const { menuVisibility, activeNavbarItem } = this.state;
return (
<div className="pageWrapper">
<Header
menuVisibility={menuVisibility}
activeNavbarItem={activeNavbarItem}
menuToggleHandler={this.toggleMenu}
onClickHandler={this.selectMenuItem}
/>
<Layout {...props}>{element}</Layout>
</div>
);
}
}