2023-04-03 09:08:02 +00:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { useFormatter } from '@/stores';
|
2023-04-06 00:17:40 +00:00
|
|
|
import type { Tally } from '@/types';
|
2023-04-03 09:08:02 +00:00
|
|
|
import { computed } from '@vue/reactivity';
|
2023-04-24 16:37:16 +00:00
|
|
|
import type { PropType } from 'vue';
|
2023-04-03 09:08:02 +00:00
|
|
|
|
|
|
|
const props = defineProps({
|
2023-04-24 16:37:16 +00:00
|
|
|
tally: { type: Object as PropType<Tally> },
|
2023-04-03 09:08:02 +00:00
|
|
|
pool: {
|
|
|
|
type: Object as PropType<{
|
2023-04-24 16:37:16 +00:00
|
|
|
not_bonded_tokens: string;
|
|
|
|
bonded_tokens: string;
|
2023-04-03 09:08:02 +00:00
|
|
|
}>,
|
|
|
|
},
|
2023-04-24 16:37:16 +00:00
|
|
|
});
|
|
|
|
const total = computed(() => props.pool?.bonded_tokens);
|
|
|
|
const format = useFormatter();
|
2023-05-06 14:56:04 +00:00
|
|
|
const yes = computed(() =>
|
|
|
|
format.calculatePercent(props.tally?.yes, total.value)
|
|
|
|
);
|
|
|
|
const no = computed(() =>
|
|
|
|
format.calculatePercent(props.tally?.no, total.value)
|
|
|
|
);
|
|
|
|
const abstain = computed(() =>
|
|
|
|
format.calculatePercent(props.tally?.abstain, total.value)
|
|
|
|
);
|
|
|
|
const veto = computed(() =>
|
|
|
|
format.calculatePercent(props.tally?.no_with_veto, total.value)
|
|
|
|
);
|
2023-04-03 09:08:02 +00:00
|
|
|
</script>
|
2023-04-24 16:37:16 +00:00
|
|
|
|
2023-04-03 09:08:02 +00:00
|
|
|
<template>
|
2023-05-15 15:44:24 +00:00
|
|
|
<div class="progress rounded-[3px] h-6 text-xs flex items-center">
|
2023-05-06 14:56:04 +00:00
|
|
|
<div
|
2023-05-15 15:44:24 +00:00
|
|
|
class="h-6 bg-yes flex items-center pl-2 text-white overflow-hidden"
|
2023-05-15 14:53:38 +00:00
|
|
|
:style="`width: ${yes}`"
|
|
|
|
:title="yes"
|
|
|
|
>
|
|
|
|
{{ yes }}
|
|
|
|
</div>
|
|
|
|
<div
|
2023-05-15 15:44:24 +00:00
|
|
|
class="h-6 bg-no flex items-center text-white overflow-hidden"
|
2023-05-15 14:53:38 +00:00
|
|
|
:style="`width: ${no}`"
|
|
|
|
:title="no"
|
|
|
|
>
|
|
|
|
{{ no }}
|
|
|
|
</div>
|
|
|
|
<div
|
2023-05-15 15:44:24 +00:00
|
|
|
class="h-6 bg-[#B71C1C] flex items-center text-white overflow-hidden"
|
2023-05-15 14:53:38 +00:00
|
|
|
:style="`width: ${veto};`"
|
|
|
|
:title="veto"
|
|
|
|
>
|
|
|
|
{{ veto }}
|
|
|
|
</div>
|
|
|
|
<div
|
2023-05-15 15:44:24 +00:00
|
|
|
class="h-6 bg-secondary flex items-center text-white overflow-hidden"
|
2023-05-15 14:53:38 +00:00
|
|
|
:style="`width: ${abstain}`"
|
|
|
|
:title="abstain"
|
|
|
|
>
|
|
|
|
{{ abstain }}
|
|
|
|
</div>
|
2023-04-24 16:37:16 +00:00
|
|
|
</div>
|
2023-04-03 09:08:02 +00:00
|
|
|
</template>
|
|
|
|
<style scoped>
|
|
|
|
.progress {
|
2023-04-24 16:37:16 +00:00
|
|
|
overflow: hidden;
|
|
|
|
background-color: rgba(128, 128, 128, 0.178);
|
2023-04-03 09:08:02 +00:00
|
|
|
}
|
2023-04-24 16:37:16 +00:00
|
|
|
</style>
|