Skip to content

Commit

Permalink
feat: Dashboard loading indicators 3 (#455)
Browse files Browse the repository at this point in the history
  • Loading branch information
janmichek committed Aug 21, 2023
1 parent f5941dd commit 4e007a6
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
27 changes: 26 additions & 1 deletion src/components/StatsPanel.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<template>
<app-panel class="stats-panel">
<app-panel
v-if="!isLoading"
class="stats-panel">
<stats-tile
class="stats-panel__stats-tile"
title="TRANSACTIONS"
Expand Down Expand Up @@ -184,6 +186,10 @@
</template>
</stats-tile>
</app-panel>

<loader-panel
v-else
class="stats-panel__loader-panel"/>
</template>

<script setup>
Expand Down Expand Up @@ -215,6 +221,11 @@ const {
latestReward,
latestBri,
} = storeToRefs(useRecentBlocksStore())
const isLoading = computed(() => {
return !(transactionsCount.value && latestBri.value && latestReward.value)
})
</script>

<style scoped>
Expand Down Expand Up @@ -248,5 +259,19 @@ const {
&__value {
font-weight: 700;
}
&__loader-panel {
height: 784px;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
padding: var(--space-4);
@media (--desktop) {
/*hardcoded height to prevent content jumping*/
height: 264px;
}
}
}
</style>
15 changes: 13 additions & 2 deletions src/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@
</div>
</div>
<div class="dashboard__row">
<client-only>
<client-only v-if="!isLoading">
<blockchain-panel/>
</client-only>
<loader-panel
v-else
class="dashboard__loader-panel"/>
</div>

<div class="dashboard__row">
Expand Down Expand Up @@ -106,6 +109,8 @@ definePageMeta({
layout: 'empty',
})
const isLoading = ref(true)
await useAsyncData(() => Promise.all([
fetchStateChannels(),
fetchInAuctionNames(),
Expand All @@ -119,7 +124,9 @@ await useAsyncData(() => Promise.all([
fetchSelectedMicroblocksInfo(),
fetchTotalTransactionsCount(),
fetchDeltaStats(),
]), { server: false })
]).then(() => {
isLoading.value = false
}), { server: false })
onBeforeMount(() => {
isSubscribedToKeyblockDetails.value = true
Expand Down Expand Up @@ -188,5 +195,9 @@ onBeforeUnmount(() => {
line-height: 20px;
font-family: var(--font-monospaced);
}
&__loader-panel {
width: 100%;
}
}
</style>

0 comments on commit 4e007a6

Please sign in to comment.