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 <noreply@anthropic.com>
This commit is contained in:
1 parent
7a80794ded
commit
6c77470824
3 files changed
+80
-52
No files matched your search
+59
-43
@@ -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]);
|
||||
}));
|
||||
},
|
||||
|
||||
|
||||
Reference in new issue
Block a user