From d937c813fe1e1d0002e3f3db061991dd83a1a3a2 Mon Sep 17 00:00:00 2001 From: Dmytro Svyrydenko Date: Fri, 16 Aug 2024 22:22:46 +0200 Subject: [PATCH 1/8] feat: Improve empty state for dashboard widgets --- src/components/widgets/balance-trend.vue | 56 +++++++----- .../widgets/components/empty-state.vue | 10 +++ .../widgets/components/widget-wrapper.vue | 4 +- src/components/widgets/expenses-structure.vue | 88 +++++++++++-------- src/components/widgets/latest-records.vue | 34 ++++--- src/pages/auth/welcome.vue | 2 +- 6 files changed, 124 insertions(+), 70 deletions(-) create mode 100644 src/components/widgets/components/empty-state.vue diff --git a/src/components/widgets/balance-trend.vue b/src/components/widgets/balance-trend.vue index 8199c052..c645732d 100644 --- a/src/components/widgets/balance-trend.vue +++ b/src/components/widgets/balance-trend.vue @@ -1,30 +1,37 @@ @@ -41,6 +48,7 @@ import { subMonths, } from "date-fns"; import { storeToRefs } from "pinia"; +import { ChartLineIcon } from "lucide-vue-next"; import { getTotalBalance } from "@/api"; import { VUE_QUERY_CACHE_KEYS } from "@/common/const"; import { calculatePercentageDifference, formatLargeNumber } from "@/js/helpers"; @@ -49,6 +57,7 @@ import { loadBalanceTrendData } from "@/services"; import { useCurrenciesStore } from "@/stores"; import WidgetWrapper from "./components/widget-wrapper.vue"; +import EmptyState from "./components/empty-state.vue"; // Calculate it manually so shart will always have first and last ticks (dates) function generateDateSteps(datesToShow = 5, date = new Date()) { @@ -143,6 +152,11 @@ watch( { immediate: true }, ); +const isDataEmpty = computed( + () => + !balanceHistory.value || balanceHistory.value.every((i) => i.amount === 0), +); + const chartOptions = computed(() => { const pixelsPerTick = 120; const ticksAmount = currentChartWidth.value diff --git a/src/components/widgets/components/empty-state.vue b/src/components/widgets/components/empty-state.vue new file mode 100644 index 00000000..5071f054 --- /dev/null +++ b/src/components/widgets/components/empty-state.vue @@ -0,0 +1,10 @@ + diff --git a/src/components/widgets/components/widget-wrapper.vue b/src/components/widgets/components/widget-wrapper.vue index a9aca5b6..6c8ab6a5 100644 --- a/src/components/widgets/components/widget-wrapper.vue +++ b/src/components/widgets/components/widget-wrapper.vue @@ -1,6 +1,6 @@