@plusguard/reels 0.0.0-stage → 1.4.1

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/index.css ADDED
@@ -0,0 +1,583 @@
1
+ /*
2
+ * reels — the CSS half: the strip that scrolls sideways, the 9:16 card, its
3
+ * clips one on another, the bars, the products. The look — corners,
4
+ * colours, the header over the card, the buttons — is the site's.
5
+ *
6
+ * Set on the section or above, per screen size with media queries:
7
+ * --pg-reels-show cards across the strip (default 4). A fraction
8
+ * shows part of the next: 1.5 on a phone is one
9
+ * card and half the next
10
+ * --pg-reels-gap between the cards (default 1rem)
11
+ * --pg-reels-ratio the card's shape (default 9 / 16)
12
+ * --pg-reels-duration a picture's time (default 5s)
13
+ * --pg-reels-seen all (default): a group is seen once all its
14
+ * clips have been shown in the full view · off
15
+ * --pg-reels-seen-for how long it stays seen (default 24h; 1h, 30m,
16
+ * 7d, forever)
17
+ * --pg-reels-panel the full view: the product panel's width on a
18
+ * computer (default: 9:16 of its height, as the
19
+ * video; 20rem to 30rem)
20
+ * --pg-reels-peek the full view: how much of the next group shows
21
+ * under the video on a computer (default 2rem)
22
+ * Written by the script on the full view:
23
+ * --pg-reels-band the band's height at a phone's foot, for a caption
24
+ * to stay above it (0 on a computer)
25
+ */
26
+
27
+ /* The strip: a row that scrolls sideways — a finger, a wheel, the arrows
28
+ — and stops with a card at its start. No bar to see. */
29
+ [data-pg-reels-strip] {
30
+ --show: var(--pg-reels-show, 4);
31
+ --gap: var(--pg-reels-gap, 1rem);
32
+ display: grid;
33
+ grid-auto-flow: column;
34
+ grid-auto-columns: calc((100% - var(--gap) * (var(--show) - 1)) / var(--show));
35
+ gap: var(--gap);
36
+ overflow-x: auto;
37
+ overscroll-behavior-x: contain;
38
+ scroll-snap-type: x mandatory;
39
+ scrollbar-width: none;
40
+ }
41
+ [data-pg-reels-strip]::-webkit-scrollbar {
42
+ display: none;
43
+ }
44
+ [data-pg-reels-group] {
45
+ display: flex;
46
+ flex-direction: column;
47
+ min-width: 0;
48
+ scroll-snap-align: start;
49
+ }
50
+
51
+ /* The card holds the shape — 9:16 by default — and its clips fill it, the
52
+ house way: the box has the shape, what is inside is 100% of it. */
53
+ [data-pg-reels-card] {
54
+ position: relative;
55
+ aspect-ratio: var(--pg-reels-ratio, 9 / 16);
56
+ display: flex;
57
+ flex-direction: column;
58
+ justify-content: center;
59
+ align-items: center;
60
+ overflow: hidden;
61
+ cursor: pointer;
62
+ }
63
+ [data-pg-reels-clip] {
64
+ position: absolute;
65
+ inset: 0;
66
+ margin: 0;
67
+ }
68
+ [data-pg-reels-card] [data-pg-reels-clip]:not([data-pg-reels-current]) {
69
+ visibility: hidden;
70
+ }
71
+ [data-pg-reels-clip] > video,
72
+ [data-pg-reels-clip] > img {
73
+ display: block;
74
+ width: 100%;
75
+ height: 100%;
76
+ object-fit: cover;
77
+ }
78
+
79
+ /* The bars: one a clip, side by side; the one playing fills with
80
+ --pg-reels-progress, those before it are full. Their look — height,
81
+ colours — the site's: here a plain line. */
82
+ [data-pg-reels-bars] {
83
+ display: flex;
84
+ gap: 0.25rem;
85
+ }
86
+ [data-pg-reels-bar],
87
+ [data-pg-reels-view-bar] {
88
+ flex: 1 1 0%;
89
+ min-width: 0;
90
+ height: 0.75rem;
91
+ padding: 0.3125rem 0;
92
+ border: 0;
93
+ background: none;
94
+ cursor: pointer;
95
+ }
96
+ [data-pg-reels-bar] > span,
97
+ [data-pg-reels-view-bar] > span {
98
+ display: block;
99
+ height: 100%;
100
+ border-radius: 999px;
101
+ background: linear-gradient(currentColor, currentColor) no-repeat left / calc(var(--pg-reels-progress, 0) * 100%) 100%, color-mix(in srgb, currentColor 25%, transparent);
102
+ }
103
+ [data-pg-reels-bar][data-pg-reels-done] > span,
104
+ [data-pg-reels-view-bar][data-pg-reels-done] > span {
105
+ background-size: 100% 100%;
106
+ }
107
+
108
+ /* A product's details are for the full view only. */
109
+ [data-pg-reels-detail] {
110
+ display: none !important;
111
+ }
112
+
113
+ /* The products: only the playing clip's shows. */
114
+ [data-pg-reels-group] [data-pg-reels-product]:not([data-pg-reels-current]) {
115
+ display: none !important;
116
+ }
117
+
118
+ /* ---------- The full view ----------
119
+ A <dialog> on <body>: the video in the middle, its ↑ ↓ beside it, the
120
+ product's panel on the right. On a phone the video fills the screen and
121
+ the product is a band at its foot, its details opened by a button. */
122
+
123
+ html:has(dialog[data-pg-reels-viewer][open]) {
124
+ overflow: hidden;
125
+ }
126
+ dialog[data-pg-reels-viewer] {
127
+ /* The panel 9:16, as the video: its width from its height — but at
128
+ most half the room beside the arrows, and 20rem to 30rem. */
129
+ --pg-reels-panel: clamp(20rem, min(calc((100dvh - 2rem) * 9 / 16), calc((100vw - 11rem) / 2)), 30rem);
130
+ --pg-reels-peek: 2rem;
131
+ position: fixed;
132
+ inset: 0;
133
+ width: 100%;
134
+ max-width: none;
135
+ height: 100dvh;
136
+ max-height: none;
137
+ margin: 0;
138
+ padding: 0;
139
+ border: 0;
140
+ background: rgb(0 0 0 / 0.92);
141
+ color: #fff;
142
+ outline: 0;
143
+ overflow: hidden;
144
+ overscroll-behavior: contain;
145
+ }
146
+ dialog[data-pg-reels-viewer]::backdrop {
147
+ background: transparent;
148
+ }
149
+ dialog[data-pg-reels-viewer] button {
150
+ font: inherit;
151
+ color: inherit;
152
+ }
153
+ dialog[data-pg-reels-viewer] svg {
154
+ display: block;
155
+ width: 1.25rem;
156
+ height: 1.25rem;
157
+ }
158
+
159
+ /* The video's height: the window's, less the top of the next group under
160
+ it (--pg-reels-peek) — and low enough to leave room for the panel. */
161
+ [data-pg-reels-stage] {
162
+ --gap: 1rem;
163
+ --h: min(calc(100dvh - 2 * var(--gap) - var(--pg-reels-peek)), 56rem, calc((100vw - var(--pg-reels-panel) - 11rem) * 16 / 9));
164
+ display: flex;
165
+ align-items: flex-start;
166
+ justify-content: center;
167
+ gap: 1.5rem;
168
+ height: 100%;
169
+ padding: var(--gap) 1.5rem 0;
170
+ box-sizing: border-box;
171
+ }
172
+
173
+ /* The video, the group before it out of sight above, the next one's top
174
+ under it: a feed that a finger drags, or the ↑ ↓ slide, by a video and
175
+ its gap. */
176
+ [data-pg-reels-feed] {
177
+ position: relative;
178
+ display: flex;
179
+ flex-direction: column;
180
+ gap: var(--gap);
181
+ flex: none;
182
+ touch-action: none;
183
+ }
184
+
185
+ /* The screen holds the shape — 9:16 — and the clip fills it. */
186
+ [data-pg-reels-screen] {
187
+ position: relative;
188
+ flex: none;
189
+ height: var(--h);
190
+ aspect-ratio: var(--pg-reels-ratio, 9 / 16);
191
+ border-radius: 0.75rem;
192
+ overflow: hidden;
193
+ background: #000;
194
+ isolation: isolate;
195
+ touch-action: none;
196
+ user-select: none;
197
+ -webkit-user-select: none;
198
+ }
199
+ [data-pg-reels-view-media] {
200
+ position: absolute;
201
+ inset: 0;
202
+ }
203
+ /* The clip passes presses to the taps under it, but for its own links
204
+ and buttons — a product's tag on it. */
205
+ [data-pg-reels-view-media] * {
206
+ -webkit-touch-callout: none;
207
+ pointer-events: none;
208
+ }
209
+ [data-pg-reels-view-media] :is(a, button) {
210
+ position: relative;
211
+ z-index: 3;
212
+ pointer-events: auto;
213
+ }
214
+
215
+ /* The groups above and under the video: their first clip, dimmed. The
216
+ one under it shows its top, and pressed is the next; the one above waits
217
+ out of sight. Dragged or sliding, both light up. */
218
+ [data-pg-reels-view-peek] {
219
+ position: relative;
220
+ flex: none;
221
+ width: 100%;
222
+ aspect-ratio: var(--pg-reels-ratio, 9 / 16);
223
+ padding: 0;
224
+ border: 0;
225
+ border-radius: 0.75rem;
226
+ overflow: hidden;
227
+ background: #000;
228
+ color: #fff;
229
+ opacity: 0.5;
230
+ cursor: pointer;
231
+ transition: opacity 0.2s;
232
+ }
233
+ [data-pg-reels-view-peek="before"] {
234
+ position: absolute;
235
+ left: 0;
236
+ right: 0;
237
+ bottom: calc(100% + var(--gap));
238
+ }
239
+ [data-pg-reels-view-peek]:hover,
240
+ [data-pg-reels-sliding] [data-pg-reels-view-peek] {
241
+ opacity: 1;
242
+ }
243
+ [data-pg-reels-view-peek][hidden] {
244
+ display: block;
245
+ visibility: hidden;
246
+ }
247
+ [data-pg-reels-view-peek] * {
248
+ pointer-events: none;
249
+ }
250
+ [data-pg-reels-view-peek] :is(video, img) {
251
+ display: block;
252
+ width: 100%;
253
+ height: 100%;
254
+ object-fit: cover;
255
+ }
256
+
257
+ /* A press on the left third: back; on the rest: on. */
258
+ [data-pg-reels-view-back],
259
+ [data-pg-reels-view-on] {
260
+ position: absolute;
261
+ top: 0;
262
+ bottom: 0;
263
+ margin: 0;
264
+ padding: 0;
265
+ border: 0;
266
+ background: none;
267
+ outline: 0;
268
+ cursor: pointer;
269
+ -webkit-tap-highlight-color: transparent;
270
+ }
271
+ [data-pg-reels-view-back] {
272
+ left: 0;
273
+ width: 30%;
274
+ }
275
+ [data-pg-reels-view-on] {
276
+ right: 0;
277
+ width: 70%;
278
+ }
279
+
280
+ [data-pg-reels-view-top] {
281
+ position: absolute;
282
+ inset: 0 0 auto;
283
+ padding: 0.75rem 0.75rem 2rem;
284
+ background: linear-gradient(rgb(0 0 0 / 0.45), transparent);
285
+ pointer-events: none;
286
+ transition: opacity 0.2s;
287
+ }
288
+ [data-pg-reels-view-top] > * > * {
289
+ pointer-events: auto;
290
+ }
291
+ [data-pg-reels-held] [data-pg-reels-view-top] {
292
+ opacity: 0;
293
+ }
294
+ [data-pg-reels-view-bars] {
295
+ display: flex;
296
+ gap: 0.25rem;
297
+ color: #fff;
298
+ }
299
+ [data-pg-reels-view-bars][hidden] {
300
+ display: none;
301
+ }
302
+ [data-pg-reels-view-row] {
303
+ display: flex;
304
+ align-items: flex-start;
305
+ justify-content: space-between;
306
+ gap: 0.5rem;
307
+ margin-top: 0.5rem;
308
+ pointer-events: none;
309
+ }
310
+ [data-pg-reels-view-head] {
311
+ min-width: 0;
312
+ }
313
+ /* The close at the top right, the sound and play / pause under it, the
314
+ group's view count on its left. Only the buttons take a press: the rest
315
+ of the corner is the video's. */
316
+ [data-pg-reels-view-row] > [data-pg-reels-view-tools] {
317
+ display: grid;
318
+ grid-template-columns: auto auto;
319
+ gap: 0.375rem;
320
+ pointer-events: none;
321
+ }
322
+ [data-pg-reels-view-tools] > button {
323
+ grid-column: 2;
324
+ pointer-events: auto;
325
+ }
326
+ [data-pg-reels-view-views] {
327
+ grid-column: 1;
328
+ grid-row: 1;
329
+ align-self: center;
330
+ }
331
+ [data-pg-reels-view-views]:empty {
332
+ display: none;
333
+ }
334
+ [data-pg-reels-view-tools] > button,
335
+ [data-pg-reels-view-steps] > button,
336
+ [data-pg-reels-panel-close] {
337
+ position: relative;
338
+ display: grid;
339
+ place-items: center;
340
+ width: 2.5rem;
341
+ height: 2.5rem;
342
+ padding: 0;
343
+ border: 0;
344
+ border-radius: 50%;
345
+ background: rgb(0 0 0 / 0.35);
346
+ cursor: pointer;
347
+ }
348
+ /* Each button its two pictures: sound off / on, pause / play. */
349
+ [data-pg-reels-viewer] [data-pg-reels-sound] > svg:last-child,
350
+ [data-pg-reels-viewer] [data-pg-reels-sound][aria-pressed="true"] > svg:first-child,
351
+ [data-pg-reels-view-play] > svg:last-child,
352
+ [data-pg-reels-paused] [data-pg-reels-view-play] > svg:first-child {
353
+ display: none;
354
+ }
355
+ [data-pg-reels-viewer] [data-pg-reels-sound][aria-pressed="true"] > svg:last-child,
356
+ [data-pg-reels-paused] [data-pg-reels-view-play] > svg:last-child {
357
+ display: block;
358
+ }
359
+
360
+ /* ↑ ↓: the group before, the next — beside the video's middle, round
361
+ and grey, their name beside them under the mouse. */
362
+ [data-pg-reels-view-steps] {
363
+ display: flex;
364
+ flex-direction: column;
365
+ gap: 1rem;
366
+ margin-top: calc(var(--h) / 2 - 4rem);
367
+ }
368
+ dialog[data-pg-reels-viewer] [data-pg-reels-view-steps] > button {
369
+ width: 3.5rem;
370
+ height: 3.5rem;
371
+ background: rgb(255 255 255 / 0.1);
372
+ transition: background-color 0.15s;
373
+ }
374
+ dialog[data-pg-reels-viewer] [data-pg-reels-view-steps] svg {
375
+ width: 1.5rem;
376
+ height: 1.5rem;
377
+ }
378
+ [data-pg-reels-view-steps] > button:not(:disabled):hover {
379
+ background: rgb(255 255 255 / 0.2);
380
+ }
381
+ [data-pg-reels-view-steps] > button:disabled {
382
+ opacity: 0.3;
383
+ cursor: default;
384
+ }
385
+ [data-pg-reels-view-steps] > button::after {
386
+ content: attr(aria-label);
387
+ position: absolute;
388
+ right: calc(100% + 0.75rem);
389
+ top: 50%;
390
+ translate: 0 -50%;
391
+ padding: 0.5rem 0.625rem;
392
+ border-radius: 0.25rem;
393
+ background: rgb(97 97 97 / 0.95);
394
+ color: #fff;
395
+ font-size: 0.75rem;
396
+ line-height: 1.2;
397
+ white-space: nowrap;
398
+ opacity: 0;
399
+ pointer-events: none;
400
+ transition: opacity 0.1s;
401
+ }
402
+ [data-pg-reels-view-steps] > button:not(:disabled):hover::after {
403
+ opacity: 1;
404
+ transition-delay: 0.4s;
405
+ }
406
+
407
+ /* The product: a panel from the video's top to the window's foot — a head with the product's
408
+ name (the template's data-pg-reels-title) and the close, a line under
409
+ it, the rest of the template under that, scrolling. A long name goes
410
+ onto a second line; the close stays at the top. */
411
+ [data-pg-reels-panel] {
412
+ position: relative;
413
+ z-index: 1;
414
+ display: flex;
415
+ flex-direction: column;
416
+ flex: none;
417
+ box-sizing: border-box;
418
+ width: var(--pg-reels-panel);
419
+ height: calc(100dvh - 2 * var(--gap));
420
+ border-radius: 0.75rem;
421
+ background: #fff;
422
+ color: #111;
423
+ overflow: hidden;
424
+ }
425
+ [data-pg-reels-no-product] [data-pg-reels-panel] {
426
+ visibility: hidden;
427
+ }
428
+ [data-pg-reels-panel-head] {
429
+ display: flex;
430
+ align-items: flex-start;
431
+ gap: 0.75rem;
432
+ flex: none;
433
+ padding: 0.875rem 0.875rem 0.875rem 1.25rem;
434
+ border-bottom: 1px solid color-mix(in srgb, currentColor 14%, transparent);
435
+ }
436
+ [data-pg-reels-panel-title] {
437
+ flex: 1 1 auto;
438
+ min-width: 0;
439
+ align-self: center;
440
+ }
441
+ dialog[data-pg-reels-viewer] [data-pg-reels-panel-close] {
442
+ flex: none;
443
+ background: color-mix(in srgb, currentColor 10%, transparent);
444
+ transition: background-color 0.15s;
445
+ }
446
+ dialog[data-pg-reels-viewer] [data-pg-reels-panel-close]:hover {
447
+ background: color-mix(in srgb, currentColor 18%, transparent);
448
+ }
449
+ dialog[data-pg-reels-viewer] [data-pg-reels-panel-close] svg {
450
+ width: 1.5rem;
451
+ height: 1.5rem;
452
+ }
453
+ [data-pg-reels-panel-detail] {
454
+ flex: 1 1 auto;
455
+ min-height: 0;
456
+ padding: 1.25rem;
457
+ overflow: auto;
458
+ overscroll-behavior: contain;
459
+ }
460
+ /* Variants: only the chosen one's gallery shows. */
461
+ [data-pg-reels-panel] [data-pg-reels-gallery]:not([data-pg-reels-current]) {
462
+ display: none;
463
+ }
464
+
465
+ /* The foot: the template's data-pg-reels-foot — the link to the product
466
+ — always in sight under what scrolls, a line above it. */
467
+ [data-pg-reels-panel-foot] {
468
+ flex: none;
469
+ padding: 1rem 1.25rem;
470
+ border-top: 1px solid color-mix(in srgb, currentColor 14%, transparent);
471
+ }
472
+ [data-pg-reels-panel-foot]:empty {
473
+ display: none;
474
+ }
475
+ [data-pg-reels-panel-band] {
476
+ display: none;
477
+ }
478
+
479
+ /* ---------- On a phone: the video fills the screen ----------
480
+ The groups above and under it wait out of sight, full size, for the
481
+ finger; the product is a band at the foot. */
482
+ @media (max-width: 47.99rem) {
483
+ [data-pg-reels-stage] {
484
+ display: block;
485
+ padding: 0;
486
+ }
487
+ [data-pg-reels-feed] {
488
+ position: absolute;
489
+ inset: 0;
490
+ --gap: 0px;
491
+ }
492
+ [data-pg-reels-screen] {
493
+ position: absolute;
494
+ inset: 0;
495
+ height: auto;
496
+ aspect-ratio: auto;
497
+ border-radius: 0;
498
+ }
499
+ [data-pg-reels-view-peek],
500
+ [data-pg-reels-view-peek="before"] {
501
+ position: absolute;
502
+ left: 0;
503
+ right: 0;
504
+ height: 100%;
505
+ aspect-ratio: auto;
506
+ border-radius: 0;
507
+ opacity: 1;
508
+ }
509
+ [data-pg-reels-view-peek="before"] {
510
+ bottom: 100%;
511
+ }
512
+ [data-pg-reels-view-peek="after"] {
513
+ top: 100%;
514
+ }
515
+ [data-pg-reels-view-top] {
516
+ padding-top: max(0.75rem, env(safe-area-inset-top));
517
+ }
518
+ [data-pg-reels-view-steps],
519
+ [data-pg-reels-panel-head] {
520
+ display: none;
521
+ }
522
+
523
+ /* The band at the foot: the product as on the card, and the button
524
+ that opens its details, above the band on the right. */
525
+ [data-pg-reels-panel] {
526
+ position: absolute;
527
+ inset: auto 0 0;
528
+ display: block;
529
+ width: auto;
530
+ height: auto;
531
+ padding: 0.75rem 1rem max(0.75rem, env(safe-area-inset-bottom));
532
+ border-radius: 1rem 1rem 0 0;
533
+ overflow: visible;
534
+ }
535
+ [data-pg-reels-no-product] [data-pg-reels-panel] {
536
+ display: none;
537
+ }
538
+ [data-pg-reels-panel-band] {
539
+ display: block;
540
+ position: relative;
541
+ }
542
+ [data-pg-reels-panel-toggle] {
543
+ position: absolute;
544
+ right: 0;
545
+ bottom: calc(100% + 1.25rem);
546
+ display: flex;
547
+ align-items: center;
548
+ gap: 0.25rem;
549
+ padding: 0.375rem 0.75rem;
550
+ border: 0;
551
+ border-radius: 999px;
552
+ background: rgb(0 0 0 / 0.55);
553
+ color: #fff !important;
554
+ font-size: 0.8125rem;
555
+ cursor: pointer;
556
+ }
557
+ [data-pg-reels-panel-toggle] svg {
558
+ width: 1rem;
559
+ height: 1rem;
560
+ transition: transform 0.2s;
561
+ }
562
+ [data-pg-reels-details] [data-pg-reels-panel-toggle] svg {
563
+ transform: rotate(180deg);
564
+ }
565
+ [data-pg-reels-panel-detail] {
566
+ display: none;
567
+ padding: 0;
568
+ }
569
+ [data-pg-reels-details] [data-pg-reels-panel-detail] {
570
+ display: block;
571
+ max-height: 55dvh;
572
+ margin-top: 0.75rem;
573
+ }
574
+ /* The foot: with the details only, under them. */
575
+ [data-pg-reels-panel-foot] {
576
+ display: none;
577
+ padding: 0.75rem 0 0;
578
+ border: 0;
579
+ }
580
+ [data-pg-reels-details] [data-pg-reels-panel-foot]:not(:empty) {
581
+ display: block;
582
+ }
583
+ }