Skip to content

Commit 862d5a3

Browse files
committed
chore: use afcl spinner across project codebase
1 parent 09c4059 commit 862d5a3

File tree

7 files changed

+104
-146
lines changed

7 files changed

+104
-146
lines changed

adminforth/spa/src/App.vue

Lines changed: 77 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -5,80 +5,80 @@
55
class="fixed h-14 top-0 z-30 w-full border-b drop-shadow-sm bg-lightNavbar dark:bg-darkNavbar dark:border-darkSidebarDevider"
66
>
77
<div class="af-header px-3 lg:px-5 lg:pl-3 flex items-center justify-between h-full w-full" >
8-
<div class="flex items-center justify-start rtl:justify-end">
9-
<button @click="sideBarOpen = !sideBarOpen"
10-
type="button" class="inline-flex items-center p-2 text-sm rounded-lg sm:hidden hover:bg-lightSidebarItemHover focus:outline-none focus:ring-2 focus:ring-lightSidebarDevider dark:text-darkSidebarIcons dark:hover:bg-darkSidebarHover dark:focus:ring-lightSidebarDevider">
11-
<span class="sr-only">{{ $t('Open sidebar') }}</span>
12-
<svg class="w-6 h-6" aria-hidden="true" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
13-
<path clip-rule="evenodd" fill-rule="evenodd" d="M2 4.75A.75.75 0 012.75 4h14.5a.75.75 0 010 1.5H2.75A.75.75 0 012 4.75zm0 10.5a.75.75 0 01.75-.75h7.5a.75.75 0 010 1.5h-7.5a.75.75 0 01-.75-.75zM2 10a.75.75 0 01.75-.75h14.5a.75.75 0 010 1.5H2.75A.75.75 0 012 10z"></path>
8+
<div class="flex items-center justify-start rtl:justify-end">
9+
<button @click="sideBarOpen = !sideBarOpen"
10+
type="button" class="inline-flex items-center p-2 text-sm rounded-lg sm:hidden hover:bg-lightSidebarItemHover focus:outline-none focus:ring-2 focus:ring-lightSidebarDevider dark:text-darkSidebarIcons dark:hover:bg-darkSidebarHover dark:focus:ring-lightSidebarDevider">
11+
<span class="sr-only">{{ $t('Open sidebar') }}</span>
12+
<svg class="w-6 h-6" aria-hidden="true" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
13+
<path clip-rule="evenodd" fill-rule="evenodd" d="M2 4.75A.75.75 0 012.75 4h14.5a.75.75 0 010 1.5H2.75A.75.75 0 012 4.75zm0 10.5a.75.75 0 01.75-.75h7.5a.75.75 0 010 1.5h-7.5a.75.75 0 01-.75-.75zM2 10a.75.75 0 01.75-.75h14.5a.75.75 0 010 1.5H2.75A.75.75 0 012 10z"></path>
14+
</svg>
15+
</button>
16+
</div>
17+
<div class="flex items-center">
18+
<component
19+
v-if="coreStore?.adminUser"
20+
v-for="c in coreStore?.config?.globalInjections?.header || []"
21+
:is="getCustomComponent(c)"
22+
:meta="c.meta"
23+
:adminUser="coreStore.adminUser"
24+
/>
25+
26+
<div class="flex items-center ms-3 ">
27+
<Tooltip>
28+
<IconWifiOff v-if="coreStore.isInternetError" class="blinking-icon w-8 h-8 text-red-500" />
29+
<template #tooltip>
30+
{{$t('Internet connection lost')}}
31+
</template>
32+
</Tooltip>
33+
<span
34+
v-if="!coreStore.config?.singleTheme"
35+
@click="toggleTheme" class="cursor-pointer flex items-center gap-1 block px-4 py-2 text-sm text-black dark:text-darkSidebarTextHover dark:hover:text-darkSidebarTextActive" role="menuitem">
36+
<IconMoonSolid class="w-5 h-5 text-blue-300" v-if="coreStore.theme !== 'dark'" />
37+
<IconSunSolid class="w-5 h-5 text-yellow-300" v-else />
38+
</span>
39+
<div>
40+
<button
41+
ref="dropdownUserButton"
42+
type="button" class="flex text-sm bg- rounded-full focus:ring-4 focus:ring-lightSidebarDevider dark:focus:ring-darkSidebarDevider dark:bg-" aria-expanded="false" data-dropdown-toggle="dropdown-user">
43+
<span class="sr-only">{{ $t('Open user menu') }}</span>
44+
<img
45+
v-if="coreStore.userAvatarUrl"
46+
class="w-8 h-8 rounded-full object-cover"
47+
:src="coreStore.userAvatarUrl"
48+
alt="user photo"
49+
/>
50+
<svg v-else class="w-8 h-8 text-lightNavbarIcons dark:text-darkNavbarIcons" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
51+
<path fill-rule="evenodd" d="M12 20a7.966 7.966 0 0 1-5.002-1.756l.002.001v-.683c0-1.794 1.492-3.25 3.333-3.25h3.334c1.84 0 3.333 1.456 3.333 3.25v.683A7.966 7.966 0 0 1 12 20ZM2 12C2 6.477 6.477 2 12 2s10 4.477 10 10c0 5.5-4.44 9.963-9.932 10h-.138C6.438 21.962 2 17.5 2 12Zm10-5c-1.84 0-3.333 1.455-3.333 3.25S10.159 13.5 12 13.5c1.84 0 3.333-1.455 3.333-3.25S13.841 7 12 7Z" clip-rule="evenodd"/>
1452
</svg>
15-
</button>
16-
</div>
17-
<div class="flex items-center">
18-
<component
19-
v-if="coreStore?.adminUser"
20-
v-for="c in coreStore?.config?.globalInjections?.header || []"
21-
:is="getCustomComponent(c)"
22-
:meta="c.meta"
23-
:adminUser="coreStore.adminUser"
24-
/>
25-
26-
<div class="flex items-center ms-3 ">
27-
<Tooltip>
28-
<IconWifiOff v-if="coreStore.isInternetError" class="blinking-icon w-8 h-8 text-red-500" />
29-
<template #tooltip>
30-
{{$t('Internet connection lost')}}
31-
</template>
32-
</Tooltip>
33-
<span
34-
v-if="!coreStore.config?.singleTheme"
35-
@click="toggleTheme" class="cursor-pointer flex items-center gap-1 block px-4 py-2 text-sm text-black dark:text-darkSidebarTextHover dark:hover:text-darkSidebarTextActive" role="menuitem">
36-
<IconMoonSolid class="w-5 h-5 text-blue-300" v-if="coreStore.theme !== 'dark'" />
37-
<IconSunSolid class="w-5 h-5 text-yellow-300" v-else />
38-
</span>
39-
<div>
40-
<button
41-
ref="dropdownUserButton"
42-
type="button" class="flex text-sm bg- rounded-full focus:ring-4 focus:ring-lightSidebarDevider dark:focus:ring-darkSidebarDevider dark:bg-" aria-expanded="false" data-dropdown-toggle="dropdown-user">
43-
<span class="sr-only">{{ $t('Open user menu') }}</span>
44-
<img
45-
v-if="coreStore.userAvatarUrl"
46-
class="w-8 h-8 rounded-full object-cover"
47-
:src="coreStore.userAvatarUrl"
48-
alt="user photo"
49-
/>
50-
<svg v-else class="w-8 h-8 text-lightNavbarIcons dark:text-darkNavbarIcons" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
51-
<path fill-rule="evenodd" d="M12 20a7.966 7.966 0 0 1-5.002-1.756l.002.001v-.683c0-1.794 1.492-3.25 3.333-3.25h3.334c1.84 0 3.333 1.456 3.333 3.25v.683A7.966 7.966 0 0 1 12 20ZM2 12C2 6.477 6.477 2 12 2s10 4.477 10 10c0 5.5-4.44 9.963-9.932 10h-.138C6.438 21.962 2 17.5 2 12Zm10-5c-1.84 0-3.333 1.455-3.333 3.25S10.159 13.5 12 13.5c1.84 0 3.333-1.455 3.333-3.25S13.841 7 12 7Z" clip-rule="evenodd"/>
52-
</svg>
53-
</button>
54-
</div>
55-
<div class="z-50 hidden my-4 text-base list-none bg-lightUserMenuBackground divide-y divide-lightUserMenuBorder text-lightUserMenuText rounded shadow dark:shadow-black dark:bg-darkUserMenuBackground dark:divide-darkUserMenuBorder text-darkUserMenuText dark:shadow-black" id="dropdown-user">
56-
<div class="px-4 py-3" role="none">
57-
<p class="text-sm text-gray-900 dark:text-darkNavbarText" role="none" v-if="coreStore.userFullname">
58-
{{ coreStore.userFullname }}
59-
</p>
60-
<p class="text-sm font-medium text-gray-900 truncate dark:text-darkSidebarText" role="none">
61-
{{ coreStore.username }}
62-
</p>
63-
</div>
64-
65-
<ul class="py-1" role="none">
66-
<li v-for="c in userMenuComponents" class="bg-lightUserMenuItemBackground hover:bg-lightUserMenuItemBackgroundHover text-lightUserMenuItemText hover:text-lightUserMenuItemText dark:bg-darkUserMenuItemBackground dark:hover:bg-darkUserMenuItemBackgroundHover dark:text-darkUserMenuItemText dark:hover:darkUserMenuItemTextHover" >
67-
<component
68-
:is="getCustomComponent(c)"
69-
:meta="c.meta"
70-
:adminUser="coreStore.adminUser"
71-
/>
72-
</li>
73-
<li v-if="coreStore?.config?.settingPages && coreStore.config.settingPages.length > 0">
74-
<UserMenuSettingsButton />
75-
</li>
76-
<li>
77-
<button @click="logout" class="cursor-pointer flex items-center gap-1 block px-4 py-2 text-sm bg-lightUserMenuItemBackground hover:bg-lightUserMenuItemBackgroundHover text-lightUserMenuItemText hover:text-lightUserMenuItemText dark:bg-darkUserMenuItemBackground dark:hover:bg-darkUserMenuItemBackgroundHover dark:text-darkUserMenuItemText dark:hover:darkUserMenuItemTextHover w-full" role="menuitem">{{ $t('Sign out') }}</button>
78-
</li>
79-
</ul>
53+
</button>
54+
</div>
55+
<div class="z-50 hidden my-4 text-base list-none bg-lightUserMenuBackground divide-y divide-lightUserMenuBorder text-lightUserMenuText rounded shadow dark:shadow-black dark:bg-darkUserMenuBackground dark:divide-darkUserMenuBorder text-darkUserMenuText dark:shadow-black" id="dropdown-user">
56+
<div class="px-4 py-3" role="none">
57+
<p class="text-sm text-gray-900 dark:text-darkNavbarText" role="none" v-if="coreStore.userFullname">
58+
{{ coreStore.userFullname }}
59+
</p>
60+
<p class="text-sm font-medium text-gray-900 truncate dark:text-darkSidebarText" role="none">
61+
{{ coreStore.username }}
62+
</p>
8063
</div>
64+
65+
<ul class="py-1" role="none">
66+
<li v-for="c in userMenuComponents" class="bg-lightUserMenuItemBackground hover:bg-lightUserMenuItemBackgroundHover text-lightUserMenuItemText hover:text-lightUserMenuItemText dark:bg-darkUserMenuItemBackground dark:hover:bg-darkUserMenuItemBackgroundHover dark:text-darkUserMenuItemText dark:hover:darkUserMenuItemTextHover" >
67+
<component
68+
:is="getCustomComponent(c)"
69+
:meta="c.meta"
70+
:adminUser="coreStore.adminUser"
71+
/>
72+
</li>
73+
<li v-if="coreStore?.config?.settingPages && coreStore.config.settingPages.length > 0">
74+
<UserMenuSettingsButton />
75+
</li>
76+
<li>
77+
<button @click="logout" class="cursor-pointer flex items-center gap-1 block px-4 py-2 text-sm bg-lightUserMenuItemBackground hover:bg-lightUserMenuItemBackgroundHover text-lightUserMenuItemText hover:text-lightUserMenuItemText dark:bg-darkUserMenuItemBackground dark:hover:bg-darkUserMenuItemBackgroundHover dark:text-darkUserMenuItemText dark:hover:darkUserMenuItemTextHover w-full" role="menuitem">{{ $t('Sign out') }}</button>
78+
</li>
79+
</ul>
8180
</div>
81+
</div>
8282
</div>
8383
</div>
8484
</nav>
@@ -92,12 +92,14 @@
9292
@sidebarStateChange="handleSidebarStateChange"
9393
/>
9494

