@ruckc/truss-chart 1.54.1 → 1.55.0
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.
- package/dist/StatTile.svelte +19 -2
- package/package.json +1 -1
package/dist/StatTile.svelte
CHANGED
|
@@ -76,14 +76,16 @@
|
|
|
76
76
|
const cs = getComputedStyle(valueEl!);
|
|
77
77
|
const dur = toMs(cs.getPropertyValue('--_load')) * Number(cs.getPropertyValue('--tr-motion-distance'));
|
|
78
78
|
if (!(dur > 0)) return;
|
|
79
|
+
// the stagger (#294): the count-up waits for the tile's rise to start (the tile's animation-delay, 0s unless a theme staggers)
|
|
80
|
+
const delay = toMs(getComputedStyle(valueEl!.closest('.tile')!).animationDelay);
|
|
79
81
|
const to = value;
|
|
80
82
|
const fmt = format ?? fmtValue;
|
|
81
83
|
const dec = (String(to).split('.')[1] ?? '').length;
|
|
82
84
|
let clock: Animation;
|
|
83
85
|
try {
|
|
84
|
-
clock = valueEl!.animate(null, { duration: dur, easing: cs.getPropertyValue('--_load-ease').trim() });
|
|
86
|
+
clock = valueEl!.animate(null, { duration: dur, delay, fill: 'backwards', easing: cs.getPropertyValue('--_load-ease').trim() });
|
|
85
87
|
} catch {
|
|
86
|
-
clock = valueEl!.animate(null, { duration: dur, easing: 'ease-out' }); // an easing the Web Animations API does not take
|
|
88
|
+
clock = valueEl!.animate(null, { duration: dur, delay, fill: 'backwards', easing: 'ease-out' }); // an easing the Web Animations API does not take
|
|
87
89
|
}
|
|
88
90
|
let raf = 0;
|
|
89
91
|
const step = () => {
|
|
@@ -131,10 +133,25 @@
|
|
|
131
133
|
|
|
132
134
|
<style>
|
|
133
135
|
.host { display: contents; }
|
|
136
|
+
/* the opt-in stagger (#294): a tile's place among its siblings (capped at the 8th) times --tr-stagger-step delays its rise and count-up */
|
|
137
|
+
.host:nth-child(2) { --_i: 1; }
|
|
138
|
+
.host:nth-child(3) { --_i: 2; }
|
|
139
|
+
.host:nth-child(4) { --_i: 3; }
|
|
140
|
+
.host:nth-child(5) { --_i: 4; }
|
|
141
|
+
.host:nth-child(6) { --_i: 5; }
|
|
142
|
+
.host:nth-child(7) { --_i: 6; }
|
|
143
|
+
.host:nth-child(n + 8) { --_i: 7; }
|
|
134
144
|
.host.auto { display: block; container-type: inline-size; height: 100%; min-width: 0; }
|
|
135
145
|
.auto .tile { box-sizing: border-box; height: 100%; padding: clamp(8px, 4cqi, 20px) clamp(12px, 5cqi, 24px); gap: clamp(2px, 1.5cqi, 8px); }
|
|
136
146
|
.auto .value { font-size: var(--trc-stat-value-size, clamp(20px, 11cqi, 56px)); }
|
|
137
147
|
.tile { display: flex; flex-direction: column; gap: 4px; padding: 12px 16px; background: var(--tr-stat-tile-bg, var(--tr-surface-container-low)); border: 1px solid var(--tr-stat-tile-border-color, var(--tr-outline-variant)); border-radius: var(--tr-radius-card, var(--tr-radius-md)); box-shadow: var(--tr-stat-tile-shadow, none); color: var(--tr-on-surface); font-family: var(--tr-font-sans); }
|
|
148
|
+
/* the opt-in entry rise (--tr-rise-dur, 0s unless a theme sets it): a fade and a short rise that always ends on the tile at rest; none
|
|
149
|
+
under reduced motion (× --tr-motion-distance), and none inside a container that rises itself (a Dashboard widget) */
|
|
150
|
+
.tile {
|
|
151
|
+
animation: tr-stat-rise calc(var(--tr-rise-dur, 0s) * var(--tr-motion-distance)) var(--tr-load-ease, var(--tr-ease)) calc(var(--tr-stagger-step, 0s) * var(--_i, 0) * var(--tr-motion-distance)) backwards;
|
|
152
|
+
}
|
|
153
|
+
:global([data-tr-rise]) .tile { animation-name: none; }
|
|
154
|
+
@keyframes tr-stat-rise { from { opacity: 0; translate: 0 calc(14px * var(--tr-motion-distance)); } }
|
|
138
155
|
.tile.featured {
|
|
139
156
|
background-color: var(--tr-stat-featured-bg, var(--tr-primary-container)); background-image: var(--tr-stat-featured-image, none);
|
|
140
157
|
border-color: var(--tr-stat-featured-border-color, transparent); box-shadow: var(--tr-stat-featured-shadow, none); color: var(--tr-stat-featured-color, var(--tr-on-primary-container));
|