forked from quoid/userscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoader.svelte
More file actions
61 lines (55 loc) · 1.31 KB
/
Copy pathLoader.svelte
File metadata and controls
61 lines (55 loc) · 1.31 KB
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
<script>
import { fade } from "svelte/transition";
import iconLoader from "@shared/img/icon-loader.svg?raw";
export let abort = false;
export let abortClick = () => {};
export let backgroundColor = "var(--color-bg-secondary)";
/**
* Avoid icon bouncing due to viewport height changes or banner insertion
* @type {import('svelte/action').Action}
*/
function lockIconTopPosition(node) {
const icon = node.querySelector("svg");
const rect = icon.getBoundingClientRect();
icon.style.top = rect.top.toString();
icon.style.position = "fixed";
}
</script>
<div
class="loader"
style="background-color: {backgroundColor};"
out:fade={{ duration: 125 }}
use:lockIconTopPosition
>
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
{@html iconLoader}
{#if abort}
<div>
Fetching resources, <button class="link" on:click={abortClick}>
cancel request
</button>
</div>
{/if}
</div>
<style>
.loader {
align-items: center;
display: flex;
flex-direction: column;
justify-content: center;
inset: 0;
position: absolute;
z-index: 90;
}
.loader :global(svg) {
height: 2rem;
width: 2rem;
stroke: var(--text-color-primary);
}
.loader div {
color: var(--text-color-disabled);
font: var(--text-small);
letter-spacing: var(--letter-spacing-small);
margin-top: 1rem;
}
</style>