From f637eebe70e6c21e6940771f9ff2b9fcf26e1ec0 Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Sat, 25 Jul 2026 10:31:30 +0700 Subject: [PATCH] Add skeleton loading to DataTable component - Introduced `loading` prop to DataTable for handling loading state - Replaced loading text with skeleton rows during data fetch - Updated Business Types and Plans pages to utilize the new loading prop --- app/components/data-table/DataTable.vue | 22 ++++++++++-- app/pages/admin/business-types/index.vue | 5 +-- app/pages/admin/plans/index.vue | 5 +-- .../2026-07-25-skeleton-loading-table.md | 35 +++++++++++++++++++ 4 files changed, 57 insertions(+), 10 deletions(-) create mode 100644 docs/history/2026-07-25-skeleton-loading-table.md diff --git a/app/components/data-table/DataTable.vue b/app/components/data-table/DataTable.vue index 83dfb67..4833591 100644 --- a/app/components/data-table/DataTable.vue +++ b/app/components/data-table/DataTable.vue @@ -27,6 +27,7 @@ import { TableRow, } from '@/components/ui/table' import { valueUpdater } from '@/lib/utils' +import { Skeleton } from '@/components/ui/skeleton' import DataTablePagination from './DataTablePagination.vue' import { Empty, EmptyDescription, @@ -36,6 +37,7 @@ import { const props = defineProps<{ columns: ColumnDef[] data: TData[] + loading?: boolean }>() const sorting = ref([]) @@ -81,6 +83,14 @@ const table = useVueTable({ }, }) +function skeletonWidth(columnId: string) { + switch (columnId) { + case 'number': return 'w-6' + case 'actions': return 'w-8' + default: return 'w-full' + } +} + defineExpose({ table }) @@ -99,7 +109,15 @@ defineExpose({ table }) -