Skip to content

Commit 63d343e

Browse files
authored
Use a flyout menu on narrow screens (graphql#1095)
1 parent 7234421 commit 63d343e

File tree

5 files changed

+79
-15
lines changed

5 files changed

+79
-15
lines changed

src/assets/css/_css/graphql.less

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,70 @@ header {
158158
}
159159

160160
nav {
161+
input {
162+
display: none;
163+
}
164+
161165
@media screen and (min-width: 1020px) {
162166
float: left;
163167
}
164-
@media screen and (max-width: 1019px) {
168+
169+
@media screen and (min-width: 720px) and (max-width: 1019px) {
165170
text-align: center;
166171
margin: 0 -1em;
167172
}
168173

174+
@media screen and (max-width: 719px) {
175+
height: 50px;
176+
position: relative;
177+
178+
input {
179+
display: block;
180+
float: right;
181+
appearance: none;
182+
background: url(http://github.com/%3Cspan%20class=%22pl-s%22%3E%3Cspan%20class=%22pl-pds%22%3E"%3C/span%3E/img/menu.svg%3Cspan%20class=%22pl-pds%22%3E"%3C/span%3E%3C/span%3E);
183+
width: 42px;
184+
height: 42px;
185+
margin: 4px 0;
186+
cursor: pointer;
187+
188+
.hero & {
189+
background: url(http://github.com/%3Cspan%20class=%22pl-s%22%3E%3Cspan%20class=%22pl-pds%22%3E"%3C/span%3E/img/menu-white.svg%3Cspan%20class=%22pl-pds%22%3E"%3C/span%3E%3C/span%3E);
190+
}
191+
}
192+
193+
div {
194+
display: none;
195+
}
196+
197+
input:checked + div {
198+
display: block;
199+
position: absolute;
200+
top: 100%;
201+
right: 0;
202+
left: 0;
203+
a {
204+
display: block;
205+
background: white;
206+
width: 100%;
207+
left: 0;
208+
.hero & {
209+
background: @dark-color;
210+
&:hover,
211+
&:focus {
212+
color: white;
213+
}
214+
}
215+
}
216+
a:not(:first-child) {
217+
border-top: solid 1px #eee;
218+
.hero & {
219+
border-top-color: #666;
220+
}
221+
}
222+
}
223+
}
224+
169225
a {
170226
color: #aaa;
171227
display: inline-block;
@@ -224,10 +280,11 @@ footer {
224280
}
225281
}
226282

227-
a, span {
283+
a,
284+
span {
228285
color: white;
229286
display: table;
230-
margin: 2px -10px;
287+
margin: 2px 15px 2px -10px;
231288
padding: 3px 10px;
232289
position: relative;
233290

@@ -247,11 +304,13 @@ footer {
247304
margin: 0 0 10px;
248305

249306
&,
250-
& > a, & > span {
307+
& > a,
308+
& > span {
251309
color: lighten(@dark-color, 50%);
252310
}
253311

254-
& > a, & > span {
312+
& > a,
313+
& > span {
255314
margin: 0 -10px;
256315
}
257316
}

src/assets/css/_css/index.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ div.index {
5454
height: 13vh;
5555
}
5656

57-
nav > a {
57+
nav a {
5858
text-shadow: 0 1px 1px @dark-color, 0 0 3px @dark-color;
5959

6060
&:hover, &:focus {

src/components/HeaderLinks/index.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ const links: LinkItem[] = [
1111
{
1212
section: "learn",
1313
text: "Learn",
14-
href: "/learn/"
14+
href: "/learn/",
1515
},
1616
{
1717
section: "code",
1818
text: "Code",
19-
href: "/code/"
19+
href: "/code/",
2020
},
2121
{
2222
section: "community",
2323
text: "Community",
24-
href: "/community/"
24+
href: "/community/",
2525
},
2626
{
2727
section: "faq",
2828
text: "FAQ",
29-
href: "/faq/"
29+
href: "/faq/",
3030
},
3131
{
3232
section: "spec",
@@ -47,10 +47,13 @@ const links: LinkItem[] = [
4747

4848
export default () => (
4949
<nav>
50-
{links.map((link, i) => (
51-
<Link key={i} href={link.href}>
52-
{link.text}
53-
</Link>
54-
))}
50+
<input type="checkbox" id="menubox" aria-label="Menu" />
51+
<div>
52+
{links.map((link, i) => (
53+
<Link key={i} href={link.href}>
54+
{link.text}
55+
</Link>
56+
))}
57+
</div>
5558
</nav>
5659
)

static/img/menu-white.svg

Lines changed: 1 addition & 0 deletions
Loading

static/img/menu.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)