Skip to content

Commit 79d5dd3

Browse files
authored
Overlay menu adjustments (#16)
* Improve animation of off-canvas menu * Simplify styles and push main content with CSS transforms for higher FPS * Reduce padding around toggle button * Customize color of focus state * Merge overlay menu changes into /docs Close #15
1 parent 7127714 commit 79d5dd3

File tree

13 files changed

+73
-111
lines changed

13 files changed

+73
-111
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1010
- Google Analytics tracking ID, Disqus comments, to `/docs` demo site.
1111

1212
### Changed
13-
- Refactor sidebar off-canvas menu. [#9](https://github.com/mmistakes/jekyll-theme-basically-basic/issues/9)
13+
- Refactor sidebar off-canvas menu and improve animation. [#9](https://github.com/mmistakes/jekyll-theme-basically-basic/issues/9) [#15](https://github.com/mmistakes/jekyll-theme-basically-basic/issues/15)
1414
- Removed tinted background from `<th>` elements.
1515
- Permalink structure of `/docs` demo site.
1616

_layouts/default.html

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@
1313
{% include skip-links.html %}
1414

1515
<div class="sidebar-toggle-wrapper">
16-
<a class="toggle navicon-button larr" href="#sidebar">
16+
<button class="toggle navicon-button larr">
1717
<span class="sidebar-toggle-label">{{ site.data.theme.t.menu | default: 'Menu' }}</span>
1818
<div class="navicon"></div>
19-
</a>
19+
</button>
2020
</div>
2121

22-
<div class="wrapper">
23-
{% include masthead.html %}
24-
{{ content }}
22+
<div class="canvas">
23+
<div class="wrapper">
24+
{% include masthead.html %}
25+
{{ content }}
26+
</div>
2527
</div>
2628

2729
<div id="sidebar" class="sidebar">

_sass/basically-basic/_base.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,9 @@ a {
110110
color: shade($accent-color, 25%);
111111
}
112112
}
113+
114+
*:focus {
115+
border-color: $accent-color;
116+
outline: none;
117+
box-shadow: 0 0 10px $accent-color;
118+
}

_sass/basically-basic/_layout.scss

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,23 @@
22
Layout
33
========================================================================== */
44

5+
.canvas {
6+
position: relative;
7+
width: 100%;
8+
overflow: hidden;
9+
}
10+
511
.wrapper {
12+
position: relative;
613
width: 100%;
14+
height: 100%;
715
min-height: 100vh;
16+
transform: translateX(0);
817
transition: $global-transition;
9-
box-shadow: -1em 0 5em 0 rgba(0, 0, 0, 0.125);
10-
11-
@include breakpoint($medium) {
12-
position: relative;
13-
z-index: 200;
14-
}
18+
background-color: $background-color;
19+
z-index: 100;
20+
-webkit-backface-visibility: hidden;
21+
backface-visibility: hidden;
1522
}
1623

1724
.intro,

_sass/basically-basic/_navicons.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
.navicon-button {
66
display: inline-block;
77
position: relative;
8-
padding: 1.8125rem 1rem;
8+
margin: 0.90625rem 0;
9+
padding: 0.90625rem 1rem;
910
transition: $navicon-duration / 2;
11+
border: 0;
12+
outline: none;
1013
background-color: $navicon-nav-bg-close;
1114
cursor: pointer;
1215
-moz-user-select: none;

_sass/basically-basic/_sidebar.scss

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,12 @@
77
top: 0;
88
left: 0;
99
width: 100%;
10+
max-width: $sidebar-width;
1011
height: 100%;
11-
z-index: 150;
12-
13-
@include breakpoint($sidebar-width) {
14-
width: $sidebar-width;
15-
}
12+
z-index: 50;
1613

1714
@include breakpoint($large) {
18-
width: (1.5 * $sidebar-width);
15+
max-width: (1.5 * $sidebar-width);
1916
}
2017

2118
li {
@@ -55,46 +52,17 @@
5552
}
5653
}
5754

58-
&.is--visible {
59-
transform: translateX(0);
60-
61-
> .inner {
62-
transform: none;
63-
}
64-
65-
&.is--animatable > .inner {
66-
transition: all 330ms ease-out;
67-
}
68-
}
69-
70-
&.is--animatable > .inner {
71-
transition: all 130ms ease-in;
72-
}
73-
7455
> .inner {
75-
position: relative;
7656
width: 100%;
77-
max-width: $sidebar-width;
7857
height: 100%;
7958
padding: 1.5em;
80-
transform: translateX(-1 * $sidebar-width);
8159
background-color: $sidebar-background-color;
82-
z-index: 160;
83-
will-change: transform;
8460
overflow-x: hidden;
61+
box-shadow: inset -1em 0 5em 0 rgba(0, 0, 0, 0.125);
8562

8663
@include breakpoint($medium) {
8764
padding: 3rem;
8865
}
89-
90-
@include breakpoint(max-width $medium) {
91-
box-shadow: 0 0 5em 0 rgba(0, 0, 0, 0.125);
92-
}
93-
94-
@include breakpoint($large) {
95-
max-width: (1.5 * $sidebar-width);
96-
transform: translateX(-1.5 * $sidebar-width);
97-
}
9866
}
9967

10068
.menu {

_sass/basically-basic/utilities/_align.scss

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,10 @@ a img.align-left {
5353
========================================================================== */
5454

5555
.is--pushed {
56-
@include clearfix();
57-
58-
@include breakpoint($medium) {
59-
width: calc(100% - #{$sidebar-width});
60-
transform: translateX(1 * $sidebar-width);
61-
}
56+
transform: translateX(1 * $sidebar-width);
57+
transform-origin: right;
6258

6359
@include breakpoint($large) {
64-
width: calc(100% - (1.5 * #{$sidebar-width}));
6560
transform: translateX(1.5 * $sidebar-width);
6661
}
6762
}

docs/_layouts/default.html

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@
1313
{% include skip-links.html %}
1414

1515
<div class="sidebar-toggle-wrapper">
16-
<a class="toggle navicon-button larr" href="#sidebar">
16+
<button class="toggle navicon-button larr">
1717
<span class="sidebar-toggle-label">{{ site.data.theme.t.menu | default: 'Menu' }}</span>
1818
<div class="navicon"></div>
19-
</a>
19+
</button>
2020
</div>
2121

22-
<div class="wrapper">
23-
{% include masthead.html %}
24-
{{ content }}
22+
<div class="canvas">
23+
<div class="wrapper">
24+
{% include masthead.html %}
25+
{{ content }}
26+
</div>
2527
</div>
2628

2729
<div id="sidebar" class="sidebar">

docs/_sass/basically-basic/_base.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,9 @@ a {
110110
color: shade($accent-color, 25%);
111111
}
112112
}
113+
114+
*:focus {
115+
border-color: $accent-color;
116+
outline: none;
117+
box-shadow: 0 0 10px $accent-color;
118+
}

docs/_sass/basically-basic/_layout.scss

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,23 @@
22
Layout
33
========================================================================== */
44

5+
.canvas {
6+
position: relative;
7+
width: 100%;
8+
overflow: hidden;
9+
}
10+
511
.wrapper {
12+
position: relative;
613
width: 100%;
14+
height: 100%;
715
min-height: 100vh;
16+
transform: translateX(0);
817
transition: $global-transition;
9-
box-shadow: -1em 0 5em 0 rgba(0, 0, 0, 0.125);
10-
11-
@include breakpoint($medium) {
12-
position: relative;
13-
z-index: 200;
14-
}
18+
background-color: $background-color;
19+
z-index: 100;
20+
-webkit-backface-visibility: hidden;
21+
backface-visibility: hidden;
1522
}
1623

1724
.intro,

0 commit comments

Comments
 (0)