Skip to content

Commit

Permalink
Initial implementation of BP votes tab
Browse files Browse the repository at this point in the history
Change BP Vote css to scss

Improve styling for BP Vote tab

Remove progress graph for BP Votes, adjust syntax
  • Loading branch information
kylanhurt committed Nov 22, 2023
1 parent e1b0c84 commit 7cfa21c
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 0 deletions.
119 changes: 119 additions & 0 deletions src/components/BpVotes.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<script>
import { getHyperionAccountData } from 'src/api/hyperion';
export default {
props: {
account: {
type: String,
required: true,
},
},
data() {
return {
bpVotes: [],
};
},
async mounted() {
const {
account: {
voter_info: { producers },
},
} = await getHyperionAccountData(this.account);
this.bpVotes = producers;
},
};
</script>

<template>
<div
class="row col-12 q-my-xs justify-center text-left container-max-width"
>
<div class="row col-11">
<div class="row col-12 q-mt-lg">
<div>
<p class="panel-title">Votes for Block Producers</p>
</div>
<q-space />
</div>
<q-separator class="row col-12 q-mt-md separator" />
<div class="info-wrap">
<div class="row voted-producers q-pa-md">
<p>Currently voting for the {{ bpVotes.length }} out of 30 possible block producers:</p>
<div v-if="bpVotes.length" class="producers-list">
<span
v-for="producer in bpVotes"
v-bind:key="producer"
class="producer-name"
>
<a :href="`/account/${producer}`">{{ producer }}</a>
</span>
</div>
</div>
</div>
</div>
</div>
</template>

<style lang="scss">
.info-wrap {
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
@media (min-width: $breakpoint-sm-min) {
flex-direction: row-reverse;
align-items: flex-start;
}
.vote-fraction-wrap {
// color: var(--q-primary);
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
.bp-vote-circle {
color: var(--q-primary);
}
@media (min-width: $breakpoint-sm-min) {
border-left: 1px solid var(--q-color-seperator-background);
}
}
.voted-producers {
display: block;
width: 100%;
p {
margin-bottom: 20px;
width: 100%;
display: none;
@media (min-width: $breakpoint-sm-min) {
display: block;
}
}
.producers-list {
width: 100%;
/* make grid with column width 100px and 20px margin */
display: inline-grid;
grid-template-columns: repeat(auto-fill, 100px);
grid-gap: 20px;
.producer-name {
width: 100px;
margin-right: 20px;
a {
text-decoration: none;
color: var(--q-primary);
}
}
}
}
}
</style>
6 changes: 6 additions & 0 deletions src/pages/Account.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import KeysPanel from 'components/KeysPanel.vue';
import ChildrenPanel from 'components/ChildrenPanel.vue';
import AccountCard from 'components/AccountCard.vue';
import ContractTabs from 'components/contract/ContractTabs.vue';
import BpVotes from 'components/BpVotes.vue';
import { api } from 'src/api';
import { useRoute, useRouter } from 'vue-router';
import { useStore } from 'src/store';
Expand All @@ -20,6 +21,7 @@ export default defineComponent({
ChildrenPanel,
AccountCard,
ContractTabs,
BpVotes,
},
setup() {
const store = useStore();
Expand Down Expand Up @@ -67,6 +69,7 @@ export default defineComponent({
<q-tab v-if="!accountPageSettings.hideContractsTab && abi" name="contract" label="Contract"/>
<q-tab v-if="!accountPageSettings.hideTokensTab" name="tokens" label="Tokens"/>
<q-tab v-if="!accountPageSettings.hideKeysTab" name="keys" label="Keys"/>
<q-tab name="votes" label="Votes"/>
<q-tab v-if="!accountPageSettings.hideChildrenTab" name="children" label="Children"/>
</q-tabs>
</div>
Expand All @@ -83,6 +86,9 @@ export default defineComponent({
<q-tab-panel v-if="!accountPageSettings.hideKeysTab" name="keys">
<KeysPanel :account="account"/>
</q-tab-panel>
<q-tab-panel name="votes">
<BpVotes :account="account"/>
</q-tab-panel>
<q-tab-panel v-if="!accountPageSettings.hideChildrenTab" name="children">
<ChildrenPanel :account="account"/>
</q-tab-panel>
Expand Down

0 comments on commit 7cfa21c

Please sign in to comment.