forked from pkp/ui-library
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkp/pkp-lib#10663 Spinners for dashboard&workflow
- Loading branch information
1 parent
cd9dcf6
commit 72c3280
Showing
7 changed files
with
160 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<template> | ||
<div | ||
v-if="progressStore.isFullScreenSpinner" | ||
class="fixed inset-0 z-50 flex items-center justify-center bg-default bg-opacity-75" | ||
> | ||
<Spinner size-variant="big" /> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import Spinner from '@/components/Spinner/Spinner.vue'; | ||
import {useProgressStore} from '@/stores/progressStore'; | ||
const progressStore = useProgressStore(); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import {defineStore} from 'pinia'; | ||
import {ref, computed} from 'vue'; | ||
|
||
export const useProgressStore = defineStore('progress', () => { | ||
/** | ||
* Background spinner currently used on workflow page | ||
* Detects all fetch activity on current screen | ||
* */ | ||
const screenFetchesInProgress = ref({}); | ||
const screensInProgress = computed(() => { | ||
const screens = []; | ||
Object.keys(screenFetchesInProgress.value).forEach((key) => { | ||
if (screenFetchesInProgress.value[key] > 0) { | ||
screens.push(key); | ||
} | ||
}); | ||
|
||
return screens; | ||
}); | ||
|
||
function fetchStarted(screenName = 'base') { | ||
if ( | ||
Object.prototype.hasOwnProperty.call( | ||
screenFetchesInProgress.value, | ||
screenName, | ||
) | ||
) { | ||
screenFetchesInProgress.value[screenName] = 0; | ||
} | ||
|
||
screenFetchesInProgress.value[screenName]++; | ||
} | ||
|
||
function fetchFinished(screenName = 'base') { | ||
screenFetchesInProgress.value[screenName]--; | ||
} | ||
|
||
/** | ||
* Fullscreen spinner | ||
*/ | ||
|
||
const isFullScreenSpinner = ref(false); | ||
function startFullScreenSpinner() { | ||
isFullScreenSpinner.value = true; | ||
} | ||
function stopFullScreenSpinner() { | ||
isFullScreenSpinner.value = false; | ||
} | ||
|
||
return { | ||
fetchStarted, | ||
fetchFinished, | ||
screensInProgress, | ||
|
||
/** | ||
* Full Screen spinner | ||
*/ | ||
isFullScreenSpinner, | ||
startFullScreenSpinner, | ||
stopFullScreenSpinner, | ||
}; | ||
}); |