95-
<div class="af-content-wrapper transition-all duration-300 ease-in-out max-w-[100vw]"
95+
<div
96+
v-if="loggedIn && routerIsReady && loginRedirectCheckIsReady && defaultLayout"
97+
class="af-content-wrapper transition-all duration-300 ease-in-out max-w-[100vw]"
9698
:style="{
9799
marginLeft: headerOnlyLayout ? 0 : isSidebarIconOnly ? '4.5rem' : expandedWidth,
98100
maxWidth: headerOnlyLayout ? '100%' : isSidebarIconOnly ? 'calc(100% - 4.5rem)' : `calc(100% - ${expandedWidth})`
99101
}"
100-
v-if="loggedIn && routerIsReady && loginRedirectCheckIsReady && defaultLayout">
102+
>
101103
<div class="p-0 dark:border-gray-700 mt-14">
102104
<RouterView/>
103105
</div>
@@ -109,8 +111,7 @@
109111

110112
<div v-else class="flex items-center justify-center h-screen">
111113
<div class="text-3xl text-gray-400 animate-bounce">
112-
<svg aria-hidden="true" class="w-8 h-8 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/><path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/></svg>
113-
<span class="sr-only">{{ $t('Loading...') }}</span>
114+
<Spinner class="w-8 h-8" />
114115
</div>
115116
</div>
116117
<AcceptModal />
@@ -198,7 +199,7 @@ import {useToastStore} from '@/stores/toast';
198199
import { initFrontedAPI } from '@/adminforth';
199200
import { useAdminforth } from '@/adminforth';
200201
import UserMenuSettingsButton from './components/UserMenuSettingsButton.vue';
201-
import { Tooltip } from '@/afcl'
202+
import { Tooltip, Spinner } from '@/afcl'
202203
203204
const coreStore = useCoreStore();
204205
const toastStore = useToastStore();

