Add a speaker view with a next-slide preview and keep the live slide in view
CI / Deploy / PHP 8.4 (push) Successful in 1m11s
CI / Deploy / PHP 8.5 (push) Successful in 1m13s
CI / Deploy / test (push) Successful in 2s
CI / Deploy / deploy (push) Skipped

- New /admin/{token}/speaker page for a second window: current slide, preview of
  the next slide and the usual controls. It does not start the presentation.
- The presenter state gets `next` (labels only, no solutions).
- The dashboard scrolls the live slide into view when the presenter moves on.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Sonnet 5.5 committed 2026-11-16 15:43:49 +01:00
1 parent 8262411225
commit 66ed198f87
11 files changed
+264 -5

No files matched your search

+19
View File
@@ -678,6 +678,25 @@ body.present {
--star: #d48500;
--star-empty: #c3c8da;
}
/* Speaker view (second window): current slide left, preview of the next one right. */
.stage--speaker { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); grid-template-rows: auto 1fr auto; column-gap: 3vw; }
.stage--speaker > .stage__top, .stage--speaker > .stage__controls { grid-column: 1 / -1; }
.stage--speaker .stage__question { font-size: clamp(1.5rem, 3vw, 2.6rem); }
.stage--speaker .stage__description { font-size: clamp(1rem, 1.5vw, 1.3rem); }
.stage--speaker .stage__results { font-size: clamp(.9rem, 1.3vw, 1.2rem); }
.stage__next { align-self: center; max-height: 100%; overflow: auto; padding: 2vh 2vw; border: 1px dashed rgba(var(--tint), .3); border-radius: 12px; background: rgba(var(--tint), .05); }
.stage__next-label { text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 700; font-size: .85rem; margin: 0 0 .6em; }
.stage__next-question { font-size: clamp(1.2rem, 2.2vw, 2rem); margin: 0 0 .4em; }
.stage__next-description { color: var(--muted); font-size: clamp(.95rem, 1.3vw, 1.15rem); margin: 0 0 .8em; }
.stage__next-description:empty, .stage__next-options:empty, .stage__next-note:empty { display: none; }
.stage__next-options { margin: 0 0 .8em; padding-left: 1.2em; font-size: clamp(.95rem, 1.3vw, 1.15rem); }
.stage__next-note { margin: 0; font-size: .9rem; }
.stage__next--end .stage__next-question { color: var(--muted); font-weight: 400; }
@media (max-width: 800px) {
body.present:has(.stage--speaker) { overflow: auto; }
.stage--speaker { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto auto; height: auto; min-height: 100vh; }
.stage__next { align-self: stretch; margin-bottom: 2vh; }
}
.stage__top { display: flex; justify-content: space-between; align-items: center; gap: 16px; font-size: clamp(1rem, 1.6vw, 1.4rem); color: var(--muted); }
.stage__top strong { color: var(--text); }
.stage__code { letter-spacing: .12em; background: rgba(var(--tint), .1); padding: 2px 10px; border-radius: 8px; }
+41 -1
View File
@@ -1320,6 +1320,24 @@
}
}
/** Speaker view: preview of the slide that "next" will show (labels only, the server sends no solutions). */
function renderNext(next) {
var box = q('[data-next]');
if (!box) {
return;
}
var options = q('[data-next-options]');
options.textContent = '';
setText('[data-next-meta]', next ? '· ' + next.typeLabel : '');
setText('[data-next-question]', next ? next.question : 'Das war die letzte Folie');
Format.render(q('[data-next-description]'), next ? next.description : '');
(next ? next.options : []).forEach(function (label) {
options.appendChild(el('li', { text: label }));
});
setText('[data-next-note]', next && next.hasImage ? 'Die Folie enthält ein Bild.' : '');
box.classList.toggle('stage__next--end', !next);
}
function render(newState) {
var serialized = JSON.stringify(newState);
if (serialized === last) {
@@ -1328,6 +1346,7 @@
last = serialized;
state = newState;
var slide = state.slide;
renderNext(state.next);
setText('[data-counter]', state.count === 0
? '0 / 0'
@@ -2704,6 +2723,20 @@
}
}
function currentSlideId() {
var current = document.querySelector('.slide-item--current');
return current ? current.getAttribute('data-slide-id') : null;
}
/** Scrolls the live slide into view if it is outside (no movement if it is already visible). */
function revealCurrent() {
var current = document.querySelector('.slide-item--current');
if (current) {
var calm = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
current.scrollIntoView({ block: 'nearest', behavior: calm ? 'auto' : 'smooth' });
}
}
function refreshList() {
return Fragments.request(window.location.href).then(function (doc) {
Fragments.apply(doc, ['head', 'slides']);
@@ -2735,7 +2768,14 @@
nextId: next ? next.getAttribute('data-slide-id') : null
} : null;
return refreshList().then(function () { restoreFocus(target); });
var liveBefore = currentSlideId();
return refreshList().then(function () {
restoreFocus(target);
// The presenter moved on: keep the live slide in view on long lists.
if (currentSlideId() !== liveBefore) {
revealCurrent();
}
});
});
}, Math.max(4000, parseInt(liveRoot.getAttribute('data-interval'), 10) * 2 || 4000));
}