cosmos-explorer/src/components/ProposalProcess.vue

49 lines
1.3 KiB
Vue
Raw Normal View History

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-04-24 16:44:57 +00:00
<div class="progress rounded-full h-1 text-xs flex items-center">
2023-04-24 16:37:16 +00:00
<div class="h-1 bg-yes" :style="`width: ${yes}`"></div>
<div class="h-1 bg-no" :style="`width: ${no}`"></div>
2023-05-06 14:56:04 +00:00
<div
class="h-1"
:style="`width: ${veto}; background-color: #B71C1C;`"
></div>
2023-04-24 16:37:16 +00:00
<div class="h-1 bg-secondary" :style="`width: ${abstain}`"></div>
</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>