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