Skip to content

Commit ccb7016

Browse files
Merge pull request #211 from sophie-h/sophie-h/mobile-menu
Make mobile menu navi a bit nicer
2 parents 84791f2 + ad9c5e3 commit ccb7016

File tree

4 files changed

+48
-91
lines changed

4 files changed

+48
-91
lines changed

_includes/header.html

+5-13
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,11 @@
33

44
<div class="wrapper">
55
<nav class="site-nav">
6-
<a href="#" class="menu-icon">
7-
<svg viewBox="0 0 18 15">
8-
<path fill="#424242" d="M18,1.484c0,0.82-0.665,1.484-1.484,1.484H1.484C0.665,2.969,0,2.304,0,1.484l0,0C0,0.665,0.665,0,1.484,0 h15.031C17.335,0,18,0.665,18,1.484L18,1.484z"/>
9-
<path fill="#424242" d="M18,7.516C18,8.335,17.335,9,16.516,9H1.484C0.665,9,0,8.335,0,7.516l0,0c0-0.82,0.665-1.484,1.484-1.484 h15.031C17.335,6.031,18,6.696,18,7.516L18,7.516z"/>
10-
<path fill="#424242" d="M18,13.516C18,14.335,17.335,15,16.516,15H1.484C0.665,15,0,14.335,0,13.516l0,0 c0-0.82,0.665-1.484,1.484-1.484h15.031C17.335,12.031,18,12.696,18,13.516L18,13.516z"/>
11-
</svg>
12-
</a>
13-
14-
<div class="trigger">
15-
<a class="page-link" href="/blog">Blog</a>
16-
<a class="page-link" href="/faq">FAQ</a>
17-
<a class="page-link" href="/contact">Contact</a>
18-
</div>
6+
<ul>
7+
<li><a href="/blog">Blog</a></li>
8+
<li><a href="/faq">FAQ</a></li>
9+
<li><a href="/contact">Contact</a></li>
10+
</ul>
1911
</nav>
2012

2113
<a class="site-title" href="{{ site.baseurl }}/">{{ site.title }}</a>

_sass/_base.scss

+6-10
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ h1, h2, h3, h4, h5, h6,
4040
p, blockquote, pre,
4141
ul, ol, dl, figure,
4242
%vertical-rhythm {
43-
margin-bottom: $spacing-unit / 2;
43+
margin-bottom: var(--spacing-unit-half);
4444
}
4545

4646

