forked from zerostaticthemes/gatsby-serif-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHeader.js
65 lines (60 loc) · 1.56 KB
/
Header.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import React from 'react';
import { graphql, Link, StaticQuery } from 'gatsby';
import Menu from './Menu';
import Hamburger from './Hamburger';
// import logo from '../../static/images/logo/logo.svg';
// import logoMobile from '../../static/images/logo/logo-mobile.svg';
import MenuMobile from './MenuMobile';
class Header extends React.Component {
constructor(props) {
super(props);
this.state = {
menuActive: false
};
}
toggleMenu = menuActive => {
this.setState(prevState => ({
menuActive: !prevState.menuActive
}));
};
render() {
const config = this.props.data.configJson;
return (
<div className="header">
<div className="container">
<div className="logo">
<Link to="/">
<img height={config.logo.desktop_height} alt={config.logo.alt} src={config.logo.desktop} />
</Link>
</div>
<div className="logo-mobile">
<Link to="/">
<img height={config.logo.desktop_height} alt={config.logo.alt} src={config.logo.mobile} />
</Link>
</div>
<MenuMobile active={this.state.menuActive} />
<Menu />
<Hamburger toggleMenu={this.toggleMenu} />
</div>
</div>
);
}
}
const props = () => (
<StaticQuery
query={graphql`
query HeaderQuery {
configJson {
logo {
alt
desktop
mobile
desktop_height
}
}
}
`}
render={data => <Header data={data} />}
/>
);
export default props;