Skip to content

Commit 53ad183

Browse files
committed
add hamburger menu and remove oversized panels
1 parent d6a827c commit 53ad183

File tree

3 files changed

+130
-31
lines changed

3 files changed

+130
-31
lines changed

packages/microcosm-www-next/src/layouts/index.js

Lines changed: 80 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react'
1+
import React, { Component } from 'react'
22
import PropTypes from 'prop-types'
33
import Link from 'gatsby-link'
44
import Helmet from 'react-helmet'
@@ -12,21 +12,85 @@ if (isBrowser) {
1212
require('lazysizes') //lazy loading images
1313
}
1414

15-
const Navigation = () => (
16-
<nav className="navigation">
17-
<div className="wrapper">
18-
<h1>
19-
<span className="screenreader-only">Microcosm</span>
20-
<img src={microcosmLogo} alt="" />
21-
</h1>
22-
23-
{/*
24-
@TODO add menu back in later
25-
<img src={menu} alt="menu" />
26-
*/}
27-
</div>
28-
</nav>
29-
)
15+
class Navigation extends Component {
16+
constructor(props) {
17+
super(props)
18+
19+
this.state = {
20+
hidden: true
21+
}
22+
}
23+
24+
handleHamburger = () => {
25+
const { hidden } = this.state
26+
27+
this.setState({
28+
hidden: !hidden
29+
})
30+
}
31+
32+
closeHamburger = () => {
33+
this.setState({
34+
hidden: true
35+
})
36+
}
37+
38+
render() {
39+
const { hidden } = this.state
40+
41+
return (
42+
<nav onMouseLeave={this.closeHamburger} className="navigation">
43+
<div className="wrapper">
44+
<h1>
45+
<span className="screenreader-only">Microcosm</span>
46+
<img src={microcosmLogo} alt="" />
47+
</h1>
48+
49+
<button
50+
onClick={this.handleHamburger}
51+
aria-controls="menu"
52+
className="hamburger"
53+
>
54+
Open Navigation
55+
</button>
56+
<ul
57+
id="menu"
58+
aria-hidden={hidden || null}
59+
className="hamburger-dropdown"
60+
>
61+
<li>
62+
<a
63+
href="http://code.viget.com/microcosm/guides/quickstart.html"
64+
target="_blank"
65+
rel="noopener noreferrer"
66+
>
67+
Microcosm Guides
68+
</a>
69+
</li>
70+
<li>
71+
<a
72+
href="http://code.viget.com/microcosm/api/"
73+
target="_blank"
74+
rel="noopener noreferrer"
75+
>
76+
Microcosm API
77+
</a>
78+
</li>
79+
<li>
80+
<a
81+
href="https://github.com/vigetlabs/microcosm"
82+
target="_blank"
83+
rel="noopener noreferrer"
84+
>
85+
Microcosm Github
86+
</a>
87+
</li>
88+
</ul>
89+
</div>
90+
</nav>
91+
)
92+
}
93+
}
3094

3195
const Footer = () => (
3296
<footer className="footer">

packages/microcosm-www-next/src/stylesheets/structure/_nav.scss

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,54 @@
1414
display: flex;
1515
height: inherit;
1616
justify-content: space-between;
17+
position: relative;
18+
}
19+
}
20+
21+
.hamburger {
22+
background: none;
23+
border-bottom: 3px solid white;
24+
border-top: 3px solid white;
25+
height: 23px;
26+
position: relative;
27+
text-indent: -9999px;
28+
width: 28px;
29+
30+
&::after {
31+
background: white;
32+
border-top: 3px solid white;
33+
content: "";
34+
display: block;
35+
height: 0;
36+
left: 0;
37+
position: absolute;
38+
top: 50%;
39+
transform: translate(0, -1px);
40+
width: 100%;
41+
}
42+
}
43+
44+
.hamburger-dropdown {
45+
background: #aaa;
46+
border: 1px solid #aaa;
47+
position: absolute;
48+
right: 0;
49+
top: 100%;
50+
51+
border-top: none;
52+
53+
&[aria-hidden] {
54+
display: none;
55+
}
56+
57+
a {
58+
display: block;
59+
padding: 20px;
60+
text-decoration: none;
61+
62+
&:hover, &:focus {
63+
background: white;
64+
color: #aaa;
65+
}
1766
}
1867
}

packages/microcosm-www-next/src/stylesheets/structure/_section.scss

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,13 @@ $split-bg-height-desktop: 291px;
77

88
.section {
99
background-color: color(bg-0-bottom);
10-
min-height: 140vh;
10+
min-height: 100vh;
1111
padding-bottom: 60px;
1212
padding-top: $section-top-padding-mobile;
1313
position: -webkit-sticky;
1414
position: sticky;
1515
top: 0;
1616

17-
&:last-child {
18-
min-height: 100vh;
19-
}
20-
21-
@include breakpoint(medium-desktop-up) {
22-
@media (max-height: 900px) { //from desktop up, if the screen is long enough (i.e. enough space), fix footer to bottom
23-
min-height: 100vh;
24-
}
25-
}
26-
27-
@include breakpoint(small-desktop-down) {
28-
min-height: 100vh;
29-
}
30-
3117
@include breakpoint(medium-desktop-up) {
3218
padding-top: $section-top-padding-desktop;
3319
}

0 commit comments

Comments
 (0)