@thedatagrid/docs-kit 0.2.2 → 0.3.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.
@@ -0,0 +1,533 @@
1
+ /**
2
+ * Tiny automation toolkit for a "scripted demo you can take over": a fake SVG
3
+ * cursor tweened over a LIVE component, with real state changes applied at
4
+ * each "click". Everything is cancellable through one AbortSignal, so a single
5
+ * real user interaction stops the show instantly and leaves the component
6
+ * exactly where the script brought it.
7
+ *
8
+ * Product-agnostic on purpose: no imports from any grid or app code.
9
+ */
10
+
11
+ /** Thrown by every helper when the script is aborted; callers swallow it. */
12
+ export class ScriptCancelled extends Error {
13
+ constructor() {
14
+ super('script cancelled');
15
+ this.name = 'ScriptCancelled';
16
+ }
17
+ }
18
+
19
+ export function assertActive(signal: AbortSignal) {
20
+ if (signal.aborted) throw new ScriptCancelled();
21
+ }
22
+
23
+ export function sleep(ms: number, signal: AbortSignal): Promise<void> {
24
+ assertActive(signal);
25
+ return new Promise((resolve, reject) => {
26
+ const id = window.setTimeout(() => {
27
+ signal.removeEventListener('abort', onAbort);
28
+ resolve();
29
+ }, ms);
30
+ const onAbort = () => {
31
+ window.clearTimeout(id);
32
+ reject(new ScriptCancelled());
33
+ };
34
+ signal.addEventListener('abort', onAbort, { once: true });
35
+ });
36
+ }
37
+
38
+ /** Poll until `get` returns a truthy value; null when it times out. */
39
+ export async function waitFor<T>(
40
+ get: () => T | null | undefined | false,
41
+ signal: AbortSignal,
42
+ {
43
+ timeout = 12000,
44
+ interval = 120,
45
+ }: { timeout?: number; interval?: number } = {},
46
+ ): Promise<T | null> {
47
+ const deadline = Date.now() + timeout;
48
+ for (;;) {
49
+ assertActive(signal);
50
+ const value = get();
51
+ if (value) return value;
52
+ if (Date.now() > deadline) return null;
53
+ await sleep(interval, signal);
54
+ }
55
+ }
56
+
57
+ export type Point = { x: number; y: number };
58
+
59
+ export const easeInOutCubic = (t: number) =>
60
+ t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;
61
+
62
+ /** Run `onFrame(easedT)` on every animation frame for `duration` ms. */
63
+ export function tween(
64
+ onFrame: (t: number) => void,
65
+ duration: number,
66
+ signal: AbortSignal,
67
+ ease: (t: number) => number = easeInOutCubic,
68
+ ): Promise<void> {
69
+ assertActive(signal);
70
+ return new Promise((resolve, reject) => {
71
+ const start = performance.now();
72
+ let raf = 0;
73
+ const onAbort = () => {
74
+ cancelAnimationFrame(raf);
75
+ reject(new ScriptCancelled());
76
+ };
77
+ signal.addEventListener('abort', onAbort, { once: true });
78
+ const frame = (now: number) => {
79
+ const t = Math.min(1, (now - start) / duration);
80
+ try {
81
+ onFrame(ease(t));
82
+ } catch (error) {
83
+ signal.removeEventListener('abort', onAbort);
84
+ reject(error);
85
+ return;
86
+ }
87
+ if (t >= 1) {
88
+ signal.removeEventListener('abort', onAbort);
89
+ resolve();
90
+ } else {
91
+ raf = requestAnimationFrame(frame);
92
+ }
93
+ };
94
+ raf = requestAnimationFrame(frame);
95
+ });
96
+ }
97
+
98
+ /**
99
+ * Inertial "fling": starts at `velocity` (px per ms) and decays exponentially,
100
+ * like a trackpad swipe released at speed. `apply` receives the delta for the
101
+ * frame and returns false to stop early (for example when an edge is hit).
102
+ * Resolves with the total distance travelled.
103
+ */
104
+ export function fling(
105
+ apply: (delta: number) => boolean | void,
106
+ {
107
+ velocity,
108
+ /** Fraction of velocity kept per 16.7ms frame. 0.95 ≈ a long glide. */
109
+ friction = 0.955,
110
+ minVelocity = 0.02,
111
+ maxDuration = 4000,
112
+ }: {
113
+ velocity: number;
114
+ friction?: number;
115
+ minVelocity?: number;
116
+ maxDuration?: number;
117
+ },
118
+ signal: AbortSignal,
119
+ ): Promise<number> {
120
+ assertActive(signal);
121
+ return new Promise((resolve, reject) => {
122
+ let v = velocity;
123
+ let last = performance.now();
124
+ const start = last;
125
+ let travelled = 0;
126
+ let raf = 0;
127
+ const onAbort = () => {
128
+ cancelAnimationFrame(raf);
129
+ reject(new ScriptCancelled());
130
+ };
131
+ signal.addEventListener('abort', onAbort, { once: true });
132
+ const done = () => {
133
+ signal.removeEventListener('abort', onAbort);
134
+ resolve(travelled);
135
+ };
136
+ const frame = (now: number) => {
137
+ const dt = Math.min(48, now - last);
138
+ last = now;
139
+ const delta = v * dt;
140
+ travelled += delta;
141
+ let keepGoing: boolean | void = true;
142
+ try {
143
+ keepGoing = apply(delta);
144
+ } catch (error) {
145
+ signal.removeEventListener('abort', onAbort);
146
+ reject(error);
147
+ return;
148
+ }
149
+ v *= Math.pow(friction, dt / 16.67);
150
+ if (
151
+ keepGoing === false ||
152
+ Math.abs(v) < minVelocity ||
153
+ now - start > maxDuration
154
+ ) {
155
+ done();
156
+ return;
157
+ }
158
+ raf = requestAnimationFrame(frame);
159
+ };
160
+ raf = requestAnimationFrame(frame);
161
+ });
162
+ }
163
+
164
+ const SYNTHETIC_POINTER_ID = 999;
165
+
166
+ function safeDispatch(el: EventTarget, event: Event) {
167
+ try {
168
+ el.dispatchEvent(event);
169
+ } catch {
170
+ // a hostile handler must not kill the script
171
+ }
172
+ }
173
+
174
+ function mouseInit(
175
+ clientX: number,
176
+ clientY: number,
177
+ extra: MouseEventInit = {},
178
+ ) {
179
+ return {
180
+ bubbles: true,
181
+ cancelable: true,
182
+ composed: true,
183
+ view: window,
184
+ clientX,
185
+ clientY,
186
+ ...extra,
187
+ } satisfies MouseEventInit;
188
+ }
189
+
190
+ function pointerEvent(
191
+ type: string,
192
+ clientX: number,
193
+ clientY: number,
194
+ extra: PointerEventInit = {},
195
+ ) {
196
+ return new PointerEvent(type, {
197
+ ...mouseInit(clientX, clientY),
198
+ pointerId: SYNTHETIC_POINTER_ID,
199
+ pointerType: 'mouse',
200
+ isPrimary: true,
201
+ ...extra,
202
+ });
203
+ }
204
+
205
+ /**
206
+ * Dispatch a full pointer+mouse sequence so whatever the target listens to
207
+ * (pointerdown, mousedown, click…) fires. Coordinates are real client-space
208
+ * coords, so `elementFromPoint`-style logic in handlers also works.
209
+ *
210
+ * Note: synthetic events have `isTrusted === false`; the takeover logic in
211
+ * AutomatedDemo relies on that to tell the script apart from the user.
212
+ */
213
+ export function dispatchClickSequence(
214
+ el: HTMLElement,
215
+ clientX: number,
216
+ clientY: number,
217
+ ) {
218
+ safeDispatch(el, pointerEvent('pointerover', clientX, clientY));
219
+ safeDispatch(
220
+ el,
221
+ pointerEvent('pointerenter', clientX, clientY, { bubbles: false }),
222
+ );
223
+ safeDispatch(el, new MouseEvent('mouseover', mouseInit(clientX, clientY)));
224
+ safeDispatch(
225
+ el,
226
+ pointerEvent('pointerdown', clientX, clientY, { button: 0, buttons: 1 }),
227
+ );
228
+ safeDispatch(
229
+ el,
230
+ new MouseEvent(
231
+ 'mousedown',
232
+ mouseInit(clientX, clientY, { button: 0, buttons: 1 }),
233
+ ),
234
+ );
235
+ safeDispatch(
236
+ el,
237
+ pointerEvent('pointerup', clientX, clientY, { button: 0, buttons: 0 }),
238
+ );
239
+ safeDispatch(
240
+ el,
241
+ new MouseEvent('mouseup', mouseInit(clientX, clientY, { button: 0 })),
242
+ );
243
+ safeDispatch(
244
+ el,
245
+ new MouseEvent(
246
+ 'click',
247
+ mouseInit(clientX, clientY, { button: 0, detail: 1 }),
248
+ ),
249
+ );
250
+ }
251
+
252
+ /** Fire hover events (pointerover/enter, mouseover/enter/move) on `el`. */
253
+ export function dispatchHover(
254
+ el: HTMLElement,
255
+ clientX: number,
256
+ clientY: number,
257
+ ) {
258
+ safeDispatch(el, pointerEvent('pointerover', clientX, clientY));
259
+ safeDispatch(
260
+ el,
261
+ pointerEvent('pointerenter', clientX, clientY, { bubbles: false }),
262
+ );
263
+ safeDispatch(el, new MouseEvent('mouseover', mouseInit(clientX, clientY)));
264
+ safeDispatch(
265
+ el,
266
+ new MouseEvent(
267
+ 'mouseenter',
268
+ mouseInit(clientX, clientY, { bubbles: false }),
269
+ ),
270
+ );
271
+ safeDispatch(el, pointerEvent('pointermove', clientX, clientY));
272
+ safeDispatch(el, new MouseEvent('mousemove', mouseInit(clientX, clientY)));
273
+ }
274
+
275
+ /**
276
+ * Synthetic pointer ids are unknown to the browser, so `setPointerCapture`
277
+ * throws for them. While a scripted drag runs, shadow it on the element
278
+ * instance (and restore it afterwards).
279
+ */
280
+ function shimPointerCapture(el: HTMLElement) {
281
+ const own = Object.prototype.hasOwnProperty.call(el, 'setPointerCapture');
282
+ const previous = own ? el.setPointerCapture : undefined;
283
+ const previousRelease = Object.prototype.hasOwnProperty.call(
284
+ el,
285
+ 'releasePointerCapture',
286
+ )
287
+ ? el.releasePointerCapture
288
+ : undefined;
289
+ el.setPointerCapture = () => {};
290
+ el.releasePointerCapture = () => {};
291
+ return () => {
292
+ if (previous) el.setPointerCapture = previous;
293
+ else delete (el as Partial<HTMLElement>).setPointerCapture;
294
+ if (previousRelease) el.releasePointerCapture = previousRelease;
295
+ else delete (el as Partial<HTMLElement>).releasePointerCapture;
296
+ };
297
+ }
298
+
299
+ /** Distance-based duration: constant perceived speed, clamped to sane bounds. */
300
+ function moveDuration(from: Point, to: Point, speed = 1) {
301
+ const distance = Math.hypot(to.x - from.x, to.y - from.y);
302
+ return Math.min(1100, Math.max(260, distance / 0.9)) / speed;
303
+ }
304
+
305
+ const CURSOR_HTML = `
306
+ <span class="showcase-cursor__ring"></span>
307
+ <svg class="showcase-cursor__arrow" width="26" height="30" viewBox="0 0 26 30" aria-hidden="true">
308
+ <path d="M2 1 L2 24 L8.4 18.6 L12.2 27.6 L16.6 25.7 L12.8 16.9 L20.5 16.6 Z"
309
+ fill="#14161c" stroke="#fff" stroke-width="1.6" stroke-linejoin="round" />
310
+ </svg>
311
+ <span class="showcase-cursor__label"></span>
312
+ `;
313
+
314
+ export type ScriptedCursor = ReturnType<typeof createScriptedCursor>;
315
+
316
+ /**
317
+ * The fake mouse: a cursor element inside a pointer-events-none overlay that
318
+ * covers the demo. Positions are in overlay-local coordinates; the arrow tip
319
+ * is the hotspot.
320
+ */
321
+ export function createScriptedCursor(overlay: HTMLElement) {
322
+ const el = document.createElement('div');
323
+ el.className = 'showcase-cursor';
324
+ el.innerHTML = CURSOR_HTML;
325
+ overlay.appendChild(el);
326
+ const label = el.querySelector<HTMLElement>('.showcase-cursor__label')!;
327
+
328
+ let pos: Point = {
329
+ x: overlay.clientWidth * 0.5,
330
+ y: overlay.clientHeight * 0.65,
331
+ };
332
+ const render = () => {
333
+ el.style.transform = `translate3d(${pos.x}px, ${pos.y}px, 0)`;
334
+ };
335
+ render();
336
+
337
+ const toLocal = (clientX: number, clientY: number): Point => {
338
+ const rect = overlay.getBoundingClientRect();
339
+ return { x: clientX - rect.left, y: clientY - rect.top };
340
+ };
341
+ const toClient = (p: Point): Point => {
342
+ const rect = overlay.getBoundingClientRect();
343
+ return { x: p.x + rect.left, y: p.y + rect.top };
344
+ };
345
+ const centerOf = (
346
+ target: HTMLElement,
347
+ offset: Partial<Point> = {},
348
+ ): Point => {
349
+ const rect = target.getBoundingClientRect();
350
+ return toLocal(
351
+ rect.left + rect.width / 2 + (offset.x ?? 0),
352
+ rect.top + rect.height / 2 + (offset.y ?? 0),
353
+ );
354
+ };
355
+
356
+ const cursor = {
357
+ element: el,
358
+ show() {
359
+ el.classList.add('is-visible');
360
+ },
361
+ hide() {
362
+ el.classList.remove('is-visible', 'is-pressed', 'is-clicking');
363
+ cursor.setLabel(null);
364
+ },
365
+ /** A small caption next to the cursor ("⇢ swipe", "1M rows"…); null hides it. */
366
+ setLabel(text: string | null) {
367
+ label.textContent = text ?? '';
368
+ el.classList.toggle('has-label', !!text);
369
+ },
370
+ /** Current hotspot position in client coordinates (for event dispatch). */
371
+ clientPoint(): Point {
372
+ return toClient(pos);
373
+ },
374
+ localPoint(): Point {
375
+ return { ...pos };
376
+ },
377
+
378
+ async moveTo(
379
+ target: Point,
380
+ signal: AbortSignal,
381
+ { speed = 1 }: { speed?: number } = {},
382
+ ) {
383
+ el.classList.add('is-visible');
384
+ const from = { ...pos };
385
+ await tween(
386
+ (t) => {
387
+ pos = {
388
+ x: from.x + (target.x - from.x) * t,
389
+ y: from.y + (target.y - from.y) * t,
390
+ };
391
+ render();
392
+ },
393
+ moveDuration(from, target, speed),
394
+ signal,
395
+ );
396
+ },
397
+
398
+ /**
399
+ * Move to an element's center (plus optional offset from center).
400
+ * Recomputes the rect at call time, so virtualized cells are fine as long
401
+ * as they exist when the move starts.
402
+ */
403
+ async moveToElement(
404
+ target: HTMLElement,
405
+ signal: AbortSignal,
406
+ offset: Partial<Point> = {},
407
+ options?: { speed?: number },
408
+ ) {
409
+ await cursor.moveTo(centerOf(target, offset), signal, options);
410
+ },
411
+
412
+ /** Move onto `target` and fire hover events on it (opens hover menus). */
413
+ async hover(
414
+ target: HTMLElement,
415
+ signal: AbortSignal,
416
+ offset: Partial<Point> = {},
417
+ ) {
418
+ await cursor.moveToElement(target, signal, offset);
419
+ const client = toClient(pos);
420
+ dispatchHover(target, client.x, client.y);
421
+ },
422
+
423
+ /**
424
+ * Play the click ripple; optionally dispatch a real event sequence on
425
+ * `target` at the current cursor position. Resolves after the press —
426
+ * the ripple keeps expanding while the script moves on.
427
+ */
428
+ async click(signal: AbortSignal, target?: HTMLElement | null) {
429
+ el.classList.remove('is-clicking');
430
+ // reflow so re-adding the class restarts the ripple animation
431
+ void el.offsetWidth;
432
+ el.classList.add('is-clicking');
433
+ await sleep(130, signal);
434
+ let restore: (() => void) | undefined;
435
+ if (target) {
436
+ const client = toClient(pos);
437
+ restore = shimPointerCapture(target);
438
+ dispatchClickSequence(target, client.x, client.y);
439
+ }
440
+ try {
441
+ await sleep(200, signal);
442
+ } finally {
443
+ // handlers often finish in a rAF that may still call setPointerCapture
444
+ restore?.();
445
+ el.classList.remove('is-clicking');
446
+ }
447
+ },
448
+
449
+ /**
450
+ * Press on `source`, drag to `to` (overlay-local) dispatching pointermove
451
+ * along the way, release. Events go to `source` (handlers that track a
452
+ * drag usually listen on the pressed element with pointer capture).
453
+ */
454
+ async drag(
455
+ source: HTMLElement,
456
+ to: Point,
457
+ signal: AbortSignal,
458
+ {
459
+ duration = 900,
460
+ steps = 36,
461
+ }: { duration?: number; steps?: number } = {},
462
+ ) {
463
+ await cursor.moveToElement(source, signal);
464
+ const restore = shimPointerCapture(source);
465
+ try {
466
+ const start = toClient(pos);
467
+ el.classList.add('is-pressed');
468
+ safeDispatch(
469
+ source,
470
+ pointerEvent('pointerdown', start.x, start.y, {
471
+ button: 0,
472
+ buttons: 1,
473
+ }),
474
+ );
475
+ safeDispatch(
476
+ source,
477
+ new MouseEvent(
478
+ 'mousedown',
479
+ mouseInit(start.x, start.y, { button: 0, buttons: 1 }),
480
+ ),
481
+ );
482
+ await sleep(160, signal);
483
+ const from = { ...pos };
484
+ let lastStep = -1;
485
+ await tween(
486
+ (t) => {
487
+ pos = {
488
+ x: from.x + (to.x - from.x) * t,
489
+ y: from.y + (to.y - from.y) * t,
490
+ };
491
+ render();
492
+ const step = Math.floor(t * steps);
493
+ if (step !== lastStep) {
494
+ lastStep = step;
495
+ const client = toClient(pos);
496
+ safeDispatch(
497
+ source,
498
+ pointerEvent('pointermove', client.x, client.y, { buttons: 1 }),
499
+ );
500
+ }
501
+ },
502
+ duration,
503
+ signal,
504
+ );
505
+ await sleep(140, signal);
506
+ const end = toClient(pos);
507
+ safeDispatch(
508
+ source,
509
+ pointerEvent('pointerup', end.x, end.y, { button: 0, buttons: 0 }),
510
+ );
511
+ safeDispatch(
512
+ source,
513
+ new MouseEvent('mouseup', mouseInit(end.x, end.y, { button: 0 })),
514
+ );
515
+ el.classList.remove('is-pressed');
516
+ // handlers commonly finish the drop in a rAF
517
+ await sleep(120, signal);
518
+ } finally {
519
+ el.classList.remove('is-pressed');
520
+ restore();
521
+ }
522
+ },
523
+
524
+ /** Convert an element's center to overlay-local coordinates. */
525
+ centerOf,
526
+
527
+ destroy() {
528
+ el.remove();
529
+ },
530
+ };
531
+
532
+ return cursor;
533
+ }
@@ -0,0 +1,174 @@
1
+ /*
2
+ * Styles for the product-agnostic showcase kit (scripted cursor, automated
3
+ * demo shell, lazy poster). Hosts theme it through these custom properties:
4
+ *
5
+ * --showcase-accent cursor click ripple, pill dot
6
+ * --showcase-pill-bg pill background
7
+ * --showcase-pill-fg pill text
8
+ * --showcase-pill-border pill border
9
+ * --showcase-z base z-index of the overlay layer
10
+ */
11
+
12
+ .showcase-demo {
13
+ position: relative;
14
+ height: 100%;
15
+ }
16
+
17
+ .showcase-demo__overlay {
18
+ position: absolute;
19
+ inset: 0;
20
+ z-index: calc(var(--showcase-z, 2000));
21
+ overflow: hidden;
22
+ pointer-events: none;
23
+ }
24
+
25
+ /* ---- the fake cursor ---------------------------------------------------- */
26
+
27
+ .showcase-cursor {
28
+ position: absolute;
29
+ left: 0;
30
+ top: 0;
31
+ opacity: 0;
32
+ pointer-events: none;
33
+ will-change: transform;
34
+ transition: opacity 350ms ease;
35
+ }
36
+ .showcase-cursor.is-visible {
37
+ opacity: 1;
38
+ }
39
+ .showcase-cursor__arrow {
40
+ display: block;
41
+ filter: drop-shadow(0 2px 5px rgb(0 0 0 / 0.35));
42
+ transform-origin: 4px 3px; /* the arrow tip */
43
+ transition: transform 130ms ease;
44
+ }
45
+ .showcase-cursor.is-clicking .showcase-cursor__arrow,
46
+ .showcase-cursor.is-pressed .showcase-cursor__arrow {
47
+ transform: scale(0.82);
48
+ }
49
+ .showcase-cursor__ring {
50
+ position: absolute;
51
+ left: -15px;
52
+ top: -14px;
53
+ width: 34px;
54
+ height: 34px;
55
+ border-radius: 50%;
56
+ background: var(--showcase-accent, #3b82f6);
57
+ opacity: 0;
58
+ transform: scale(0.3);
59
+ }
60
+ .showcase-cursor.is-clicking .showcase-cursor__ring {
61
+ animation: showcase-ripple 500ms ease-out;
62
+ }
63
+ .showcase-cursor.is-pressed .showcase-cursor__ring {
64
+ opacity: 0.35;
65
+ transform: scale(0.75);
66
+ transition: opacity 120ms ease, transform 120ms ease;
67
+ }
68
+ .showcase-cursor__label {
69
+ position: absolute;
70
+ left: 24px;
71
+ top: 22px;
72
+ white-space: nowrap;
73
+ padding: 3px 8px;
74
+ border-radius: 999px;
75
+ font: 500 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
76
+ color: var(--showcase-pill-fg, #e5e7eb);
77
+ background: var(--showcase-pill-bg, rgb(17 19 24 / 0.92));
78
+ border: 1px solid var(--showcase-pill-border, rgb(255 255 255 / 0.14));
79
+ opacity: 0;
80
+ transform: translateY(4px);
81
+ transition: opacity 200ms ease, transform 200ms ease;
82
+ }
83
+ .showcase-cursor.has-label .showcase-cursor__label {
84
+ opacity: 1;
85
+ transform: none;
86
+ }
87
+ @keyframes showcase-ripple {
88
+ 0% {
89
+ opacity: 0.4;
90
+ transform: scale(0.3);
91
+ }
92
+ 100% {
93
+ opacity: 0;
94
+ transform: scale(1.9);
95
+ }
96
+ }
97
+
98
+ /* ---- status pills ------------------------------------------------------- */
99
+
100
+ .showcase-pill {
101
+ position: absolute;
102
+ bottom: 12px;
103
+ left: 50%;
104
+ z-index: calc(var(--showcase-z, 2000) + 1);
105
+ transform: translateX(-50%);
106
+ display: inline-flex;
107
+ align-items: center;
108
+ gap: 8px;
109
+ padding: 6px 14px;
110
+ border-radius: 999px;
111
+ font: 500 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
112
+ white-space: nowrap;
113
+ color: var(--showcase-pill-fg, #e5e7eb);
114
+ background: var(--showcase-pill-bg, rgb(17 19 24 / 0.9));
115
+ border: 1px solid var(--showcase-pill-border, rgb(255 255 255 / 0.14));
116
+ box-shadow: 0 6px 24px rgb(0 0 0 / 0.35);
117
+ backdrop-filter: blur(8px);
118
+ }
119
+ .showcase-pill--running {
120
+ pointer-events: none;
121
+ }
122
+ .showcase-pill--user {
123
+ cursor: pointer;
124
+ transition: border-color 150ms ease, color 150ms ease;
125
+ }
126
+ .showcase-pill--user:hover {
127
+ border-color: var(--showcase-accent, #3b82f6);
128
+ }
129
+ .showcase-pill__dot {
130
+ width: 6px;
131
+ height: 6px;
132
+ border-radius: 50%;
133
+ background: var(--showcase-accent, #3b82f6);
134
+ animation: showcase-pulse 1.4s ease-in-out infinite;
135
+ }
136
+ @keyframes showcase-pulse {
137
+ 50% {
138
+ opacity: 0.35;
139
+ }
140
+ }
141
+
142
+ /* ---- lazy poster → live ------------------------------------------------- */
143
+
144
+ .showcase-lazy {
145
+ position: relative;
146
+ overflow: hidden;
147
+ }
148
+ .showcase-lazy__poster,
149
+ .showcase-lazy__live {
150
+ position: absolute;
151
+ inset: 0;
152
+ }
153
+ .showcase-lazy__poster {
154
+ transition: opacity 500ms ease;
155
+ }
156
+ .showcase-lazy__live {
157
+ opacity: 0;
158
+ transition: opacity 500ms ease;
159
+ }
160
+ .showcase-lazy[data-showcase-ready='true'] .showcase-lazy__live {
161
+ opacity: 1;
162
+ }
163
+ .showcase-lazy[data-showcase-ready='true'] .showcase-lazy__poster {
164
+ opacity: 0;
165
+ pointer-events: none;
166
+ }
167
+
168
+ @media (prefers-reduced-motion: reduce) {
169
+ .showcase-lazy__poster,
170
+ .showcase-lazy__live,
171
+ .showcase-cursor {
172
+ transition: none;
173
+ }
174
+ }