2019-05-25 17:36:44 +02:00
|
|
|
<div class="poll" >
|
2019-05-25 13:20:45 -07:00
|
|
|
<ul class="options" aria-label="Poll results">
|
|
|
|
{#each options as option}
|
|
|
|
<li class="option">
|
|
|
|
<div class="option-text">{option.title} ({option.share}%)</div>
|
|
|
|
<svg aria-hidden="true">
|
|
|
|
<line x1="0" y1="0" x2="{option.share}%" y2="0" />
|
|
|
|
</svg>
|
|
|
|
</li>
|
|
|
|
{/each}
|
|
|
|
</ul>
|
2019-05-25 17:36:44 +02:00
|
|
|
</div>
|
|
|
|
<style>
|
|
|
|
.poll {
|
|
|
|
grid-area: poll;
|
|
|
|
margin: 10px 10px 10px 5px;
|
|
|
|
}
|
|
|
|
|
2019-05-25 13:20:45 -07:00
|
|
|
ul.options {
|
|
|
|
list-style: none;
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
li.option {
|
|
|
|
margin: 0 0 10px 0;
|
|
|
|
padding: 0;
|
2019-05-25 17:36:44 +02:00
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
stroke: var(--svg-fill);
|
2019-05-25 13:20:45 -07:00
|
|
|
stroke-width: 5px;
|
|
|
|
}
|
|
|
|
|
|
|
|
li.option:last-child {
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.option-text {
|
|
|
|
word-wrap: break-word;
|
|
|
|
white-space: pre-wrap;
|
|
|
|
font-size: 1.1em;
|
2019-05-25 17:36:44 +02:00
|
|
|
}
|
|
|
|
|
2019-05-25 13:20:45 -07:00
|
|
|
svg {
|
|
|
|
height: 2px;
|
|
|
|
width: 100%;
|
|
|
|
margin-top: 5px;
|
2019-05-25 17:36:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
computed: {
|
|
|
|
poll: ({ originalStatus }) => originalStatus.poll,
|
|
|
|
options: ({ poll }) => poll.options.map(({ title, votes_count: votesCount }) => ({
|
|
|
|
title,
|
|
|
|
share: poll.votes_count ? Math.round(votesCount / poll.votes_count * 100) : 0
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|