@plusguard/reels 1.6.0 → 1.7.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/README.md CHANGED
@@ -23,9 +23,9 @@ From npm, through jsDelivr — the npm package is the code alone (about
23
23
  jsDelivr's GitHub route.
24
24
 
25
25
  ```html
26
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@plusguard/reels@1.6.0/index.css" />
26
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@plusguard/reels@1.7.0/index.css" />
27
27
  <script type="module">
28
- import { initReels } from "https://cdn.jsdelivr.net/npm/@plusguard/reels@1.6.0/dist/index.js";
28
+ import { initReels } from "https://cdn.jsdelivr.net/npm/@plusguard/reels@1.7.0/dist/index.js";
29
29
  initReels();
30
30
  </script>
31
31
  ```
@@ -158,22 +158,24 @@ in it, copies of the site's markup: the clip, the group's
158
158
  links; the rest of the clip passes presses to the taps under it.
159
159
  - **Held down** — a finger, the mouse — it stands still, the controls
160
160
  out of the way; let go and it goes on. Its play / pause button, Space.
161
- - **Its corner:** the close at the top right, the sound and play / pause
162
- under it; on the close's left the group's view count — the card's
163
- `data-pg-reels-views` element, copied, so it looks as in the card. The
164
- number is the site's (from its own counting); the package shows it.
161
+ - **Its corner:** the sound and play / pause at the video's top right,
162
+ the group's view count under them — the card's `data-pg-reels-views`
163
+ element, copied, so it looks as in the card. The number is the site's
164
+ (from its own counting); the package shows it. The close is a plain ✕ at
165
+ the window's top right, the ↑ ↓ at the window's left.
165
166
  - **The product:** on a computer, a panel beside the video, touching it
166
- as a post opened on Instagram (no corners where they meet), from its top
167
- to the window's foot, 9:16 like it: a head — the template's
168
- `data-pg-reels-title`, moved there, and the close; a long name takes a
169
- second line, the close stays at the top — a line under it; at the
167
+ as a post opened on Instagram (no corners where they meet, small ones
168
+ outside), from its top to the window's foot, about a third of the
169
+ window wide: a head — the template's `data-pg-reels-title`, moved there
170
+ (the example puts the category there) — a line under it; at the
170
171
  bottom a foot — the template's `data-pg-reels-foot`, the link to the
171
172
  product, always in sight; and between them the rest of the template,
172
173
  scrolling.
173
174
  The template is the product's `data-pg-reels-detail`, the site's markup: a
174
175
  `data-pg-reels-thumb` pressed puts its picture (the attribute's value, or
175
176
  its own `<img>`) into `data-pg-reels-big`, and is
176
- `data-pg-reels-current`. On a phone the video fills the screen; the
177
+ `data-pg-reels-current`. Below 1024px (Tailwind's `lg`) — a phone, a
178
+ tablet, a narrow window — the video fills the screen; the
177
179
  product, as on the card, is a band at its foot, and a Details button
178
180
  above the band's right opens the template under it. A clip without a
179
181
  product: no panel.
@@ -212,7 +214,7 @@ in it, copies of the site's markup: the clip, the group's
212
214
  | `--pg-reels-gap` | `1rem` | Between the cards |
213
215
  | `--pg-reels-ratio` | `9 / 16` | The card's shape |
214
216
  | `--pg-reels-duration` | `5s` | A picture's time |
215
- | `--pg-reels-panel` | 9:16 of its height, 20–30rem | The full view: the product panel's width on a computer |
217
+ | `--pg-reels-panel` | `30vw`, 21–31rem | The full view: the product panel's width on a computer |
216
218
  | `--pg-reels-seen` | `all` | `all`: a group is seen once all its clips have been shown in the full view · `off`: never |
217
219
  | `--pg-reels-seen-for` | `24h` | How long a group stays seen — `1h`, `30m`, `7d`, `forever` — then its ring is bright again |
218
220
  | `--pg-reels-peek` | `2rem` | The full view: how much of the next group shows under the video on a computer |
@@ -238,7 +240,7 @@ and videos: the box has the shape, what is inside is 100% of it.
238
240
  | `data-pg-reels-bars` | under the card, empty | Its bars are written here, one a clip |
239
241
  | `data-pg-reels-product` | one a clip | The clip's product |
240
242
  | `data-pg-reels-detail` | a `<template>` in a product — or any element, hidden, in the product or the clip | Its details, for the full view |
241
- | `data-pg-reels-title` | in the template | The product's name: shown in the panel's head, beside the close — short; the size or weight is better on a line below |
243
+ | `data-pg-reels-title` | in the template | What heads the panel — the category in the example; the product's name under the price |
242
244
  | `data-pg-reels-foot` | in the template | The link to the product: pinned to the panel's foot; on a phone, under the opened details |
243
245
  | `data-pg-reels-variant`, `-variant-price`, `-variant-href` | buttons in the template | A variant: chosen, its gallery, price and link |
244
246
  | `data-pg-reels-gallery` | in the template | A variant's pictures: shown while its variant is chosen |
package/dist/index.js CHANGED
@@ -54,10 +54,10 @@
54
54
  * goes on or back — its ↑ and ↓ buttons, a wheel, ↑ and ↓; after a
55
55
  * group's last clip, the next group. The product changes once it has
56
56
  * landed. Held
57
- * down — a finger, the mouse — it stands still; its own play / pause, its
58
- * sound, its close — under the close; left of it, the group's view count
59
- * (its data-pg-reels-views, the site's). Esc, Back, the dark around it
60
- * close it too. The
57
+ * down — a finger, the mouse — it stands still; its sound and play /
58
+ * pause at the video's top right, the group's view count under them (its
59
+ * data-pg-reels-views, the site's); its close at the window's top right.
60
+ * Esc, Back, the dark around it close it too. The
61
61
  * product: on a computer a panel beside the video — the product's
62
62
  * <template data-pg-reels-detail>, the site's markup: a title (its
63
63
  * data-pg-reels-title goes to the panel's head, beside the close), a big
@@ -596,6 +596,7 @@ export function initReels() {
596
596
  // keys work at once, no ring on a button nobody chose.
597
597
  dialog.tabIndex = -1;
598
598
  dialog.innerHTML = `
599
+ <button type="button" data-pg-reels-view-close aria-label="Close">${svg(ICONS.close)}</button>
599
600
  <div data-pg-reels-stage>
600
601
  <div data-pg-reels-view-steps>
601
602
  <button type="button" data-pg-reels-view-up aria-label="Previous reel">${svg(ICONS.up)}</button>
@@ -615,10 +616,9 @@ export function initReels() {
615
616
  <div data-pg-reels-view-row>
616
617
  <div data-pg-reels-view-head></div>
617
618
  <div data-pg-reels-view-tools>
618
- <div data-pg-reels-view-views></div>
619
- <button type="button" data-pg-reels-view-close aria-label="Close">${svg(ICONS.close)}</button>
620
619
  <button type="button" ${SOUND} aria-pressed="false" aria-label="Sound">${svg(ICONS.soundOff)}${svg(ICONS.soundOn)}</button>
621
620
  <button type="button" data-pg-reels-view-play aria-label="Pause">${svg(ICONS.pause)}${svg(ICONS.play)}</button>
621
+ <div data-pg-reels-view-views></div>
622
622
  </div>
623
623
  </div>
624
624
  </div>
@@ -629,7 +629,6 @@ export function initReels() {
629
629
  <aside data-pg-reels-panel>
630
630
  <div data-pg-reels-panel-head>
631
631
  <div data-pg-reels-panel-title></div>
632
- <button type="button" data-pg-reels-panel-close aria-label="Close">${svg(ICONS.close)}</button>
633
632
  </div>
634
633
  <div data-pg-reels-panel-band>
635
634
  <div data-pg-reels-panel-summary></div>
@@ -980,7 +979,7 @@ export function initReels() {
980
979
  // The dark around it.
981
980
  if (t === dialog || t.hasAttribute("data-pg-reels-stage"))
982
981
  return closeView();
983
- if (t.closest("[data-pg-reels-view-close], [data-pg-reels-panel-close]"))
982
+ if (t.closest("[data-pg-reels-view-close]"))
984
983
  return closeView();
985
984
  if (sliding)
986
985
  return;
package/index.css CHANGED
@@ -126,7 +126,8 @@ html:has(dialog[data-pg-reels-viewer][open]) {
126
126
  dialog[data-pg-reels-viewer] {
127
127
  /* The panel 9:16, as the video: its width from its height — but at
128
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 - 14rem) / 2)), 30rem);
129
+ /* The panel as on Instagram: a third of the window, 21rem to 31rem. */
130
+ --pg-reels-panel: clamp(21rem, 30vw, 31rem);
130
131
  --pg-reels-peek: 2rem;
131
132
  position: fixed;
132
133
  inset: 0;
@@ -160,13 +161,15 @@ dialog[data-pg-reels-viewer] svg {
160
161
  it (--pg-reels-peek) — and low enough to leave room for the panel. */
161
162
  [data-pg-reels-stage] {
162
163
  --gap: 1rem;
163
- --h: min(calc(100dvh - 2 * var(--gap) - var(--pg-reels-peek)), 56rem, calc((100vw - var(--pg-reels-panel) - 14rem) * 16 / 9));
164
+ --h: min(calc(100dvh - 2 * var(--gap) - var(--pg-reels-peek)), 56rem, calc((100vw - var(--pg-reels-panel) - 15rem) * 16 / 9));
165
+ position: relative;
164
166
  display: flex;
165
167
  align-items: flex-start;
166
168
  justify-content: center;
167
- gap: 1.5rem;
168
169
  height: 100%;
169
- padding: var(--gap) 1.5rem 0;
170
+ /* Room at the sides: the ↑ ↓ at the window's left, the close at its
171
+ right. */
172
+ padding: var(--gap) 5rem 0;
170
173
  box-sizing: border-box;
171
174
  }
172
175
 
@@ -221,7 +224,7 @@ dialog[data-pg-reels-viewer] [data-pg-reels-view-side] svg {
221
224
  }
222
225
  /* Where they touch, no corners: the video's and the next one's right,
223
226
  the panel's left. */
224
- @media (min-width: 48rem) {
227
+ @media (min-width: 64rem) {
225
228
  [data-pg-reels-pair] [data-pg-reels-screen],
226
229
  [data-pg-reels-pair] [data-pg-reels-view-peek] {
227
230
  border-top-right-radius: 0;
@@ -251,7 +254,7 @@ dialog[data-pg-reels-viewer] [data-pg-reels-view-side] svg {
251
254
  flex: none;
252
255
  height: var(--h);
253
256
  aspect-ratio: var(--pg-reels-ratio, 9 / 16);
254
- border-radius: 0.75rem;
257
+ border-radius: 0.25rem;
255
258
  overflow: hidden;
256
259
  background: #000;
257
260
  isolation: isolate;
@@ -285,7 +288,7 @@ dialog[data-pg-reels-viewer] [data-pg-reels-view-side] svg {
285
288
  aspect-ratio: var(--pg-reels-ratio, 9 / 16);
286
289
  padding: 0;
287
290
  border: 0;
288
- border-radius: 0.75rem;
291
+ border-radius: 0.25rem;
289
292
  overflow: hidden;
290
293
  background: #000;
291
294
  color: #fff;
@@ -373,9 +376,9 @@ dialog[data-pg-reels-viewer] [data-pg-reels-view-side] svg {
373
376
  [data-pg-reels-view-head] {
374
377
  min-width: 0;
375
378
  }
376
- /* The close at the top right, the sound and play / pause under it, the
377
- group's view count on its left. Only the buttons take a press: the rest
378
- of the corner is the video's. */
379
+ /* The video's top right: the sound and play / pause, the group's view
380
+ count under them. Only the buttons take a press: the rest of the corner
381
+ is the video's. */
379
382
  [data-pg-reels-view-row] > [data-pg-reels-view-tools] {
380
383
  display: grid;
381
384
  grid-template-columns: auto auto;
@@ -383,20 +386,17 @@ dialog[data-pg-reels-viewer] [data-pg-reels-view-side] svg {
383
386
  pointer-events: none;
384
387
  }
385
388
  [data-pg-reels-view-tools] > button {
386
- grid-column: 2;
387
389
  pointer-events: auto;
388
390
  }
389
391
  [data-pg-reels-view-views] {
390
- grid-column: 1;
391
- grid-row: 1;
392
- align-self: center;
392
+ grid-column: 1 / -1;
393
+ justify-self: end;
393
394
  }
394
395
  [data-pg-reels-view-views]:empty {
395
396
  display: none;
396
397
  }
397
398
  [data-pg-reels-view-tools] > button,
398
- [data-pg-reels-view-steps] > button,
399
- [data-pg-reels-panel-close] {
399
+ [data-pg-reels-view-steps] > button {
400
400
  position: relative;
401
401
  display: grid;
402
402
  place-items: center;
@@ -423,10 +423,39 @@ dialog[data-pg-reels-viewer] [data-pg-reels-view-side] svg {
423
423
  /* ↑ ↓: the group before, the next — left of the video, at its middle,
424
424
  round and grey, their name beside them under the mouse. */
425
425
  [data-pg-reels-view-steps] {
426
+ position: absolute;
427
+ left: 1.25rem;
428
+ top: calc(var(--gap) + var(--h) / 2);
429
+ translate: 0 -50%;
426
430
  display: flex;
427
431
  flex-direction: column;
428
432
  gap: 1rem;
429
- margin-top: calc(var(--h) / 2 - 4rem);
433
+ }
434
+
435
+ /* The close: the window's top right, a plain ✕ as on Instagram. */
436
+ dialog[data-pg-reels-viewer] [data-pg-reels-view-close] {
437
+ position: absolute;
438
+ z-index: 3;
439
+ top: 0.75rem;
440
+ right: 0.75rem;
441
+ display: grid;
442
+ place-items: center;
443
+ width: 2.75rem;
444
+ height: 2.75rem;
445
+ padding: 0;
446
+ border: 0;
447
+ border-radius: 50%;
448
+ background: none;
449
+ color: #fff;
450
+ cursor: pointer;
451
+ transition: background-color 0.15s;
452
+ }
453
+ dialog[data-pg-reels-viewer] [data-pg-reels-view-close]:hover {
454
+ background: rgb(255 255 255 / 0.12);
455
+ }
456
+ dialog[data-pg-reels-viewer] [data-pg-reels-view-close] svg {
457
+ width: 1.75rem;
458
+ height: 1.75rem;
430
459
  }
431
460
  dialog[data-pg-reels-viewer] [data-pg-reels-view-steps] > button {
432
461
  width: 3.5rem;
@@ -480,7 +509,7 @@ dialog[data-pg-reels-viewer] [data-pg-reels-view-steps] svg {
480
509
  box-sizing: border-box;
481
510
  width: var(--pg-reels-panel);
482
511
  height: calc(100dvh - 2 * var(--gap));
483
- border-radius: 0.75rem;
512
+ border-radius: 0.25rem;
484
513
  background: #fff;
485
514
  color: #111;
486
515
  overflow: hidden;
@@ -493,25 +522,14 @@ dialog[data-pg-reels-viewer] [data-pg-reels-view-steps] svg {
493
522
  align-items: flex-start;
494
523
  gap: 0.75rem;
495
524
  flex: none;
496
- padding: 0.875rem 0.875rem 0.875rem 1.25rem;
525
+ padding: 1rem 1.25rem;
497
526
  border-bottom: 1px solid color-mix(in srgb, currentColor 14%, transparent);
498
527
  }
499
528
  [data-pg-reels-panel-title] {
500
529
  flex: 1 1 auto;
501
530
  min-width: 0;
502
531
  align-self: center;
503
- }
504
- dialog[data-pg-reels-viewer] [data-pg-reels-panel-close] {
505
- flex: none;
506
- background: color-mix(in srgb, currentColor 10%, transparent);
507
- transition: background-color 0.15s;
508
- }
509
- dialog[data-pg-reels-viewer] [data-pg-reels-panel-close]:hover {
510
- background: color-mix(in srgb, currentColor 18%, transparent);
511
- }
512
- dialog[data-pg-reels-viewer] [data-pg-reels-panel-close] svg {
513
- width: 1.5rem;
514
- height: 1.5rem;
532
+ min-height: 1.5rem;
515
533
  }
516
534
  [data-pg-reels-panel-detail] {
517
535
  flex: 1 1 auto;
@@ -539,14 +557,23 @@ dialog[data-pg-reels-viewer] [data-pg-reels-panel-close] svg {
539
557
  display: none;
540
558
  }
541
559
 
542
- /* ---------- On a phone: the video fills the screen ----------
543
- The groups above and under it wait out of sight, full size, for the
544
- finger; the product is a band at the foot. */
545
- @media (max-width: 47.99rem) {
560
+ /* ---------- Below 1024px (Tailwind's lg): the video fills the screen ----------
561
+ A phone, a tablet, a narrow window. The groups above and under it wait
562
+ out of sight, full size, for the finger; the product is a band at the
563
+ foot, its content centred and no wider than 40rem. */
564
+ @media (max-width: 63.99rem) {
546
565
  [data-pg-reels-stage] {
547
566
  display: block;
548
567
  padding: 0;
549
568
  }
569
+ /* The close over the video's top right; the sound and pause beside it. */
570
+ dialog[data-pg-reels-viewer] [data-pg-reels-view-close] {
571
+ top: max(0.5rem, env(safe-area-inset-top));
572
+ right: 0.375rem;
573
+ }
574
+ [data-pg-reels-view-row] > [data-pg-reels-view-tools] {
575
+ margin-right: 2.75rem;
576
+ }
550
577
  [data-pg-reels-pair] {
551
578
  display: contents;
552
579
  }
@@ -607,6 +634,10 @@ dialog[data-pg-reels-viewer] [data-pg-reels-panel-close] svg {
607
634
  [data-pg-reels-no-product] [data-pg-reels-panel] {
608
635
  display: none;
609
636
  }
637
+ [data-pg-reels-panel] > * {
638
+ max-width: 40rem;
639
+ margin-inline: auto;
640
+ }
610
641
  [data-pg-reels-panel-band] {
611
642
  display: block;
612
643
  position: relative;
package/index.ts CHANGED
@@ -54,10 +54,10 @@
54
54
  * goes on or back — its ↑ and ↓ buttons, a wheel, ↑ and ↓; after a
55
55
  * group's last clip, the next group. The product changes once it has
56
56
  * landed. Held
57
- * down — a finger, the mouse — it stands still; its own play / pause, its
58
- * sound, its close — under the close; left of it, the group's view count
59
- * (its data-pg-reels-views, the site's). Esc, Back, the dark around it
60
- * close it too. The
57
+ * down — a finger, the mouse — it stands still; its sound and play /
58
+ * pause at the video's top right, the group's view count under them (its
59
+ * data-pg-reels-views, the site's); its close at the window's top right.
60
+ * Esc, Back, the dark around it close it too. The
61
61
  * product: on a computer a panel beside the video — the product's
62
62
  * <template data-pg-reels-detail>, the site's markup: a title (its
63
63
  * data-pg-reels-title goes to the panel's head, beside the close), a big
@@ -614,6 +614,7 @@ export function initReels(): () => void {
614
614
  // keys work at once, no ring on a button nobody chose.
615
615
  dialog.tabIndex = -1;
616
616
  dialog.innerHTML = `
617
+ <button type="button" data-pg-reels-view-close aria-label="Close">${svg(ICONS.close)}</button>
617
618
  <div data-pg-reels-stage>
618
619
  <div data-pg-reels-view-steps>
619
620
  <button type="button" data-pg-reels-view-up aria-label="Previous reel">${svg(ICONS.up)}</button>
@@ -633,10 +634,9 @@ export function initReels(): () => void {
633
634
  <div data-pg-reels-view-row>
634
635
  <div data-pg-reels-view-head></div>
635
636
  <div data-pg-reels-view-tools>
636
- <div data-pg-reels-view-views></div>
637
- <button type="button" data-pg-reels-view-close aria-label="Close">${svg(ICONS.close)}</button>
638
637
  <button type="button" ${SOUND} aria-pressed="false" aria-label="Sound">${svg(ICONS.soundOff)}${svg(ICONS.soundOn)}</button>
639
638
  <button type="button" data-pg-reels-view-play aria-label="Pause">${svg(ICONS.pause)}${svg(ICONS.play)}</button>
639
+ <div data-pg-reels-view-views></div>
640
640
  </div>
641
641
  </div>
642
642
  </div>
@@ -647,7 +647,6 @@ export function initReels(): () => void {
647
647
  <aside data-pg-reels-panel>
648
648
  <div data-pg-reels-panel-head>
649
649
  <div data-pg-reels-panel-title></div>
650
- <button type="button" data-pg-reels-panel-close aria-label="Close">${svg(ICONS.close)}</button>
651
650
  </div>
652
651
  <div data-pg-reels-panel-band>
653
652
  <div data-pg-reels-panel-summary></div>
@@ -989,7 +988,7 @@ export function initReels(): () => void {
989
988
  }
990
989
  // The dark around it.
991
990
  if (t === dialog || t.hasAttribute("data-pg-reels-stage")) return closeView();
992
- if (t.closest("[data-pg-reels-view-close], [data-pg-reels-panel-close]")) return closeView();
991
+ if (t.closest("[data-pg-reels-view-close]")) return closeView();
993
992
  if (sliding) return;
994
993
  if (t.closest('[data-pg-reels-view-on], [data-pg-reels-view-side="next"]')) return nextClip();
995
994
  if (t.closest('[data-pg-reels-view-back], [data-pg-reels-view-side="prev"]')) return prevClip();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plusguard/reels",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "Shoppable reels for a store: a strip of video cards — each a group of clips, each clip with its own product — that opens into a full view. Up and down between groups, left and right within one, the product beside the video on a computer and under it on a phone. No dependencies.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",