-
Notifications
You must be signed in to change notification settings - Fork 17
feat(web): add loading and error states to notification sidebar #974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,12 @@ | ||
| <script setup lang="ts"> | ||
| import { cn } from '~/components/shadcn/utils'; | ||
|
|
||
| const props = withDefaults(defineProps<{ class?: string }>(), { class: '' }); | ||
| </script> | ||
| <template> | ||
| <div | ||
| :class="cn('h-5 animate-pulse bg-gray-300 w-full', props.class)" | ||
| role="progressbar" | ||
| aria-label="Loading" | ||
| /> | ||
| </template> | ||
This file contains hidden or 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,55 @@ | ||
| <script setup lang="ts"> | ||
| import { ShieldExclamationIcon } from '@heroicons/vue/24/solid'; | ||
| import { cn } from '~/components/shadcn/utils'; | ||
pujitm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * A default container for displaying loading and error states. | ||
| * | ||
| * By default, this component will expand to full height and display contents | ||
| * in the center of the container. | ||
| * | ||
| * Any slot/child will only render when a loading/error state isn't displayed. | ||
| * | ||
| * Exposes a 'retry' event (user-triggered during error state). | ||
| * | ||
| * @example | ||
| * <LoadingError @retry="retryFunction" :loading="loading" :error="error" /> | ||
| * | ||
| * <LoadingError :loading="loading" :error="error"> | ||
| * <p>Only displayed when both loading and error are false.</p> | ||
| * </LoadingError> | ||
| */ | ||
| const props = withDefaults( | ||
| defineProps<{ | ||
| class?: string; | ||
| /** hasdfsa */ | ||
| loading: boolean; | ||
| error: Error | null | undefined; | ||
| }>(), | ||
| { class: '' } | ||
| ); | ||
|
|
||
| defineEmits(['retry']); | ||
| </script> | ||
| <template> | ||
| <div :class="cn('h-full flex flex-col items-center justify-center gap-3', props.class)"> | ||
| <!-- Loading State --> | ||
| <div v-if="loading" class="contents"> | ||
| <LoadingSpinner /> | ||
| <p>Loading Notifications...</p> | ||
| </div> | ||
| <!-- Error State --> | ||
| <div v-else-if="error" class="space-y-3"> | ||
| <div class="flex justify-center"> | ||
| <ShieldExclamationIcon class="h-10 text-unraid-red" /> | ||
| </div> | ||
| <div> | ||
| <h3 class="font-bold">{{ `Error` }}</h3> | ||
| <p>{{ error.message }}</p> | ||
| </div> | ||
| <Button type="button" class="w-full" @click="$emit('retry')">Try Again</Button> | ||
pujitm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </div> | ||
| <!-- Default state --> | ||
| <slot v-else /> | ||
pujitm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </div> | ||
| </template> | ||
This file contains hidden or 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,19 @@ | ||
| <script setup lang="ts"> | ||
pujitm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import { cn } from '~/components/shadcn/utils'; | ||
|
|
||
| const props = withDefaults(defineProps<{ class?: string }>(), { class: '' }); | ||
| </script> | ||
| <template> | ||
| <!-- adapted from https://tw-elements.com/docs/standard/components/spinners/ --> | ||
| <div | ||
| :class=" | ||
| cn( | ||
| 'inline-block h-8 w-8 animate-spin rounded-full border-2 border-solid border-current border-e-transparent align-[-0.125em] text-primary motion-reduce:animate-[spin_1.5s_linear_infinite]', | ||
| props.class | ||
| ) | ||
| " | ||
| role="status" | ||
| > | ||
| <span class="sr-only">Loading...</span> | ||
| </div> | ||
| </template> | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.