Skip to content
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

show loading indicator and disable inputs while page navigation is in… #53

Merged
merged 1 commit into from
Dec 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"prettier-plugin-svelte": "^2.8.1",
"svelte": "^3.59.2",
"svelte-adapter-azure-swa": "^0.19.0",
"svelte-loading-spinners": "^0.3.4",
"tailwindcss": "^3.2.7",
"vite": "^4.0.0",
"vitest": "^0.25.3"
Expand Down
19 changes: 19 additions & 0 deletions frontend/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
<script>
import '../app.css';
import Footer from './footer.svelte'
import { fade } from "svelte/transition";
import { navigating } from "$app/stores";
import { BarLoader } from 'svelte-loading-spinners';
</script>

<!-- shoutout to https://www.ratamero.com/blog/showing-a-loading-spinner-when-navigation-is-delayed-in-sveltekit -->
{#if Boolean($navigating)}
<div class="css-tweaked-bar-loader w-full fixed top-0 z-50">
<BarLoader size="60" color="#1e40af" duration="1s"/>
</div>
<div class="fixed w-full h-full z-10" in:fade={{ duration: 150 }}>
<div class="absolute w-full h-full bg-white dark:bg-cyan-800 opacity-50 z-10"></div>
</div>
{/if}

<div class="flex flex-col h-screen justify-between">
<div class="navbar bg-base-100 shadow-sm">
<div class="navbar-start">
Expand Down Expand Up @@ -53,3 +66,9 @@
<Footer class="self-end"></Footer>
</div>

<style>
/* overwrite svelte component styling from svelte-loading-spinners */
.css-tweaked-bar-loader :global(.wrapper) { /* this is needed so css is not leaking ... see https://stackoverflow.com/a/56989664 */
width: 100% !important;
}
</style>
Loading