From 6c7747082422f45841881e239f9a4216d62cb10c Mon Sep 17 00:00:00 2001 From: Patrick Niebeling Date: Sat, 21 Nov 2026 13:39:56 +0100 Subject: [PATCH] Show the word cloud to participants as a compact list Participants get a list with fixed text size, a weight bar and big +/- buttons (like Q&A voting) instead of the cloud. On stage the cloud shrinks as the number of words grows. Co-Authored-By: Claude Sonnet 5.5 --- docs/slide-types.md | 2 + webroot/css/plenario.css | 28 +++++++---- webroot/js/plenario.js | 102 ++++++++++++++++++++++----------------- 3 files changed, 80 insertions(+), 52 deletions(-) diff --git a/docs/slide-types.md b/docs/slide-types.md index 5e5a7a3..7250abb 100644 --- a/docs/slide-types.md +++ b/docs/slide-types.md @@ -12,6 +12,8 @@ geändert wird es nur über die Presenter-Steuerung (`SlideControlService`) bzw. jeder Begriff einmal pro Person, beliebig viele Begriffe. Einen vorhandenen Begriff erneut nennen bzw. in der Wolke anklicken = Upvote (gleiche Zeile in `responses`). Mit `allow_upvotes` sehen Teilnehmende die Wolke live; Vorschläge inkl. Kölner Phonetik in `plenario.js` (`Words`). + Teilnehmende sehen sie als kompakte Liste (`Results.wordList()`: feste Schriftgröße, Gewichtsbalken, große „+“/„−“-Buttons, wie beim Q&A-Voting), + die Bühne als Wolke, deren Schrift mit der Wortzahl kleiner wird (`--cloud-scale`). Downvotes (`vote=down`, Setting `allow_downvotes`, nur zusammen mit Upvotes): Zeile mit `numeric_value = VoteService::DOWNVOTE` (-1), nur auf fremde, vorhandene Begriffe, ein Rating pro Begriff und Person. Wortgröße richtet sich nur nach den Upvotes (`count`), Downvotes stehen separat in `down`. diff --git a/webroot/css/plenario.css b/webroot/css/plenario.css index b509921..b7d0e24 100644 --- a/webroot/css/plenario.css +++ b/webroot/css/plenario.css @@ -529,7 +529,7 @@ textarea { resize: vertical; } .donut__label { font-weight: 600; overflow-wrap: anywhere; } .donut__value { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; } -.cloud { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .2em .6em; line-height: 1.15; padding: 8px; } +.cloud { font-size: calc(1rem * var(--cloud-scale, 1)); display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .2em .6em; line-height: 1.15; padding: 8px; } .cloud__word { font-weight: 800; color: var(--c0); transition: font-size .6s ease; } .cloud__word--c1 { color: var(--c1); } .cloud__word--c2 { color: var(--c2); } @@ -542,13 +542,23 @@ textarea { resize: vertical; } .cloud__count--down { color: var(--danger); } .stage .cloud__count { font-size: max(.9rem, .4em); } /* Participant cloud: word (+) and − are separate buttons */ -.cloud--interactive .cloud__word { gap: .1em; } -.cloud__vote { font: inherit; font-weight: inherit; color: inherit; line-height: 1.15; background: none; border: 2px solid transparent; border-radius: 10px; padding: .05em .3em; cursor: pointer; display: inline-flex; align-items: baseline; gap: .25em; } -.cloud__vote:hover:not(:disabled), .cloud__vote:focus-visible { border-color: currentColor; } -.cloud__vote:disabled { cursor: default; } -.cloud__vote--down { padding: .05em .25em; } -.cloud__word.is-mine .cloud__vote--up, .cloud__word.is-down .cloud__vote--down { background: var(--surface-2); } -.cloud__word.is-down .cloud__vote--up { opacity: .55; } +/* Participant list (replaces the cloud on phones): fixed text size, weight bar, big tap targets */ +.wc-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; } +.wc-item { position: relative; display: flex; align-items: center; gap: 10px; padding: 8px 8px 10px 14px; border-radius: 10px; background: var(--surface-2); overflow: hidden; } +.wc-item__text { flex: 1; min-width: 0; font-weight: 700; word-break: break-word; } +.wc-item__actions { flex: none; display: inline-flex; gap: 6px; } +.wc-item__bar { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--c0); border-radius: 0 4px 4px 0; transition: width .6s ease; } +.wc-item.is-mine { box-shadow: inset 0 0 0 2px var(--ok); } +.wc-item.is-down { opacity: .7; } +.wc-vote { min-width: 56px; min-height: 40px; padding: 0 10px; border-radius: 999px; border: 2px solid currentColor; background: var(--surface); font: inherit; font-size: .9rem; font-weight: 700; font-variant-numeric: tabular-nums; cursor: pointer; } +.wc-vote--up { color: var(--ok); } +.wc-vote--down { color: var(--danger); } +.wc-vote.is-active { background: currentColor; } +.wc-vote.is-active span { color: var(--surface); } +.wc-vote:disabled { cursor: default; } +.wc-vote:disabled:not(.is-active) { opacity: .5; } +.wc-vote:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; } +.wc-count--down { color: var(--danger); font-weight: 700; } /* quiz results */ .quiz-status { color: var(--muted); font-style: italic; margin: 0 0 1em; } @@ -791,7 +801,7 @@ body.present { .stage .donut__chart { width: clamp(150px, 28vh, 340px); } .stage .donut__count { font-size: clamp(.85rem, 1.3vw, 1.2rem); } .stage .donut__legend { font-size: clamp(.9rem, 1.4vw, 1.3rem); } -.stage .cloud { font-size: clamp(1.4rem, 2.6vw, 2.6rem); } +.stage .cloud { font-size: calc(clamp(1.2rem, 2.2vw, 2.2rem) * var(--cloud-scale, 1)); gap: .15em .5em; } .stage .answers { columns: 340px; } .stage .quiz-timer { font-size: clamp(3rem, 7vw, 6rem); } .stage__timer:empty { display: none; } diff --git a/webroot/js/plenario.js b/webroot/js/plenario.js index 53dfe23..c206cc4 100644 --- a/webroot/js/plenario.js +++ b/webroot/js/plenario.js @@ -878,6 +878,55 @@ return el('div', { class: 'scale-results' }, [row, comments]); }, + /** + * Participant view of a word cloud: a compact list (like Q&A voting) with fixed text size, + * a bar for the relative weight and "+"/"−" buttons. Scales to any number of words. + */ + wordList: function (results, options) { + var mine = (options && options.mine) || []; + var down = (options && options.down) || []; + var onUpvote = options.onUpvote; + var onDownvote = options.onDownvote; + return el('ul', { class: 'wc-list' }, results.words.map(function (word) { + var isMine = mine.indexOf(word.key) >= 0; + var isDown = down.indexOf(word.key) >= 0; + var rated = isMine || isDown; + var downCount = word.down || 0; + var up = el('button', { + type: 'button', + class: 'wc-vote wc-vote--up' + (isMine ? ' is-active' : ''), + 'aria-pressed': isMine ? 'true' : 'false', + 'aria-label': word.text + ', ' + word.count + ' Stimmen' + + (isMine ? ', von dir genannt' : (isDown ? '' : ', unterstützen')) + }, [el('span', { 'aria-hidden': 'true', text: (isMine ? '✓ ' : '+') + word.count })]); + up.disabled = rated; + if (!rated) { + up.addEventListener('click', function () { onUpvote(word); }); + } + var downEl = null; + if (onDownvote) { + downEl = el('button', { + type: 'button', + class: 'wc-vote wc-vote--down' + (isDown ? ' is-active' : ''), + 'aria-pressed': isDown ? 'true' : 'false', + 'aria-label': word.text + ', ' + downCount + ' Ablehnungen' + + (isDown ? ', von dir abgelehnt' : (isMine ? '' : ', ablehnen')) + }, [el('span', { 'aria-hidden': 'true', text: (isDown ? '✓ ' : '−') + downCount })]); + downEl.disabled = rated; + if (!rated) { + downEl.addEventListener('click', function () { onDownvote(word); }); + } + } else if (downCount > 0) { + downEl = el('span', { class: 'wc-count--down', text: '−' + downCount }); + } + return el('li', { class: 'wc-item' + (isMine ? ' is-mine' : '') + (isDown ? ' is-down' : '') }, [ + el('span', { class: 'wc-item__text', text: word.text }), + el('span', { class: 'wc-item__actions' }, [up, downEl]), + el('span', { class: 'wc-item__bar', 'aria-hidden': 'true', style: 'width:' + Math.max(3, Math.round(word.weight * 100)) + '%' }) + ]); + })); + }, + /** * options: {mine: [keys], down: [keys], onUpvote: fn(word)|null, onDownvote: fn(word)|null} * Counts are shown as "+up" and "−down" (down only when > 0 or clickable). @@ -897,8 +946,12 @@ ordered.unshift(word); } }); - return el('div', { class: 'cloud' + (onUpvote ? ' cloud--interactive' : '') }, ordered.map(function (word, index) { - var size = 0.9 + word.weight * 2.6; + if (onUpvote) { + return Results.wordList(results, options); + } + var scale = Math.max(0.45, Math.min(1, 1.1 - ordered.length * 0.035)); + return el('div', { class: 'cloud', style: '--cloud-scale:' + scale.toFixed(2) }, ordered.map(function (word, index) { + var size = 0.9 + word.weight * 1.6; var isMine = mine.indexOf(word.key) >= 0; var isDown = down.indexOf(word.key) >= 0; var rated = isMine || isDown; @@ -909,49 +962,12 @@ title: '+' + word.count + ' / −' + downCount + (isMine ? ' – von dir genannt' : (isDown ? ' – von dir abgelehnt' : '')) }; - if (!onUpvote) { - // Presenter (and participants without upvotes): show the counts next to the word. - return el('span', attrs, [ - el('span', { text: word.text }), - el('span', { class: 'cloud__count cloud__count--up', text: '+' + word.count }), - downCount > 0 ? el('span', { class: 'cloud__count cloud__count--down', text: '−' + downCount }) : null - ]); - } - - var up = el('button', { - type: 'button', - class: 'cloud__vote cloud__vote--up', - 'aria-pressed': isMine ? 'true' : 'false', - 'aria-label': word.text + ', ' + word.count + ' Stimmen' - + (isMine ? ', von dir genannt' : (isDown ? '' : ', unterstützen')) - }, [ + // Presenter (and participants without upvotes): show the counts next to the word. + return el('span', attrs, [ el('span', { text: word.text }), - el('span', { class: 'cloud__count cloud__count--up', 'aria-hidden': 'true', text: (isMine ? '✓ ' : '+') + word.count }) + el('span', { class: 'cloud__count cloud__count--up', text: '+' + word.count }), + downCount > 0 ? el('span', { class: 'cloud__count cloud__count--down', text: '−' + downCount }) : null ]); - up.disabled = rated; - if (!rated) { - up.addEventListener('click', function () { onUpvote(word); }); - } - - var downEl = null; - if (onDownvote) { - downEl = el('button', { - type: 'button', - class: 'cloud__vote cloud__vote--down', - 'aria-pressed': isDown ? 'true' : 'false', - 'aria-label': word.text + ', ' + downCount + ' Ablehnungen' - + (isDown ? ', von dir abgelehnt' : (isMine ? '' : ', ablehnen')) - }, [ - el('span', { class: 'cloud__count cloud__count--down', 'aria-hidden': 'true', text: (isDown ? '✓ ' : '') + '−' + downCount }) - ]); - downEl.disabled = rated; - if (!rated) { - downEl.addEventListener('click', function () { onDownvote(word); }); - } - } else if (downCount > 0) { - downEl = el('span', { class: 'cloud__count cloud__count--down', text: '−' + downCount }); - } - return el('span', attrs, [up, downEl]); })); },