Skip to content

Commit c83bce9

Browse files
committed
feat: enhance loading skeleton with improved styles and dynamic row count
1 parent 84830fa commit c83bce9

1 file changed

Lines changed: 60 additions & 9 deletions

File tree

adminforth/spa/src/views/ShowView.vue

Lines changed: 60 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,53 @@
7272
:adminUser="coreStore.adminUser"
7373
/>
7474

75-
<div v-if="loading" role="status" class="max-w-sm animate-pulse">
76-
<div class="h-2.5 bg-gray-200 rounded-full dark:bg-gray-700 w-48 mb-4"></div>
77-
<div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 max-w-[360px] mb-2.5"></div>
78-
<div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 mb-2.5"></div>
79-
<div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 max-w-[330px] mb-2.5"></div>
80-
<div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 max-w-[300px] mb-2.5"></div>
81-
<div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 max-w-[360px]"></div>
82-
<span class="sr-only">{{ $t('Loading...') }}</span>
75+
<div
76+
v-if="loading"
77+
role="status"
78+
class="animate-pulse overflow-x-auto shadow-resourseFormShadow dark:shadow-darkResourseFormShadow"
79+
:class="{ 'rounded-default': isRounded }"
80+
>
81+
<div
82+
v-if="groups && groups.length > 0"
83+
class="text-md font-semibold px-6 py-3 flex flex-1 items-center bg-lightShowTableHeadingBackground dark:bg-darkShowTableHeadingBackground dark:text-darkShowTableHeadingText rounded-t-lg border-b border-lightShowTableBodyBorder dark:border-darkShowTableBodyBorder"
84+
>
85+
<div class="h-4 bg-gray-300 dark:bg-gray-600 rounded-full w-32"></div>
86+
</div>
87+
88+
<table class="w-full text-sm text-left table-fixed">
89+
<thead class="bg-lightShowTableUnderHeadingBackground dark:bg-darkShowTableUnderHeadingBackground block md:table-row-group">
90+
<tr>
91+
<th scope="col" class="px-6 py-3 text-xs uppercase hidden md:w-52 md:table-cell text-lightShowTableUnderHeadingText dark:text-darkShowTableUnderHeadingText">
92+
{{ $t('Field') }}
93+
</th>
94+
<th scope="col" class="px-6 py-3 text-xs uppercase hidden md:table-cell text-lightShowTableUnderHeadingText dark:text-darkShowTableUnderHeadingText">
95+
{{ $t('Value') }}
96+
</th>
97+
</tr>
98+
</thead>
99+
100+
<tbody>
101+
<tr
102+
v-for="i in skeletonRowsCount"
103+
:key="i"
104+
class="bg-lightShowTablesBodyBackground border-t border-lightShowTableBodyBorder dark:bg-darkShowTablesBodyBackground dark:border-darkShowTableBodyBorder block md:table-row"
105+
>
106+
<td class="px-6 py-[15.5px] relative block md:table-cell pb-0 md:pb-[15.5px]">
107+
<div class="md:absolute md:inset-0 flex items-center px-6 py-[15.5px]">
108+
<div class="h-2.5 bg-gray-200 dark:bg-gray-700 rounded-full w-24"></div>
109+
</div>
110+
</td>
111+
112+
<td class="px-6 py-[15.5px] whitespace-pre-wrap block md:table-cell">
113+
<div class="flex items-center h-full min-h-[21px]">
114+
<div class="h-2.5 bg-gray-200 dark:bg-gray-700 rounded-full w-full max-w-[280px]"></div>
115+
</div>
116+
</td>
117+
</tr>
118+
</tbody>
119+
</table>
120+
121+
<span class="sr-only">{{ $t('Loading...') }}</span>
83122
</div>
84123
<div
85124
v-else-if="coreStore.record"
@@ -164,6 +203,18 @@ const customActions = computed(() => {
164203
return coreStore.resource?.options?.actions?.filter((a: any) => a.showIn?.showThreeDotsMenu) || [];
165204
});
166205
206+
const skeletonRowsCount = computed(() => {
207+
const allCols = coreStore.resource?.columns;
208+
209+
const isEnabledInConfig = (col: any) => {
210+
return col.showIn?.list !== false;
211+
};
212+
213+
const finalCount = allCols.filter(isEnabledInConfig).length;
214+
215+
return finalCount > 0 ? finalCount : 10;
216+
});
217+
167218
onMounted(async () => {
168219
loading.value = true;
169220
await coreStore.fetchResourceFull({
@@ -178,7 +229,7 @@ onMounted(async () => {
178229
if(coreStore.resourceOptions){
179230
checkAcessByAllowedActions(coreStore.resourceOptions.allowedActions,'show');
180231
}
181-
loading.value = false;
232+
// loading.value = false;
182233
});
183234
184235
const groups = computed(() => {

0 commit comments

Comments
 (0)