mirror of
https://github.com/elk-zone/elk.git
synced 2024-11-21 17:05:22 +03:00
fix: avoid bar width division by zero (#1826)
This commit is contained in:
parent
a5cece7b42
commit
2842a5f383
1 changed files with 2 additions and 2 deletions
|
@ -57,7 +57,7 @@ const votersCount = $computed(() => poll.votersCount ?? poll.votesCount ?? 0)
|
|||
<div
|
||||
v-for="(option, index) of poll.options"
|
||||
:key="index" py-1 relative
|
||||
:style="{ '--bar-width': toPercentage((option.votesCount || 0) / votersCount) }"
|
||||
:style="{ '--bar-width': toPercentage(votersCount === 0 ? 0 : (option.votesCount ?? 0) / votersCount) }"
|
||||
>
|
||||
<div flex justify-between pb-2 w-full>
|
||||
<span inline-flex align-items>
|
||||
|
@ -67,7 +67,7 @@ const votersCount = $computed(() => poll.votersCount ?? poll.votesCount ?? 0)
|
|||
<span text-primary-active> {{ formatPercentage(votersCount > 0 ? (option.votesCount || 0) / votersCount : 0) }}</span>
|
||||
</div>
|
||||
<div class="bg-gray/40" rounded-l-sm rounded-r-lg h-5px w-full>
|
||||
<div bg-primary-active h-full class="w-[var(--bar-width)]" />
|
||||
<div bg-primary-active h-full min-w="1%" class="w-[var(--bar-width)]" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
|
Loading…
Reference in a new issue