mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-24 02:05:39 +03:00
Add style for leading choices
Also make sure the votes percentage doesn't shrink
This commit is contained in:
parent
f2dc15c8ef
commit
121e9176f3
2 changed files with 12 additions and 1 deletions
|
@ -396,6 +396,13 @@ a.card:hover {
|
|||
gap: 8px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.poll-option-votes {
|
||||
flex-shrink: 0;
|
||||
font-size: 90%;
|
||||
}
|
||||
.poll-option-leading .poll-option-votes {
|
||||
font-weight: bold;
|
||||
}
|
||||
.poll-vote-button {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
|
|
@ -290,9 +290,13 @@ function Poll({ poll }) {
|
|||
const pollVotesCount = votersCount || votesCount;
|
||||
const percentage =
|
||||
Math.round((optionVotesCount / pollVotesCount) * 100) || 0;
|
||||
// check if current poll choice is the leading one
|
||||
const isLeading =
|
||||
optionVotesCount > 0 &&
|
||||
optionVotesCount === Math.max(...options.map((o) => o.votesCount));
|
||||
return (
|
||||
<div
|
||||
class="poll-option"
|
||||
class={`poll-option ${isLeading ? 'poll-option-leading' : ''}`}
|
||||
style={{
|
||||
'--percentage': `${percentage}%`,
|
||||
}}
|
||||
|
|
Loading…
Reference in a new issue