UX: Highlight user's vote in polls.

This commit is contained in:
Guo Xiang Tan 2017-01-25 11:56:39 +08:00
parent e7564dc1d7
commit 1da6fc8e3c
2 changed files with 8 additions and 3 deletions

View File

@ -160,8 +160,9 @@ createWidget('discourse-poll-standard-results', {
return ordered.map((option, idx) => {
const contents = [];
const per = rounded[idx].toString();
const chosen = attrs.vote.includes(option.id);
contents.push(h('div.option',
h('p', [ h('span.percentage', `${per}%`), optionHtml(option) ])
));
@ -178,7 +179,7 @@ createWidget('discourse-poll-standard-results', {
}));
}
return h('li', contents);
return h('li', { className: `${chosen ? 'chosen' : ''}` }, contents);
});
}
}

View File

@ -107,7 +107,11 @@ div.poll {
.bar {
height: 10px;
background: $primary;
background: dark-light-diff($primary, $secondary, 50%, -25%);;
}
.chosen .bar {
background: $tertiary;
}
}