List upcoming schedule days on wider screens
Some checks failed
/ build (pull_request) Has been cancelled
/ accessibility (pull_request) Has been cancelled

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Vincent Mahnke 2026-11-14 04:47:18 +01:00
commit ce03851d57
Signed by: ViMaSter
GPG key ID: 6D787326BA7D6469
2 changed files with 114 additions and 18 deletions

View file

@ -1,4 +1,4 @@
/* Tour schedule shortcode: a day picker, with a grid fallback on wide screens without JavaScript. */
/* Tour schedule shortcode: a mobile day picker and a wide-screen list, with a no-JavaScript grid fallback. */
.schedule {
--schedule-line: color-mix(in oklch, var(--color-text) 20%, transparent);
@ -250,7 +250,7 @@
}
}
/* The picker is only shown with JavaScript. */
/* The picker is only shown on mobile with JavaScript. */
.schedule__picker {
display: none;
}
@ -304,30 +304,37 @@
color: var(--color-text-meta);
}
.schedule--picker {
.schedule__day:not(.schedule__day--selected) {
display: none;
}
@media (width <= 666px) {
.schedule--picker {
.schedule__day:not(.schedule__day--selected) {
display: none;
}
/* The picker already names the day. */
.schedule__day-title {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
/* The picker already names the day. */
.schedule__day-title {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
}
}
}
@container (width >= 48rem) {
.schedule--picker {
.schedule__days {
display: block;
display: grid;
grid-template-columns: none;
grid-template-rows: none;
gap: var(--spacing-l);
}
.schedule__day {
display: block;
grid-column: auto;
grid-row: auto;
}
.schedule__list {
@ -351,3 +358,10 @@
}
}
}
@media (width >= 667px) {
.schedule__picker:not([hidden]),
.schedule--picker .schedule__day--past {
display: none;
}
}

View file

@ -1,4 +1,4 @@
// Day picker for the schedule shortcode. Without JavaScript all days remain visible.
// Responsive schedule for the shortcode. Without JavaScript all days remain visible.
for (const schedule of document.querySelectorAll('[data-schedule]')) {
const picker = schedule.querySelector('.schedule__picker');
const buttons = [...picker.querySelectorAll('button')];
@ -21,6 +21,13 @@ for (const schedule of document.querySelectorAll('[data-schedule]')) {
const today = new Date().toLocaleDateString('sv');
select(buttons.find((button) => button.dataset.date === today) ?? buttons[0]);
const hasUpcomingDays = buttons.some((button) => button.dataset.date >= today);
for (const button of buttons) {
document
.getElementById(button.getAttribute('aria-controls'))
.classList.toggle('schedule__day--past', hasUpcomingDays && button.dataset.date < today);
}
picker.hidden = false;
schedule.classList.add('schedule--picker');
}