Skip to content

Commit 5fa4b5b

Browse files
💄🔧:keep what the old sidebar got right
Read against bento-sidebar's own source rather than trusting that a drawer is a drawer. Four things it did that this had dropped: The panel hangs off the trailing edge, so in a page that reads right to left it has to leave to the left. It was leaving to the right whatever the direction, which parked the closed panel in the middle of the viewport. No page sets `lang: ar` yet, but the layout emits `dir='rtl'` for one that does. `overflow-y: auto` alone makes the other axis scrollable too, so a long entry would have given the drawer a horizontal scrollbar. The old one pinned `overflow-x: hidden` on purpose. A drag on the backdrop scrolled the page behind it. The old one made the backdrop swallow the gesture; `touch-action` says the same thing without the two hacks it needed to do it. Escape closed the drawer and carried on to whatever else was listening. The slide is the old one's again as well, a sharp decelerate over 350ms, so the motion is the one the site had rather than a new one. Left behind deliberately: `role="menu"` on a list of links, which wants `menuitem` children to mean anything and reads worse than the labelled `nav` around it. The toolbar attribute, the `open` attribute as an API, and pausing media on close were never used here. History integration — the back button closing the drawer — belonged to `amp-sidebar`, not to the component this site loaded, so it was never ours to lose. Signed-off-by: Derek Lewis <DerekNonGeneric@inf.is> Assisted-by: Claude-Code:claude-opus-5
1 parent 9228eff commit 5fa4b5b

3 files changed

Lines changed: 30 additions & 8 deletions

File tree

‎_assets/styles/_nav.scss‎

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// The slide bento-sidebar used, kept so the motion is the one the site
2+
// had: a sharp decelerate rather than a symmetric ease.
3+
$sidebar-slide-time: 350ms;
4+
$sidebar-slide: $sidebar-slide-time cubic-bezier(0, 0, 0.21, 1);
5+
16
// `manipulation` is the whole reason the menu button was unreliable on a
27
// phone. Left at `auto`, Safari holds a tap for a third of a second to see
38
// whether a second one is coming and a double-tap should zoom instead --
@@ -47,19 +52,26 @@
4752
visibility: hidden;
4853
width: min(15rem, 70vw);
4954
padding-top: $navbar-height;
50-
overflow-y: auto;
55+
overflow: hidden auto;
5156
overscroll-behavior: contain;
5257
background-color: $secondary;
5358
transform: translateX(100%);
5459
transition:
55-
transform 0.3s ease,
56-
visibility 0s linear 0.3s;
60+
transform $sidebar-slide,
61+
visibility 0s linear $sidebar-slide-time;
62+
}
63+
64+
// The panel hangs off the trailing edge, which is the left one in a page
65+
// that reads right to left, so it has to leave in that direction too.
66+
// Without this the closed panel sits in the middle of the viewport.
67+
[dir='rtl'] .sidebar {
68+
transform: translateX(-100%);
5769
}
5870

5971
.sidebar.is-open {
6072
visibility: visible;
6173
transform: none;
62-
transition: transform 0.3s ease;
74+
transition: transform $sidebar-slide;
6375
}
6476

6577
.sidebar .nav-link {
@@ -77,17 +89,22 @@
7789
inset: 0;
7890
z-index: $zindex-fixed - 10;
7991
visibility: hidden;
92+
93+
// A drag here scrolls nothing. Without it the page behind creeps along
94+
// under the finger, which `overflow: hidden` on the body does not reliably
95+
// stop on iOS.
96+
touch-action: none;
8097
background-color: rgb(0 0 0 / 50%);
8198
opacity: 0;
8299
transition:
83-
opacity 0.3s ease,
84-
visibility 0s linear 0.3s;
100+
opacity $sidebar-slide,
101+
visibility 0s linear $sidebar-slide-time;
85102
}
86103

87104
.sidebar-backdrop.is-open {
88105
visibility: visible;
89106
opacity: 1;
90-
transition: opacity 0.3s ease;
107+
transition: opacity $sidebar-slide;
91108
}
92109

93110
// The drawer scrolls itself, so the page behind it should not.

‎_includes/footer.liquid‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353
5454
backdrop.addEventListener('click', close);
5555
document.addEventListener('keydown', (event) => {
56-
if (event.key === 'Escape') close();
56+
if (!open || event.key !== 'Escape') return;
57+
// The press closed the drawer, so nothing else should also act on it.
58+
event.preventDefault();
59+
event.stopImmediatePropagation();
60+
close();
5761
});
5862
</script>

‎project-terms.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Aftertabs
22
Anson
33
autolinks
44
backref
5+
bento
56
bibtex
67
biomejs
78
blockified

0 commit comments

Comments
 (0)