diff --git a/AGENTS.md b/AGENTS.md index 200f97f..5efd33d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -225,7 +225,7 @@ tests/ PHPUnit; PlenarioTestTrait erzeugt Testdaten, Fixtures `Comments.delay()` = 2,5 s + 15 Zeichen/s, 5–30 s, geteilt durch das Tempo der Umfrage `polls.comment_speed` (Prozent aus `Poll::COMMENT_SPEEDS`, im State `poll.commentSpeed` als Faktor, Dashboard → „Einstellungen“); Vor/Zurück/Fortsetzen geben dem Kommentar wieder die volle Zeit; „Kommentar X von N“, vor/zurück/Pause, Laufbalken bis zum Wechsel (`Comments.progress()`, setzt nach dem Neu-Rendern per negativem - `animation-delay` fort, bei Pause unsichtbar), Zustand übersteht das Neu-Rendern beim Polling). Bei internem Feedback erscheinen sie erst, + `animation-delay` fort, bei Pause unsichtbar), Zustand übersteht das Neu-Rendern beim Polling; die Box ist so hoch wie der längste Kommentar – alle liegen unsichtbar in derselben Grid-Zelle –, damit die zentrierte Bühne beim Wechsel nicht springt; höchstens `--comment-max` ≈ 5 Zeilen, längere Kommentare setzt `Comments.fit()` kleiner statt sie abzuschneiden). Bei internem Feedback erscheinen sie erst, wenn der Presenter die Ergebnisse einblendet. - **Sterne-Bewertung** (Skala mit Setting `style = stars`, `Slide::isStarRating()`, Standard `numbers`): immer 1 bis `scale_max` Sterne (`SlidesTable::sanitizeSettings()` erzwingt `scale_min = 1`), gespeichert wie jede Skala als `numeric_value`. diff --git a/webroot/css/plenario.css b/webroot/css/plenario.css index 4ba9c88..59c981a 100644 --- a/webroot/css/plenario.css +++ b/webroot/css/plenario.css @@ -582,10 +582,17 @@ button.qa-steps__step:hover:not(:disabled) { color: var(--text); border-color: v .own-comment__edit summary:hover { color: var(--text); } .comments { margin-top: 20px; padding: 16px 20px; background: var(--surface-2); border-radius: 14px; } .comments__counter { margin: 0 0 6px; font-size: .85em; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-variant-numeric: tabular-nums; } -.comments__text { margin: 0; font-size: 1.25em; font-weight: 600; white-space: pre-line; overflow-wrap: anywhere; } +.comments__text { margin: 0; font-size: var(--comment-size); font-weight: 600; white-space: pre-line; overflow-wrap: anywhere; } .comments__text::before { content: '„'; } .comments__text::after { content: '“'; } .comments__value { margin: 6px 0 0; color: var(--muted); font-size: .9em; } +/* all comments share one grid cell (invisible sizers): the box keeps the height of the longest one */ +.comments__body { display: grid; } +.comments__body > * { grid-area: 1 / 1; min-width: 0; } +.comments__sizer { visibility: hidden; } +/* at most about 5 lines; longer comments are set smaller by Comments.fit() instead of being cut off */ +.comments { --comment-size: 1.25em; --comment-max: 11em; } +.comments__sizer, .comments__current { max-height: var(--comment-max); overflow: hidden; } .comments__progress { height: 4px; margin-top: 14px; border-radius: 2px; background: var(--border); overflow: hidden; } .comments__progress[hidden] { display: block; visibility: hidden; } /* keeps the layout steady while paused */ .comments__progress-fill { height: 100%; background: var(--primary); transform: scaleX(0); transform-origin: left; } diff --git a/webroot/js/plenario.js b/webroot/js/plenario.js index fb9ea84..a93c93b 100644 --- a/webroot/js/plenario.js +++ b/webroot/js/plenario.js @@ -342,10 +342,23 @@ text: text }); }; + // Every comment sits invisibly in the same grid cell as the one shown, so the box is as + // tall as the longest comment and the centred stage does not jump while they rotate. + var sizers = items.length < 2 ? [] : items.map(function (item) { + var hasValue = item.value !== null && item.value !== undefined; + return el('div', { class: 'comments__sizer', 'aria-hidden': 'true' }, [ + el('blockquote', { class: 'comments__text', text: item.text }), + hasValue ? el('p', { class: 'comments__value', text: 'Bewertung: ' + Comments.format(item.value) }) : null + ]); + }); var node = el('section', { class: 'comments', 'data-comments': '', 'aria-label': 'Kommentare' }, [ el('p', { class: 'comments__counter', 'data-comment-counter': '' }), - el('blockquote', { class: 'comments__text', 'data-comment-text': '' }), - el('p', { class: 'comments__value', 'data-comment-value': '' }), + el('div', { class: 'comments__body' }, sizers.concat([ + el('div', { class: 'comments__current' }, [ + el('blockquote', { class: 'comments__text', 'data-comment-text': '' }), + el('p', { class: 'comments__value', 'data-comment-value': '' }) + ]) + ])), // Time left until the next comment; decorative, the counter carries the information. items.length < 2 ? null : el('div', { class: 'comments__progress', 'data-comment-progress': '', 'aria-hidden': 'true' }, [ el('div', { class: 'comments__progress-fill' }) @@ -379,6 +392,29 @@ return node; }, + /** + * The box has a maximum height (CSS --comment-max); a comment that does not fit is set + * smaller step by step instead of being cut off. The invisible sizers are capped the same + * way, so a single long comment does not make the box huge. + */ + fit: function () { + var node = Comments.node; + if (!node || !document.body.contains(node)) { + return; + } + var current = node.querySelector('.comments__current'); + var text = node.querySelector('[data-comment-text]'); + var size = 1; + text.style.fontSize = ''; + while (current.scrollHeight > current.clientHeight + 1 && size > Comments.MIN_FONT) { + size = Math.max(Comments.MIN_FONT, size - 0.05); + text.style.fontSize = 'calc(' + size + ' * var(--comment-size))'; + } + }, + + // Smallest font size (factor) for a long comment. + MIN_FONT: 0.5, + step: function (delta) { var n = Comments.items.length; Comments.index = (Comments.index + delta + n) % n; @@ -459,6 +495,8 @@ void text.offsetWidth; // restart the CSS animation text.classList.add('is-entering'); } + // Measure once the box is in the document (render() calls this before it is attached). + requestAnimationFrame(Comments.fit); var toggle = node.querySelector('[data-comment-action="toggle"]'); if (toggle) { var label = Comments.paused ? 'Kommentare automatisch weiterblättern' : 'Automatisches Weiterblättern anhalten'; @@ -470,6 +508,8 @@ Comments.progress(); } }; + // A different width changes the line breaks: fit the comment again. + window.addEventListener('resize', function () { Comments.fit(); }); // ------------------------------------------------------------------ results