New mobile menu.
This commit is contained in:
parent
0b35bcb8a2
commit
110d34531e
4 changed files with 120 additions and 24 deletions
|
|
@ -2,7 +2,7 @@
|
|||
{{ $currentID := .UniqueID }}
|
||||
<nav class="main-menu layout__navigation layout__full" role="navigation">
|
||||
<h2 class="visually-hidden">Main menu</h2>
|
||||
<ul class="navbar clearfix">
|
||||
<ul class="navbar">
|
||||
<li><a class="{{ if .IsHome }}active{{ end }}" href="/">{{ i18n "menu_home" }}</a></li>
|
||||
{{ range after 1 (where .Site.Pages "Section" "") -}}
|
||||
<li><a class="{{ if eq $currentID .UniqueID }}active{{ end }}" href="{{ .RelPermalink }}">{{ .Title }}</a></li>
|
||||
|
|
|
|||
124
sass/_zen.scss
124
sass/_zen.scss
|
|
@ -183,26 +183,7 @@ body {
|
|||
}
|
||||
|
||||
.header {
|
||||
padding-top: $zen-gutters / 2;
|
||||
|
||||
@include respond-to(m) {
|
||||
padding-top: $zen-gutters;
|
||||
}
|
||||
|
||||
&__logo {
|
||||
@include respond-to(s) {
|
||||
}
|
||||
}
|
||||
|
||||
&__site-name {
|
||||
@include respond-to(s) {
|
||||
}
|
||||
}
|
||||
|
||||
&__region {
|
||||
@include respond-to(s) {
|
||||
}
|
||||
}
|
||||
padding-top: $zen-gutters;
|
||||
}
|
||||
|
||||
/* Navigation */
|
||||
|
|
@ -330,3 +311,106 @@ body {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.js-nav-wrapper {
|
||||
position: fixed;
|
||||
right: 0;
|
||||
top: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
z-index: 10;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.js-nav-cover {
|
||||
position: absolute;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background-color: rgba(color(text), .2);
|
||||
opacity: 0;
|
||||
|
||||
.js-nav-open & {
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.js-nav-toggle {
|
||||
@include typeface(headings);
|
||||
display: block;
|
||||
position: absolute;
|
||||
top: $zen-gutters / 2;
|
||||
right: $zen-gutters + $zen-gutters / 2 + $zen-gutters / 4;
|
||||
z-index: 12;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
line-height: 1;
|
||||
pointer-events: auto;
|
||||
|
||||
.js-nav-open & {
|
||||
color: color(text-bg);
|
||||
}
|
||||
|
||||
&::after {
|
||||
position: absolute;
|
||||
content: '';
|
||||
margin-left: $zen-gutters / 4;
|
||||
width: $zen-gutters;
|
||||
height: 4px;
|
||||
border-top: 12px double color(text);
|
||||
border-bottom: 4px solid color(text);
|
||||
}
|
||||
|
||||
.js-nav-open &::after {
|
||||
border-color: color(text-bg);
|
||||
}
|
||||
}
|
||||
|
||||
.js-nav-sheet {
|
||||
position: relative;
|
||||
background-color: color(header-bg);
|
||||
width: 90vw;
|
||||
height: 100vh;
|
||||
padding: 2rem;
|
||||
transform: translateX(100vw);
|
||||
z-index: 11;
|
||||
|
||||
.js-nav-open & {
|
||||
pointer-events: auto;
|
||||
box-shadow: -10px 0 10px -10px color('nearblack');
|
||||
transform: translateX(10vw);
|
||||
}
|
||||
|
||||
.js-navbar {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
|
||||
li {
|
||||
list-style-type: none;
|
||||
margin: .4rem 0;
|
||||
|
||||
a {
|
||||
color: color(white);
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.js-nav-cover,
|
||||
.js-nav-toggle,
|
||||
.js-nav-toggle::after,
|
||||
.js-nav-sheet {
|
||||
transition: all 130ms ease-in;
|
||||
|
||||
.js-nav-open & {
|
||||
transition: all 330ms ease-out;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -11,10 +11,22 @@
|
|||
$('html').addClass('js');
|
||||
|
||||
// Activate the SlickNav menu for small screens.
|
||||
if (window.matchMedia && $.isFunction($.fn.slicknav)) {
|
||||
if (window.matchMedia) {
|
||||
var mq = window.matchMedia('(max-width: 666px)');
|
||||
if (mq.matches) {
|
||||
$('.main-menu').addClass('hidden').find('.navbar').filter(':first').slicknav();
|
||||
// Create the nav toggle button and the nav sheet.
|
||||
$('.page').after('<div class="js-nav-wrapper"><div class="js-nav-cover"></div><a href="#navigation" class="js-nav-toggle" aria-haspopup="true" role="button">Menu</a><nav class="js-nav-sheet"></nav></div>');
|
||||
|
||||
// Populate the nav sheet.
|
||||
$('.main-menu').addClass('hidden').clone().removeClass('main-menu layout__navigation layout__full hidden hidden').addClass('js-main-menu').appendTo('.js-nav-sheet').find('.navbar').removeClass('navbar').addClass('js-navbar');
|
||||
$('.header__region').addClass('hidden').clone().removeClass('header__region region hidden').addClass('js-region').appendTo('.js-nav-sheet');
|
||||
|
||||
// Toggle the nav sheet.
|
||||
$('.js-nav-cover, .js-nav-toggle').on('click toushstart', function (e) {
|
||||
e.preventDefault();
|
||||
$('.js-nav-wrapper').toggleClass('js-nav-open');
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue