forked from hplush/slowreader
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloader.svelte
More file actions
69 lines (61 loc) · 1.39 KB
/
loader.svelte
File metadata and controls
69 lines (61 loc) · 1.39 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
62
63
64
65
66
67
68
69
<script lang="ts">
import { commonMessages as t } from '@slowreader/core'
let {
label = $t.loading,
size = 'normal',
value,
variant = 'auto'
}: {
label?: string
size?: 'normal' | 'wide'
value?: boolean | number
variant?: 'accent' | 'auto'
} = $props()
</script>
<progress
class="loader"
class:is-accent={variant === 'accent'}
class:is-wide={size === 'wide'}
{@attach progress => {
if (typeof value === 'number') {
progress.value = value
} else {
progress.removeAttribute('value')
}
}}
aria-label={label}
></progress>
<style>
/* Styles are in main/loader.css */
:global {
.loader.is-accent {
--loader-background: oklch(1 0 0 / 20%);
--loader-bar: oklch(1 0 0);
}
.loader.is-wide {
min-width: 100%;
}
@media (prefers-reduced-motion: reduce) {
.loader {
background: repeating-linear-gradient(
-45deg,
var(--loader-bar),
var(--loader-bar) 0.625rem,
var(--loader-background) 0.625rem,
var(--loader-background) 1.25rem
);
}
.loader::after {
display: none;
}
.loader::-webkit-progress-value {
background: transparent;
animation: none !important;
}
.loader::-moz-progress-bar {
background: transparent;
animation: none !important;
}
}
}
</style>