mirror of
https://github.com/danbulant/design
synced 2026-05-19 04:08:46 +00:00
add loading spinner
This commit is contained in:
parent
a8c5882e56
commit
1b72cbf5fd
2 changed files with 54 additions and 1 deletions
45
src/lib/components/icons/spinner.svelte
Normal file
45
src/lib/components/icons/spinner.svelte
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<svg class="spinner" width="100%" height="100%" viewBox="0 0 66 66" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle class="path" fill="none" stroke-width="6" stroke-linecap="round" cx="33" cy="33" r="30"></circle>
|
||||
</svg>
|
||||
|
||||
<style>
|
||||
.spinner {
|
||||
--offset: 187;
|
||||
--duration: 1.4s;
|
||||
animation: rotator var(--duration) linear infinite;
|
||||
}
|
||||
|
||||
@keyframes rotator {
|
||||
0% { transform: rotate(0deg); }
|
||||
100% { transform: rotate(270deg); }
|
||||
}
|
||||
|
||||
.path {
|
||||
stroke-dasharray: var(--offset);
|
||||
stroke-dashoffset: 0;
|
||||
transform-origin: center;
|
||||
animation:
|
||||
dash var(--duration) ease-in-out infinite,
|
||||
colors calc(var(--duration)*4) ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes colors {
|
||||
0% { stroke: #4285F4; }
|
||||
25% { stroke: #DE3E35; }
|
||||
50% { stroke: #F7C223; }
|
||||
75% { stroke: #1B9A59; }
|
||||
100% { stroke: #4285F4; }
|
||||
}
|
||||
|
||||
@keyframes dash {
|
||||
0% { stroke-dashoffset: var(--offset); }
|
||||
50% {
|
||||
stroke-dashoffset: calc(var(--offset)/4);
|
||||
transform:rotate(135deg);
|
||||
}
|
||||
100% {
|
||||
stroke-dashoffset: var(--offset);
|
||||
transform:rotate(450deg);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
|
|
@ -5,7 +5,9 @@
|
|||
import { browser, dev } from "$app/environment";
|
||||
import * as Sentry from '@sentry/browser';
|
||||
import { apm } from "$lib/apm";
|
||||
import { page } from "$app/stores";
|
||||
import { navigating, page } from "$app/stores";
|
||||
import Spinner from "$lib/components/icons/spinner.svelte";
|
||||
import { fly } from "svelte/transition";
|
||||
|
||||
if (browser && dev) import("virtual:windi-devtools");
|
||||
|
||||
|
|
@ -25,6 +27,12 @@
|
|||
|
||||
<Navbar />
|
||||
|
||||
{#if $navigating}
|
||||
<div transition:fly={{ duration: 200, opacity: 0, y: -20 }} class="fixed bg-hex-1f1f1f top-20 left-1/2 transform -translate-x-1/2 rounded-full w-14 h-14 p-2 z-99">
|
||||
<Spinner />
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="overflow-x-hidden w-100vw">
|
||||
<PageTransition url={data.url}>
|
||||
<slot />
|
||||
|
|
|
|||
Loading…
Reference in a new issue