Open source personal finance application
perf(stat): hold dashboard in a skeleton while local data hydrates
Ilya Komichev00486a9ef61e
diff --git a/app/app/components/stat/PageSkeleton.vue b/app/app/components/stat/PageSkeleton.vuenew file mode 100644index 00000000..8e39c98c--- /dev/null+++ b/app/app/components/stat/PageSkeleton.vue@@ -0,0 +1,26 @@+<script setup lang="ts">+// Space-reserving placeholder shown while local data is still hydrating: the first+// data paint replaces equal-height blocks instead of shifting the layout (CLS).+</script>++<template>+ <UiPage>+ <div class="grid gap-4 px-3 pt-3">+ <USkeleton class="h-8 w-40" />++ <USkeleton class="h-9 w-full max-w-72" />++ <USkeleton class="h-12 w-full" />++ <div class="grid grid-cols-3 gap-3">+ <USkeleton v-for="i in 3" :key="i" class="h-16" />+ </div>++ <USkeleton class="h-40 w-full" />++ <div class="grid gap-2 pt-2">+ <USkeleton v-for="i in 6" :key="i" class="h-12 w-full" />+ </div>+ </div>+ </UiPage>+</template>diff --git a/app/app/pages/dashboard.vue b/app/app/pages/dashboard.vueindex 72580c4a..3acecaf4 100644--- a/app/app/pages/dashboard.vue+++ b/app/app/pages/dashboard.vue@@ -1,10 +1,18 @@<script setup lang="ts">import { useInitApp } from '~/components/app/useInitApp'+import { useTrnsStore } from '~/components/trns/useTrnsStore'+import { useWalletsStore } from '~/components/wallets/useWalletsStore'defineOptions({ name: 'Dashboard' })const { t } = useI18n()const { bootState } = useInitApp()+const trnsStore = useTrnsStore()+const walletsStore = useWalletsStore()++// Data may still be hydrating (cache prime / first watch emission) after the shell paints;+// a skeleton holds the page shape until then so arriving rows don't shift the layout.+const hasAnyData = computed(() => trnsStore.hasItems || walletsStore.hasItems)useSeoMeta({ogTitle: t('stat.title'),@@ -13,6 +21,7 @@ useSeoMeta({</script><template>- <StatPage v-if="bootState === 'ready'" />+ <StatPage v-if="bootState === 'ready' && hasAnyData" />+ <StatPageSkeleton v-else-if="bootState === 'ready'" /><LazyAppOnboarding v-else-if="bootState === 'onboarding'" /></template>