@leavepulse/ui 0.20.0 → 0.20.2
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.
|
@@ -4,8 +4,8 @@ export interface UseSettledOptions {
|
|
|
4
4
|
delay?: MaybeRefOrGetter<number>;
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
|
-
* Returns a ref that flips true once `open` has been
|
|
8
|
-
* overlay's opening animation. Gate expensive content on it:
|
|
7
|
+
* Returns a ref that flips true once `open` has been truthy for the length of
|
|
8
|
+
* the overlay's opening animation. Gate expensive content on it:
|
|
9
9
|
*
|
|
10
10
|
* ```ts
|
|
11
11
|
* const settled = useSettled(() => isOpen.value)
|
|
@@ -15,7 +15,12 @@ export interface UseSettledOptions {
|
|
|
15
15
|
* <RowSkeletons v-else />
|
|
16
16
|
* ```
|
|
17
17
|
*
|
|
18
|
+
* Anything truthy counts as open, so an id can be passed instead of a boolean.
|
|
19
|
+
* That is the useful form when the same panel is reused for different subjects:
|
|
20
|
+
* the wait restarts when the id changes, because the panel is mounting a whole
|
|
21
|
+
* new body without ever having closed.
|
|
22
|
+
*
|
|
18
23
|
* With reduced motion there is no animation to protect, so it resolves on the
|
|
19
24
|
* next tick rather than making the user wait for a delay that buys nothing.
|
|
20
25
|
*/
|
|
21
|
-
export declare function useSettled(open: MaybeRefOrGetter<
|
|
26
|
+
export declare function useSettled(open: MaybeRefOrGetter<unknown>, options?: UseSettledOptions): import('vue').Ref<boolean, boolean>;
|
|
@@ -11,12 +11,13 @@ function useSettled(open, options = {}) {
|
|
|
11
11
|
}
|
|
12
12
|
watch(
|
|
13
13
|
() => toValue(open),
|
|
14
|
-
(
|
|
14
|
+
(value) => {
|
|
15
15
|
clear();
|
|
16
|
-
if (!
|
|
16
|
+
if (!value) {
|
|
17
17
|
settled.value = false;
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
|
+
settled.value = false;
|
|
20
21
|
const reduced = typeof window !== "undefined" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
21
22
|
const wait = reduced ? 0 : toValue(options.delay) ?? SETTLE_MS;
|
|
22
23
|
timer = setTimeout(() => {
|
package/package.json
CHANGED
|
@@ -28,8 +28,8 @@ export interface UseSettledOptions {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
* Returns a ref that flips true once `open` has been
|
|
32
|
-
* overlay's opening animation. Gate expensive content on it:
|
|
31
|
+
* Returns a ref that flips true once `open` has been truthy for the length of
|
|
32
|
+
* the overlay's opening animation. Gate expensive content on it:
|
|
33
33
|
*
|
|
34
34
|
* ```ts
|
|
35
35
|
* const settled = useSettled(() => isOpen.value)
|
|
@@ -39,11 +39,16 @@ export interface UseSettledOptions {
|
|
|
39
39
|
* <RowSkeletons v-else />
|
|
40
40
|
* ```
|
|
41
41
|
*
|
|
42
|
+
* Anything truthy counts as open, so an id can be passed instead of a boolean.
|
|
43
|
+
* That is the useful form when the same panel is reused for different subjects:
|
|
44
|
+
* the wait restarts when the id changes, because the panel is mounting a whole
|
|
45
|
+
* new body without ever having closed.
|
|
46
|
+
*
|
|
42
47
|
* With reduced motion there is no animation to protect, so it resolves on the
|
|
43
48
|
* next tick rather than making the user wait for a delay that buys nothing.
|
|
44
49
|
*/
|
|
45
50
|
export function useSettled(
|
|
46
|
-
open: MaybeRefOrGetter<
|
|
51
|
+
open: MaybeRefOrGetter<unknown>,
|
|
47
52
|
options: UseSettledOptions = {},
|
|
48
53
|
) {
|
|
49
54
|
const settled = ref(false)
|
|
@@ -58,12 +63,16 @@ export function useSettled(
|
|
|
58
63
|
|
|
59
64
|
watch(
|
|
60
65
|
() => toValue(open),
|
|
61
|
-
(
|
|
66
|
+
(value) => {
|
|
62
67
|
clear()
|
|
63
|
-
if (!
|
|
68
|
+
if (!value) {
|
|
64
69
|
settled.value = false
|
|
65
70
|
return
|
|
66
71
|
}
|
|
72
|
+
// Restarted on the value, not on open/closed: a panel handed a different
|
|
73
|
+
// id stays open while its whole body is replaced, and that second mount
|
|
74
|
+
// is as expensive as the first.
|
|
75
|
+
settled.value = false
|
|
67
76
|
const reduced =
|
|
68
77
|
typeof window !== "undefined" &&
|
|
69
78
|
window.matchMedia?.("(prefers-reduced-motion: reduce)").matches
|
package/src/tokens/tokens.css
CHANGED
|
@@ -320,6 +320,23 @@
|
|
|
320
320
|
}
|
|
321
321
|
}
|
|
322
322
|
|
|
323
|
+
/*
|
|
324
|
+
* Mirror of tree-row-in, for rows that arrive from the trailing edge: a list
|
|
325
|
+
* swapping placeholders for loaded content reads as the real rows sliding in
|
|
326
|
+
* over them rather than blinking into place. Stagger it per row the way
|
|
327
|
+
* OPTION_ITEM does, capping the delay so a long list still lands promptly.
|
|
328
|
+
*/
|
|
329
|
+
@keyframes row-in-trailing {
|
|
330
|
+
from {
|
|
331
|
+
opacity: 0;
|
|
332
|
+
transform: translateX(10px);
|
|
333
|
+
}
|
|
334
|
+
to {
|
|
335
|
+
opacity: 1;
|
|
336
|
+
transform: translateX(0);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
323
340
|
/*
|
|
324
341
|
* Lightbox. The image grows in from slightly under full size so opening reads as
|
|
325
342
|
* the picture coming toward you rather than a panel appearing; the exit is
|