-
-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathLoading.svelte
100 lines (87 loc) · 1.88 KB
/
Loading.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<script lang="ts">
import {fade} from 'svelte/transition';
let {
background = false,
color = 'hsl(var(--text))',
global = false,
offset = 0,
}: {
background?: boolean;
color?: string;
global?: boolean;
offset?: number;
} = $props();
</script>
<div
class="container"
class:global
class:local={!global}
class:background
transition:fade="{{ duration: 100 }}"
>
<div class="loading" style="margin-top: {offset}px;">
<div class="loading-1" style:background={color}></div>
<div class="loading-2" style:background={color}></div>
<div class="loading-3" style:background={color}></div>
</div>
</div>
<style>
.container {
display: flex;
flex: 1;
justify-content: center;
align-items: center;
z-index: 1;
}
@keyframes fade-in {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes fade-out {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
.loading {
width: 3.3rem;
height: 1.1rem;
aspect-ratio: 3;
display: flex;
justify-content: space-evenly;
align-items: center;
}
.loading-1, .loading-2, .loading-3 {
height: 66%;
aspect-ratio: 1;
border-radius: 50%;
animation: 1s infinite alternate fade-in;
opacity: 0;
}
.loading-2 {
animation-delay: 333ms;
}
.loading-3 {
animation-delay: 666ms;
}
.global {
position: absolute;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
}
.local {
min-width: 70px;
max-width: 70px;
}
.background {
background: rgba(127, 127, 127, .5);
}
</style>