@shival99/z-ui-svelte 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,61 +1,70 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { Snippet } from 'svelte';
|
|
3
|
-
import type { ClassValue } from 'clsx';
|
|
4
|
-
import { zTranslate } from '../../i18n/translate.svelte';
|
|
5
|
-
import { zMergeClasses } from '../../utils/merge-classes';
|
|
6
|
-
|
|
7
|
-
interface Props {
|
|
8
|
-
class?: ClassValue;
|
|
9
|
-
/** Text or i18n key. The `children` snippet replaces it. */
|
|
10
|
-
zText?: string;
|
|
11
|
-
/** Seconds for one sweep (default 2). */
|
|
12
|
-
zDuration?: number;
|
|
13
|
-
/** Hold the sweep: the text stays in its resting colour. */
|
|
14
|
-
zPaused?: boolean;
|
|
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
|
-
background-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { ClassValue } from 'clsx';
|
|
4
|
+
import { zTranslate } from '../../i18n/translate.svelte';
|
|
5
|
+
import { zMergeClasses } from '../../utils/merge-classes';
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
class?: ClassValue;
|
|
9
|
+
/** Text or i18n key. The `children` snippet replaces it. */
|
|
10
|
+
zText?: string;
|
|
11
|
+
/** Seconds for one sweep (default 2). */
|
|
12
|
+
zDuration?: number;
|
|
13
|
+
/** Hold the sweep: the text stays in its resting colour. */
|
|
14
|
+
zPaused?: boolean;
|
|
15
|
+
/** Resting colour of the text (any CSS colour; default the muted foreground). */
|
|
16
|
+
zBase?: string;
|
|
17
|
+
/** Colour of the sweeping highlight (default the foreground). */
|
|
18
|
+
zPeak?: string;
|
|
19
|
+
children?: Snippet;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let { class: className, zText = '', zDuration = 2, zPaused = false, zBase, zPeak, children }: Props = $props();
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<!-- A highlight sweeps across the text — "thinking…", "loading…" — without moving any layout. -->
|
|
26
|
+
<span
|
|
27
|
+
class={zMergeClasses('z-shimmer-text inline-block', zPaused && 'z-shimmer-text-paused', className)}
|
|
28
|
+
style:--z-shimmer-duration={`${zDuration}s`}
|
|
29
|
+
style:--z-shimmer-base={zBase}
|
|
30
|
+
style:--z-shimmer-peak={zPeak}
|
|
31
|
+
>
|
|
32
|
+
{#if children}{@render children()}{:else}{zTranslate(zText)}{/if}
|
|
33
|
+
</span>
|
|
34
|
+
|
|
35
|
+
<style>
|
|
36
|
+
.z-shimmer-text {
|
|
37
|
+
/* The gradient is 3x the text and never repeats: the highlight enters and leaves in the resting colour, so the
|
|
38
|
+
loop has no jump (a repeating gradient showed the previous tile's highlight when the sweep restarted). */
|
|
39
|
+
background-image: linear-gradient(
|
|
40
|
+
105deg,
|
|
41
|
+
var(--z-shimmer-base, var(--muted-foreground)) 40%,
|
|
42
|
+
var(--z-shimmer-peak, var(--foreground)) 50%,
|
|
43
|
+
var(--z-shimmer-base, var(--muted-foreground)) 60%
|
|
44
|
+
);
|
|
45
|
+
background-size: 300% 100%;
|
|
46
|
+
background-repeat: no-repeat;
|
|
47
|
+
background-clip: text;
|
|
48
|
+
-webkit-background-clip: text;
|
|
49
|
+
color: transparent;
|
|
50
|
+
animation: z-shimmer-sweep var(--z-shimmer-duration, 2s) linear infinite;
|
|
51
|
+
}
|
|
52
|
+
.z-shimmer-text-paused {
|
|
53
|
+
animation-play-state: paused;
|
|
54
|
+
}
|
|
55
|
+
@keyframes z-shimmer-sweep {
|
|
56
|
+
from {
|
|
57
|
+
background-position: 100% 0;
|
|
58
|
+
}
|
|
59
|
+
to {
|
|
60
|
+
background-position: 0% 0;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
@media (prefers-reduced-motion: reduce) {
|
|
64
|
+
.z-shimmer-text {
|
|
65
|
+
animation: none;
|
|
66
|
+
background-image: none;
|
|
67
|
+
color: var(--z-shimmer-base, var(--muted-foreground));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
</style>
|
|
@@ -8,6 +8,10 @@ interface Props {
|
|
|
8
8
|
zDuration?: number;
|
|
9
9
|
/** Hold the sweep: the text stays in its resting colour. */
|
|
10
10
|
zPaused?: boolean;
|
|
11
|
+
/** Resting colour of the text (any CSS colour; default the muted foreground). */
|
|
12
|
+
zBase?: string;
|
|
13
|
+
/** Colour of the sweeping highlight (default the foreground). */
|
|
14
|
+
zPeak?: string;
|
|
11
15
|
children?: Snippet;
|
|
12
16
|
}
|
|
13
17
|
declare const ZShimmerText: import("svelte").Component<Props, {}, "">;
|