adminforth/spa/src/afcl/Button.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@
1010
'text-lightSecondaryContrast/70 bg-lightSecondary border-lightSecondaryContrast/30 dark:bg-darkSecondary hover:bg-lightSecondary/60 hover:border-lightSecondaryContrast/60 focus:ring-lightSecondary dark:focus:ring-darkSecondary/40 dark:text-darkSecondaryContrast dark:border-darkSecondaryContrast/40 dark:hover:bg-darkSecondary/60 dark:hover:border-darkSecondary/60': props.mode === 'secondary',
1111
}"
1212
>
13-
<svg v-if="props.loader"
14-
aria-hidden="true" class="w-4 h-4 text-lightButtonsText animate-spin dark:text-darkButtonsText fill-lightButtonsBackground dark:fill-darkPrimary"
15-
viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/><path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/></svg>
13+
<Spinner v-if="props.loader" class="w-4 h-4 text-lightButtonsText dark:text-darkButtonsText fill-lightButtonsBackground dark:fill-darkPrimary" />
1614
<slot></slot>
1715
</button>
1816
</template>
1917

2018
<script setup lang="ts">
19+
import { Spinner } from '@/afcl';
2120
2221
const props = withDefaults(defineProps<{
2322
loader?: boolean;

adminforth/spa/src/afcl/Spinner.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
<path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
55
<path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
66
</svg>
7-
<span class="sr-only">Loading...</span>
7+
<span class="sr-only">{{ $t('Loading...') }}</span>
88
</div>
99
</template>

adminforth/spa/src/components/ResourceListTable.vue

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -218,17 +218,10 @@
218218
:is="getIcon(action.icon)"
219219
class="w-6 h-6 text-lightPrimary dark:text-darkPrimary"
220220
/>
221-
<svg
221+
<Spinner
222222
v-if="actionLoadingStates[`${action.id}_${row._primaryKeyValue}`]"
223-
aria-hidden="true"
224-
class="w-6 h-6 p-1 animate-spin text-gray-200 dark:text-gray-500 fill-gray-500 dark:fill-gray-300"
225-
viewBox="0 0 100 101"
226-
fill="none"
227-
xmlns="http://www.w3.org/2000/svg"
228-
>
229-
<path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
230-
<path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
231-
</svg>
223+
class="w-5 h-5 text-gray-200 dark:text-gray-500 fill-gray-500 dark:fill-gray-300"
224+
/>
232225
<span v-if="actionLoadingStates[`${action.id}_${row._primaryKeyValue}`]" class="sr-only">Loading...</span>
233226
</button>
234227
</component>
@@ -369,7 +362,7 @@ import {
369362
IconInboxOutline
370363
} from '@iconify-prerendered/vue-flowbite';
371364
import router from '@/router';
372-
import { Tooltip } from '@/afcl';
365+
import { Tooltip, Spinner } from '@/afcl';
373366
import type { AdminForthResourceCommon, AdminForthResourceColumnCommon, AdminForthComponentDeclarationFull, AdminForthComponentDeclaration } from '@/types/Common';
374367
import { useAdminforth } from '@/adminforth';
375368
import Checkbox from '@/afcl/Checkbox.vue';

0 commit comments

Comments
 (0)