@@ -72,7 +72,7 @@ figcaption {
7272
* Lists
7373
*/
7474
ul, ol {
75-
margin-left: $spacing-unit;
75+
margin-left: var(--spacing-unit);
7676
}
7777

7878
li {
@@ -166,7 +166,7 @@ td.docs {
166166
blockquote {
167167
color: $grey-color;
168168
border-left: 4px solid $grey-color-light;
169-
padding-left: $spacing-unit / 2;
169+
padding-left: var(--spacing-unit-half);
170170
font-size: 18px;
171171
letter-spacing: -1px;
172172
font-style: italic;
@@ -212,13 +212,9 @@ code {
212212
* Wrapper
213213
*/
214214
.wrapper {
215-
padding-left: calc(50vw - 400px);
216-
padding-right: calc(50vw - 400px);
217-
218-
@include media-query($on-laptop) {
219-
padding-right: $spacing-unit / 2;
220-
padding-left: $spacing-unit / 2;
221-
}
215+
--padding: calc(50vw - (var(--content-width) / 2) + var(--spacing-unit-half));
216+
padding-left: max(var(--padding), var(--spacing-unit-half));
217+
padding-right: max(var(--padding), var(--spacing-unit-half));
222218
}
223219

224220
section {

_sass/_layout.scss

+27-61
Original file line numberDiff line numberDiff line change
@@ -49,71 +49,41 @@
4949
.site-nav {
5050
float: right;
5151

52-
.trigger {
52+
ul {
5353
display: flex;
5454
justify-content: flex-end;
55-
margin-right: 1.5rem;
56-
}
57-
58-
.menu-icon {
59-
display: none;
60-
}
61-
62-
.page-link {
63-
color: $header-text-color;
64-
line-height: 3em;
65-
margin: 0 1rem;
66-
font-weight: bold;
67-
transition: 0.3s;
68-
transition-property: color;
69-
border-radius: 7px;
70-
}
71-
72-
.page-link:hover {
73-
color: white;
74-
}
55+
flex-wrap: wrap;
7556

76-
@include media-query($on-laptop) {
77-
position: absolute;
78-
top: 1.5em;
79-
right: 1.5em;
80-
border: 1px solid white;
81-
border-radius: 5px;
82-
background: $box-background;
57+
margin: 0;
58+
margin-right: 1.5rem;
8359

84-
.page-link {
85-
float: none;
86-
display: block;
87-
padding: 0 1.5em;
88-
}
60+
li {
61+
list-style: none;
62+
display: inline-block;
8963

90-
.menu-icon {
91-
display: block;
92-
float: right;
93-
width: 36px;
94-
height: 26px;
95-
line-height: 0;
96-
padding-top: 10px;
97-
text-align: center;
98-
99-
> svg {
100-
width: 18px;
101-
height: 15px;
102-
103-
path {
104-
fill: white;
64+
a {
65+
color: $header-text-color;
66+
line-height: 3em;
67+
margin: 0 1rem;
68+
font-weight: bold;
69+
transition: 0.3s;
70+
transition-property: color;
71+
border-radius: 7px;
72+
73+
&:hover {
74+
color: white;
10575
}
10676
}
10777
}
78+
}
10879

109-
.trigger {
110-
clear: both;
111-
display: none;
112-
}
80+
@include media-query($on-mobile) {
81+
float: none;
82+
margin-bottom: -1rem;
11383

114-
&:hover .trigger {
115-
display: block;
116-
padding-bottom: 5px;
84+
ul {
85+
justify-content: center;
86+
margin-right: 0;
11787
}
11888
}
11989
}
@@ -219,7 +189,7 @@ section.special {
219189
list-style: none;
220190

221191
> li {
222-
margin-bottom: $spacing-unit;
192+
margin-bottom: var(--spacing-unit);
223193
}
224194
}
225195

@@ -271,17 +241,13 @@ section.special {
271241
* Posts
272242
*/
273243
.post-header {
274-
margin-bottom: $spacing-unit;
244+
margin-bottom: var(--spacing-unit);
275245
}
276246

277247
.post-title {
278248
font-size: 42px;
279249
letter-spacing: -1px;
280250
line-height: 1;
281-
282-
@include media-query($on-laptop) {
283-
font-size: 36px;
284-
}
285251
}
286252

287253
/**

_sass/_variables.scss

+10-7
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,13 @@ $base-line-height: 1.3;
77
$headings-font-family: Cantarell, Helvetica, Arial, sans-serif;
88
$headings-color: #3d3846;
99

10-
$spacing-unit: 25px;
11-
1210
$text-color: #3d3846;
1311
$background-color: #f6f5f4;
1412
$brand-color: #813d9c;
1513

1614
$grey-color: #828282;
1715
$grey-color-light: lighten($grey-color, 40%);
1816

19-
$on-palm: 675px;
20-
$on-laptop: 820px;
21-
2217
$header-borders: 6px;
2318
$header-line-height: 56px;
2419
$content-padding: 10px;
@@ -29,11 +24,19 @@ $header-text-color: #dc8add;
2924

3025
$box-background: linear-gradient(150deg, #241f31, #3d3846);
3126

27+
$on-mobile: 600px;
28+
29+
body {
30+
--content-width: 800px;
31+
--spacing-unit: 26px;
32+
--spacing-unit-half: calc(var(--spacing-unit) / 2);
33+
}
34+
3235
// Using media queries with like this:
3336
// @include media-query($palm) {
3437
// .wrapper {
35-
// padding-right: $spacing-unit / 2;
36-
// padding-left: $spacing-unit / 2;
38+
// padding-right: var(--spacing-unit-half);
39+
// padding-left: var(--spacing-unit-half);
3740
// }
3841
// }
3942
@mixin media-query($device) {

0 commit comments

Comments
 (0)