Skip to content

Commit 3ea2749

Browse files
committed
Fixes
1 parent 4be11f2 commit 3ea2749

3 files changed

Lines changed: 108 additions & 70 deletions

File tree

_config.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,15 @@ site.preprocess([".html"], (pages) => {
189189

190190
for (const page of pages) {
191191
delete page.data.walkthroughProgress;
192+
if (page.data.walkthrough !== undefined && !getWalkthroughData(page)) {
193+
console.error(
194+
"The page",
195+
page.src.path,
196+
"has invalid walkthrough metadata.",
197+
);
198+
error = true;
199+
++errorCount;
200+
}
192201
}
193202

194203
const trackLabels: Record<WalkthroughTrack, string> = {
@@ -532,11 +541,11 @@ site.helper("walkthrough", (track: string) => {
532541

533542
return `<div class="walkthrough-group" data-walkthrough-collapsed>
534543
<ol class="walkthrough-list" aria-label="${label}">\n${visibleItems.join("\n")}\n </ol>
535-
<button class="walkthrough-more" type="button" aria-expanded="false">
544+
<button class="walkthrough-more" type="button" aria-expanded="false" aria-controls="walkthrough-${track}-remainder">
536545
<span class="walkthrough-more-collapsed">Show More</span>
537546
<span class="walkthrough-more-expanded">Show Less</span>
538547
</button>
539-
<div class="walkthrough-remainder">
548+
<div class="walkthrough-remainder" id="walkthrough-${track}-remainder">
540549
<div class="walkthrough-remainder-inner">
541550
<ol class="walkthrough-list walkthrough-list-continuation" start="11" aria-label="${label}, continued">\n${remainingItems.join("\n")}\n </ol>
542551
</div>

src/_includes/style/walkthrough.scss

Lines changed: 61 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,8 @@ ol.walkthrough-list {
7070

7171
.walkthrough-remainder {
7272
display: grid;
73-
grid-template-rows: 0fr;
74-
opacity: 0;
75-
transform: translateY(-0.5rem);
73+
grid-template-rows: 1fr;
74+
opacity: 1;
7675
transition:
7776
grid-template-rows 560ms cubic-bezier(0.16, 1, 0.3, 1),
7877
opacity 240ms ease,
@@ -86,17 +85,61 @@ ol.walkthrough-list {
8685

8786
> .walkthrough-list {
8887
margin-top: 0;
89-
margin-bottom: 0;
88+
margin-bottom: 1rem;
9089
}
9190
}
9291
}
9392

9493
.walkthrough-list-continuation > li {
95-
opacity: 0;
96-
transform: translateY(-0.3rem);
94+
opacity: 1;
9795
transition: opacity 220ms ease, transform 400ms cubic-bezier(0.16, 1, 0.3, 1);
9896
}
9997

98+
.walkthrough-group.is-enhanced {
99+
> .walkthrough-more {
100+
display: inline-flex;
101+
align-items: center;
102+
min-height: 2rem;
103+
margin: 0.2rem 0 0.2rem 1.15rem;
104+
padding: 0.2rem 0.45rem;
105+
border: 0;
106+
border-radius: 0;
107+
background: var(--dbt);
108+
color: var(--kr);
109+
cursor: pointer;
110+
font: inherit;
111+
font-size: 0.75rem;
112+
touch-action: manipulation;
113+
}
114+
115+
&:not(.is-expanded) {
116+
> .walkthrough-remainder {
117+
grid-template-rows: 0fr;
118+
opacity: 0;
119+
transform: translateY(-0.5rem);
120+
121+
> .walkthrough-remainder-inner > .walkthrough-list {
122+
margin-bottom: 0;
123+
}
124+
}
125+
126+
.walkthrough-list-continuation > li {
127+
opacity: 0;
128+
transform: translateY(-0.3rem);
129+
}
130+
}
131+
132+
&.is-expanded > .walkthrough-more {
133+
> .walkthrough-more-collapsed {
134+
display: none;
135+
}
136+
137+
> .walkthrough-more-expanded {
138+
display: inline;
139+
}
140+
}
141+
}
142+
100143
.index-subsections > ul {
101144
display: grid;
102145
gap: 0.15rem;
@@ -211,72 +254,25 @@ ol.walkthrough-list {
211254
}
212255

213256
@media (hover: hover) and (pointer: fine) {
214-
.walkthrough-group:hover,
215-
.walkthrough-group:focus-within {
216-
> .walkthrough-remainder {
217-
grid-template-rows: 1fr;
218-
opacity: 1;
219-
transform: none;
220-
221-
> .walkthrough-remainder-inner > .walkthrough-list {
222-
margin-bottom: 1rem;
223-
}
224-
}
225-
226-
.walkthrough-list-continuation > li {
227-
opacity: 1;
228-
transform: none;
229-
}
257+
.walkthrough-group.is-enhanced > .walkthrough-more:not(:focus-visible) {
258+
position: absolute;
259+
width: 1px;
260+
height: 1px;
261+
min-height: 0;
262+
margin: -1px;
263+
padding: 0;
264+
overflow: hidden;
265+
clip: rect(0, 0, 0, 0);
266+
clip-path: inset(50%);
267+
border: 0;
268+
white-space: nowrap;
230269
}
231270

232271
.index-subsection-toggle {
233272
display: none;
234273
}
235274
}
236275

237-
@media (hover: none), (pointer: coarse) {
238-
.walkthrough-more {
239-
display: inline-flex;
240-
align-items: center;
241-
min-height: 2rem;
242-
margin: 0.2rem 0 0.2rem 1.15rem;
243-
padding: 0.2rem 0.45rem;
244-
border: 0;
245-
border-radius: 0;
246-
background: var(--dbt);
247-
color: var(--kr);
248-
cursor: pointer;
249-
font: inherit;
250-
font-size: 0.75rem;
251-
touch-action: manipulation;
252-
}
253-
254-
.walkthrough-group.is-expanded > .walkthrough-more {
255-
> .walkthrough-more-collapsed {
256-
display: none;
257-
}
258-
259-
> .walkthrough-more-expanded {
260-
display: inline;
261-
}
262-
}
263-
264-
.walkthrough-group.is-expanded > .walkthrough-remainder {
265-
grid-template-rows: 1fr;
266-
opacity: 1;
267-
transform: none;
268-
269-
> .walkthrough-remainder-inner > .walkthrough-list {
270-
margin-bottom: 1rem;
271-
}
272-
}
273-
274-
.walkthrough-group.is-expanded .walkthrough-list-continuation > li {
275-
opacity: 1;
276-
transform: none;
277-
}
278-
}
279-
280276
@media (prefers-reduced-motion: reduce) {
281277
.walkthrough-remainder,
282278
.walkthrough-list-continuation > li {

src/static/script.js

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,14 +332,47 @@ function initIndexSubsections() {
332332
}
333333

334334
function initWalkthroughGroups() {
335+
const desktopQuery = matchMedia("(hover: hover) and (pointer: fine)");
336+
335337
for (const group of document.querySelectorAll("[data-walkthrough-collapsed]")) {
336338
const button = group.querySelector(":scope > .walkthrough-more");
337-
if (!(button instanceof HTMLButtonElement)) continue;
339+
const remainder = group.querySelector(":scope > .walkthrough-remainder");
340+
if (!(button instanceof HTMLButtonElement) || !(remainder instanceof HTMLElement)) continue;
338341

339-
button.addEventListener("click", () => {
340-
const expanded = group.classList.toggle("is-expanded");
342+
let hovered = false;
343+
let manuallyExpanded = false;
344+
345+
const setExpanded = (expanded) => {
346+
group.classList.toggle("is-expanded", expanded);
341347
button.setAttribute("aria-expanded", String(expanded));
348+
remainder.setAttribute("aria-hidden", String(!expanded));
349+
remainder.toggleAttribute("inert", !expanded);
350+
};
351+
352+
const syncExpanded = () => {
353+
const activeElement = document.activeElement;
354+
const contentHasFocus = activeElement !== button && group.contains(activeElement);
355+
setExpanded(manuallyExpanded || (desktopQuery.matches && (hovered || contentHasFocus)));
356+
};
357+
358+
button.addEventListener("click", () => {
359+
manuallyExpanded = !group.classList.contains("is-expanded");
360+
syncExpanded();
361+
});
362+
group.addEventListener("mouseenter", () => {
363+
hovered = true;
364+
syncExpanded();
342365
});
366+
group.addEventListener("mouseleave", () => {
367+
hovered = false;
368+
syncExpanded();
369+
});
370+
group.addEventListener("focusin", syncExpanded);
371+
group.addEventListener("focusout", () => queueMicrotask(syncExpanded));
372+
desktopQuery.addEventListener("change", syncExpanded);
373+
374+
group.classList.add("is-enhanced");
375+
syncExpanded();
343376
}
344377
}
345378

0 commit comments

Comments
 (0)