Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 101 additions & 12 deletions _assets/styles/_nav.scss
Original file line number Diff line number Diff line change
@@ -1,24 +1,113 @@
// A sharp decelerate: the panel arrives, then settles.
$sidebar-slide-time: 350ms;
$sidebar-slide: $sidebar-slide-time cubic-bezier(0, 0, 0.21, 1);

// Without `manipulation`, Safari holds a tap for a third of a second in
// case a double-tap to zoom follows, and a second tap inside that wait
// cancels both. iOS ignores the viewport's scale limits, so nothing else
// turns it off.
.navbar-toggler {
position: relative;
touch-action: manipulation;
}

// 48px is the smallest tap target recommended. The reach grows past the
// button, so nothing drawn changes.
.navbar-toggler::after {
position: absolute;
inset: 50% auto auto 50%;
width: 48px;
height: 48px;
content: '';
transform: translate(-50%, -50%);
}

.navbar-toggler svg {
height: 24px;
}

.navbar-toggler-wrapper {
display: flex;
flex-direction: row-reverse;
height: $navbar-height;
// Focus lands on both of these without a press. Only a keyboard needs the
// ring.
.navbar-toggler:focus:not(:focus-visible) {
box-shadow: none;
}

bento-sidebar {
.sidebar:focus:not(:focus-visible) {
outline: none;
}

// Under the navbar, so the button keeps its place and the panel never
// crosses it.
.sidebar {
position: fixed;
inset-block: 0;
inset-inline-end: 0;
z-index: $zindex-fixed - 5;
visibility: hidden;
width: min(15rem, 70vw);
padding-top: $navbar-height;
overflow: hidden auto;
overscroll-behavior: contain;
background-color: $secondary;
transform: translateX(100%);
transition:
transform $sidebar-slide,
visibility 0s linear $sidebar-slide-time;
}

.nav-link {
padding-left: 2rem;
line-height: 32px;
border-left: 2px solid transparent;
}
// The trailing edge is the left one in a page that reads right to left, so
// the panel leaves that way.
[dir='rtl'] .sidebar {
transform: translateX(-100%);
}

.sidebar.is-open {
visibility: visible;
transform: none;
transition: transform $sidebar-slide;
}

.sidebar .nav-link {
padding-left: 2rem;
line-height: 32px;
border-left: 2px solid transparent;
}

.sidebar .nav-link.active {
border-left-color: $primary;
}

.sidebar-backdrop {
position: fixed;
inset: 0;
z-index: $zindex-fixed - 10;
visibility: hidden;

// A drag here scrolls nothing: `overflow: hidden` on the body does not
// hold on iOS.
touch-action: none;
background-color: rgb(0 0 0 / 50%);
opacity: 0;
transition:
opacity $sidebar-slide,
visibility 0s linear $sidebar-slide-time;
}

.sidebar-backdrop.is-open {
visibility: visible;
opacity: 1;
transition: opacity $sidebar-slide;
}

// The drawer scrolls itself, so the page behind it should not.
body.sidebar-open {
overflow: hidden;
}

.nav-link.active {
border-left-color: $primary;
@media (prefers-reduced-motion: reduce) {
.sidebar,
.sidebar-backdrop {
transition: none;
}
}

Expand Down
3 changes: 0 additions & 3 deletions _includes/assets/img/sublime-theme/hamburger-primary.svg

This file was deleted.

62 changes: 50 additions & 12 deletions _includes/footer.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,54 @@
</footer>

<script>
(async () => {
const sidebar = document.querySelector('#sidebar');
await customElements.whenDefined('bento-sidebar');
const api = await sidebar.getApi();

// set up button actions
const matches = document.querySelectorAll('.navbar-toggler');

matches.forEach((match) => {
match.onclick = () => api.toggle(0);
});
})();
// The drawer is markup and CSS, so the button works the moment this runs.
const toggle = document.querySelector('#sidebar-toggle');
const sidebar = document.querySelector('#sidebar');
const backdrop = document.querySelector('.sidebar-backdrop');

// A menu that cannot open is worse than none, so the markup ships hidden.
// From here the stylesheet holds the closed state.
sidebar.hidden = false;
backdrop.hidden = false;

let open = false;

const setOpen = (next) => {
open = next;
sidebar.classList.toggle('is-open', open);
backdrop.classList.toggle('is-open', open);
document.body.classList.toggle('sidebar-open', open);
toggle.setAttribute('aria-expanded', String(open));
// Off screen either way: keep it out of the tab order and off a screen
// reader's path.
sidebar.inert = !open;
};

// Follows the drawer, so the next tab goes where the eye already is. Only
// on a press: the setup below has to leave focus where the reader left it.
const moveFocus = () => {
(open ? sidebar : toggle).focus();
};

setOpen(false);

toggle.addEventListener('click', () => {
setOpen(!open);
moveFocus();
});

const close = () => {
if (!open) return;
setOpen(false);
moveFocus();
};

backdrop.addEventListener('click', close);
document.addEventListener('keydown', (event) => {
if (!open || event.key !== 'Escape') return;
// The press is spent on the drawer; nothing else acts on it.
event.preventDefault();
event.stopImmediatePropagation();
close();
});
</script>
34 changes: 5 additions & 29 deletions _includes/head.liquid
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<head>
<meta charset='utf-8'>
<meta
name='viewport'
content='width=device-width,maximum-scale=1,minimum-scale=1,initial-scale=1'
>
{%- comment -%}
No scale limits: iOS ignores them, and elsewhere they take pinch-zoom
from anyone who needs it.
{%- endcomment -%}
<meta name='viewport' content='width=device-width,initial-scale=1'>
<link
type='image/svg+xml'
rel='shortcut icon preload'
Expand Down Expand Up @@ -38,31 +39,6 @@
src='/assets/js/vendor/count.js'
></script>
{%- endif -%}
<script
type='module'
src='https://cdn.ampproject.org/bento.mjs'
crossorigin='anonymous'
></script>
<script
nomodule
src='https://cdn.ampproject.org/bento.js'
crossorigin='anonymous'
></script>
<script
type='module'
src='https://cdn.ampproject.org/v0/bento-sidebar-1.0.mjs'
crossorigin='anonymous'
></script>
<script
nomodule
src='https://cdn.ampproject.org/v0/bento-sidebar-1.0.js'
crossorigin='anonymous'
></script>
<link
rel='stylesheet'
href='https://cdn.ampproject.org/v0/bento-sidebar-1.0.css'
crossorigin='anonymous'
>
<link
rel='stylesheet'
href='/assets/styles/main{% if env == "production" %}.min{% endif %}.css'
Expand Down
24 changes: 9 additions & 15 deletions _includes/header.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
{% include 'assets/img/logogram-color.svg' %}
</a>
<button
id='sidebar-toggle'
class='navbar-toggler'
type='button'
aria-label='Toggle navigation'
aria-controls='sidebar'
aria-expanded='false'
>
{% include 'assets/img/sublime-theme/hamburger-secondary.svg' %}
</button>
Expand All @@ -36,21 +39,12 @@
</div>
</nav>
</header>
<bento-sidebar
id='sidebar'
side='right'
layout='nodisplay'
>
{%- comment -%}
The header's button is the only control, so nothing moves under a finger.
{%- endcomment -%}
<div class='sidebar-backdrop' hidden></div>
<div id='sidebar' class='sidebar' tabindex='-1' hidden>
<nav class='navbar py-0' aria-label='Sidebar'>
<div class='navbar-toggler-wrapper container-fluid'>
<button
class='navbar-toggler'
type='button'
aria-label='Toggle navigation'
>
{% include 'assets/img/sublime-theme/hamburger-primary.svg' %}
</button>
</div>
<ul class='navbar-nav me-auto mb-2 mb-md-0 w-100'>
{% for link in menu %}
<li class='nav-item'>
Expand All @@ -67,4 +61,4 @@
{% endfor %}
</ul>
</nav>
</bento-sidebar>
</div>
4 changes: 2 additions & 2 deletions project-terms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ Kosic
lede
middot
noarchive
nodisplay
noindex
nomodule
nonoptional
noopener
noreferrer
Expand Down Expand Up @@ -77,9 +75,11 @@ sitewide
skipcq
stylesheet
Sysnative
tabindex
tamasfe
trixie
unconfigured
unentitled
unifiedjs
windir
zindex
Loading