@plusguard/reels 1.4.1 → 1.6.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 +11 -8
- package/dist/index.js +21 -6
- package/index.css +76 -4
- package/index.ts +21 -6
- package/package.json +1 -1
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.
|
|
26
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@plusguard/reels@1.6.0/index.css" />
|
|
27
27
|
<script type="module">
|
|
28
|
-
import { initReels } from "https://cdn.jsdelivr.net/npm/@plusguard/reels@1.
|
|
28
|
+
import { initReels } from "https://cdn.jsdelivr.net/npm/@plusguard/reels@1.6.0/dist/index.js";
|
|
29
29
|
initReels();
|
|
30
30
|
</script>
|
|
31
31
|
```
|
|
@@ -139,14 +139,16 @@ in it, copies of the site's markup: the clip, the group's
|
|
|
139
139
|
`data-pg-reels-head`, the clip's product and its details.
|
|
140
140
|
|
|
141
141
|
- **Within a group:** the bars on top (none for a single clip), a press on
|
|
142
|
-
the video's right or left third,
|
|
142
|
+
the video's right or left third, the ‹ › on a computer — outside the video
|
|
143
|
+
and its panel, small and see-through, white under the mouse; none
|
|
144
|
+
before the very first clip, none after the very last — → and ←. Its clips play on, a video to
|
|
143
145
|
its end, a picture for its time; after the group's last clip, the next
|
|
144
146
|
group — after the last group, the first.
|
|
145
147
|
- **Between groups:** a finger — or the mouse — dragging the video up or
|
|
146
148
|
down, at once or after holding it: it follows, the next group coming in under it (the one before
|
|
147
149
|
above it), and let go it goes on if pulled a fifth of its height or
|
|
148
150
|
flicked, or back if not; past the first or the last it gives a little
|
|
149
|
-
and comes back. The ↑ ↓ buttons
|
|
151
|
+
and comes back. The ↑ ↓ buttons left of the video (round, their name
|
|
150
152
|
beside them under the mouse), a wheel or a trackpad, ↑ and ↓ slide it
|
|
151
153
|
the same way. On a computer the next group's top shows under the video
|
|
152
154
|
(`--pg-reels-peek`); pressed, it is the next. The product panel changes
|
|
@@ -160,7 +162,8 @@ in it, copies of the site's markup: the clip, the group's
|
|
|
160
162
|
under it; on the close's left the group's view count — the card's
|
|
161
163
|
`data-pg-reels-views` element, copied, so it looks as in the card. The
|
|
162
164
|
number is the site's (from its own counting); the package shows it.
|
|
163
|
-
- **The product:** on a computer, a panel beside the video,
|
|
165
|
+
- **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
|
|
164
167
|
to the window's foot, 9:16 like it: a head — the template's
|
|
165
168
|
`data-pg-reels-title`, moved there, and the close; a long name takes a
|
|
166
169
|
second line, the close stays at the top — a line under it; at the
|
|
@@ -293,8 +296,8 @@ shows them. See [`examples/react/Example.tsx`](examples/react/Example.tsx)
|
|
|
293
296
|
## Example
|
|
294
297
|
|
|
295
298
|
[`examples/static/index.html`](examples/static/index.html) — six groups of
|
|
296
|
-
|
|
297
|
-
|
|
299
|
+
three to five clips, videos (`?duration=2s` sets a picture's time; `?seen=off`,
|
|
300
|
+
`?seen-for=1h` for the rings), each clip with a product and its
|
|
298
301
|
details: its category (a link), its name in the panel's head, a big
|
|
299
302
|
picture at 4:3, small ones — nine for the first product, a row that
|
|
300
303
|
scrolls — the price, a line about it, a link. Under the card the product
|
|
@@ -307,6 +310,6 @@ third four from a pasta and mantı maker, the fourth four from a
|
|
|
307
310
|
jeweller, the fifth four from a nut and sweet shop — a coffee with four
|
|
308
311
|
weights (variants, each its pictures and price) and three categories,
|
|
309
312
|
each listing a few of its products — the sixth three from a pastırma and
|
|
310
|
-
sucuk shop
|
|
313
|
+
sucuk shop — each with its product. The food products'
|
|
311
314
|
further photos are from [Unsplash](https://unsplash.com/license) (free to
|
|
312
315
|
use).
|
package/dist/index.js
CHANGED
|
@@ -48,7 +48,8 @@
|
|
|
48
48
|
* The full view — a <dialog>, built here on <body>, its contents copies:
|
|
49
49
|
* the clip playing, the group's data-pg-reels-head, the clip's product.
|
|
50
50
|
* Within a group: the bars on top, a press on the video's right or left,
|
|
51
|
-
*
|
|
51
|
+
* the ‹ › on either side of the video and its panel (none before the
|
|
52
|
+
* first clip or after the last), → and ←. Between groups: a finger (or the mouse) dragging the video up
|
|
52
53
|
* or down — it follows, the next group coming in under it, and let go
|
|
53
54
|
* goes on or back — its ↑ and ↓ buttons, a wheel, ↑ and ↓; after a
|
|
54
55
|
* group's last clip, the next group. The product changes once it has
|
|
@@ -188,6 +189,8 @@ const ICONS = {
|
|
|
188
189
|
up: '<path d="M12 19V5M5 12l7-7 7 7"/>',
|
|
189
190
|
down: '<path d="M12 5v14M19 12l-7 7-7-7"/>',
|
|
190
191
|
chevron: '<path d="m6 15 6-6 6 6"/>',
|
|
192
|
+
prev: '<path d="m15 6-6 6 6 6"/>',
|
|
193
|
+
next: '<path d="m9 6 6 6-6 6"/>',
|
|
191
194
|
};
|
|
192
195
|
/* ---------- One group ---------- */
|
|
193
196
|
function partsOf(el, root) {
|
|
@@ -594,6 +597,13 @@ export function initReels() {
|
|
|
594
597
|
dialog.tabIndex = -1;
|
|
595
598
|
dialog.innerHTML = `
|
|
596
599
|
<div data-pg-reels-stage>
|
|
600
|
+
<div data-pg-reels-view-steps>
|
|
601
|
+
<button type="button" data-pg-reels-view-up aria-label="Previous reel">${svg(ICONS.up)}</button>
|
|
602
|
+
<button type="button" data-pg-reels-view-down aria-label="Next reel">${svg(ICONS.down)}</button>
|
|
603
|
+
</div>
|
|
604
|
+
<div data-pg-reels-pair>
|
|
605
|
+
<button type="button" data-pg-reels-view-side="prev" aria-label="Previous">${svg(ICONS.prev)}</button>
|
|
606
|
+
<div data-pg-reels-column>
|
|
597
607
|
<div data-pg-reels-feed>
|
|
598
608
|
<div data-pg-reels-view-peek="before" aria-hidden="true" hidden></div>
|
|
599
609
|
<div data-pg-reels-screen>
|
|
@@ -615,9 +625,6 @@ export function initReels() {
|
|
|
615
625
|
</div>
|
|
616
626
|
<button type="button" data-pg-reels-view-peek="after" tabindex="-1" aria-label="Next reel" hidden></button>
|
|
617
627
|
</div>
|
|
618
|
-
<div data-pg-reels-view-steps>
|
|
619
|
-
<button type="button" data-pg-reels-view-up aria-label="Previous reel">${svg(ICONS.up)}</button>
|
|
620
|
-
<button type="button" data-pg-reels-view-down aria-label="Next reel">${svg(ICONS.down)}</button>
|
|
621
628
|
</div>
|
|
622
629
|
<aside data-pg-reels-panel>
|
|
623
630
|
<div data-pg-reels-panel-head>
|
|
@@ -631,6 +638,8 @@ export function initReels() {
|
|
|
631
638
|
<div data-pg-reels-panel-detail></div>
|
|
632
639
|
<div data-pg-reels-panel-foot></div>
|
|
633
640
|
</aside>
|
|
641
|
+
<button type="button" data-pg-reels-view-side="next" aria-label="Next">${svg(ICONS.next)}</button>
|
|
642
|
+
</div>
|
|
634
643
|
</div>`;
|
|
635
644
|
const part = (name) => dialog.querySelector(`[data-pg-reels-${name}]`);
|
|
636
645
|
const media = part("view-media");
|
|
@@ -641,6 +650,8 @@ export function initReels() {
|
|
|
641
650
|
const viewBars = part("view-bars");
|
|
642
651
|
const playButton = part("view-play");
|
|
643
652
|
const upButton = part("view-up");
|
|
653
|
+
const sidePrev = dialog.querySelector('[data-pg-reels-view-side="prev"]');
|
|
654
|
+
const sideNext = dialog.querySelector('[data-pg-reels-view-side="next"]');
|
|
644
655
|
const downButton = part("view-down");
|
|
645
656
|
const toggle = part("panel-toggle");
|
|
646
657
|
document.body.append(dialog);
|
|
@@ -757,6 +768,10 @@ export function initReels() {
|
|
|
757
768
|
dialog.toggleAttribute(NO_PRODUCT, !product);
|
|
758
769
|
upButton.disabled = view.gi === 0;
|
|
759
770
|
downButton.disabled = view.gi === view.list.length - 1;
|
|
771
|
+
// The arrows beside the video: none before the very first clip,
|
|
772
|
+
// none after the very last.
|
|
773
|
+
sidePrev.hidden = view.gi === 0 && view.ci === 0;
|
|
774
|
+
sideNext.hidden = view.gi === view.list.length - 1 && view.ci === n - 1;
|
|
760
775
|
view.shown = 0;
|
|
761
776
|
view.since = performance.now();
|
|
762
777
|
playView();
|
|
@@ -969,9 +984,9 @@ export function initReels() {
|
|
|
969
984
|
return closeView();
|
|
970
985
|
if (sliding)
|
|
971
986
|
return;
|
|
972
|
-
if (t.closest(
|
|
987
|
+
if (t.closest('[data-pg-reels-view-on], [data-pg-reels-view-side="next"]'))
|
|
973
988
|
return nextClip();
|
|
974
|
-
if (t.closest(
|
|
989
|
+
if (t.closest('[data-pg-reels-view-back], [data-pg-reels-view-side="prev"]'))
|
|
975
990
|
return prevClip();
|
|
976
991
|
if (t.closest("[data-pg-reels-view-up]"))
|
|
977
992
|
return prevGroup();
|
package/index.css
CHANGED
|
@@ -126,7 +126,7 @@ 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 -
|
|
129
|
+
--pg-reels-panel: clamp(20rem, min(calc((100dvh - 2rem) * 9 / 16), calc((100vw - 14rem) / 2)), 30rem);
|
|
130
130
|
--pg-reels-peek: 2rem;
|
|
131
131
|
position: fixed;
|
|
132
132
|
inset: 0;
|
|
@@ -160,7 +160,7 @@ dialog[data-pg-reels-viewer] svg {
|
|
|
160
160
|
it (--pg-reels-peek) — and low enough to leave room for the panel. */
|
|
161
161
|
[data-pg-reels-stage] {
|
|
162
162
|
--gap: 1rem;
|
|
163
|
-
--h: min(calc(100dvh - 2 * var(--gap) - var(--pg-reels-peek)), 56rem, calc((100vw - var(--pg-reels-panel) -
|
|
163
|
+
--h: min(calc(100dvh - 2 * var(--gap) - var(--pg-reels-peek)), 56rem, calc((100vw - var(--pg-reels-panel) - 14rem) * 16 / 9));
|
|
164
164
|
display: flex;
|
|
165
165
|
align-items: flex-start;
|
|
166
166
|
justify-content: center;
|
|
@@ -170,6 +170,69 @@ dialog[data-pg-reels-viewer] svg {
|
|
|
170
170
|
box-sizing: border-box;
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
+
/* The video and its panel side by side, touching — as a post opened on
|
|
174
|
+
Instagram — and the ‹ › outside the pair, at the video's middle: the
|
|
175
|
+
clip before, the next; none before the very first or after the very
|
|
176
|
+
last. Small and see-through; white under the mouse. */
|
|
177
|
+
[data-pg-reels-pair] {
|
|
178
|
+
position: relative;
|
|
179
|
+
display: flex;
|
|
180
|
+
align-items: flex-start;
|
|
181
|
+
flex: none;
|
|
182
|
+
margin-inline: 2.5rem;
|
|
183
|
+
}
|
|
184
|
+
[data-pg-reels-column] {
|
|
185
|
+
position: relative;
|
|
186
|
+
flex: none;
|
|
187
|
+
}
|
|
188
|
+
dialog[data-pg-reels-viewer] [data-pg-reels-view-side] {
|
|
189
|
+
position: absolute;
|
|
190
|
+
z-index: 2;
|
|
191
|
+
top: calc(var(--h) / 2);
|
|
192
|
+
translate: 0 -50%;
|
|
193
|
+
display: grid;
|
|
194
|
+
place-items: center;
|
|
195
|
+
width: 1.75rem;
|
|
196
|
+
height: 1.75rem;
|
|
197
|
+
padding: 0;
|
|
198
|
+
border: 0;
|
|
199
|
+
border-radius: 50%;
|
|
200
|
+
background: rgb(255 255 255 / 0.55);
|
|
201
|
+
color: #111;
|
|
202
|
+
cursor: pointer;
|
|
203
|
+
transition: background-color 0.15s;
|
|
204
|
+
}
|
|
205
|
+
dialog[data-pg-reels-viewer] [data-pg-reels-view-side]:hover {
|
|
206
|
+
background: #fff;
|
|
207
|
+
}
|
|
208
|
+
[data-pg-reels-view-side="prev"] {
|
|
209
|
+
right: calc(100% + 0.75rem);
|
|
210
|
+
}
|
|
211
|
+
[data-pg-reels-view-side="next"] {
|
|
212
|
+
left: calc(100% + 0.75rem);
|
|
213
|
+
}
|
|
214
|
+
dialog[data-pg-reels-viewer] [data-pg-reels-view-side][hidden] {
|
|
215
|
+
display: none;
|
|
216
|
+
}
|
|
217
|
+
dialog[data-pg-reels-viewer] [data-pg-reels-view-side] svg {
|
|
218
|
+
width: 1rem;
|
|
219
|
+
height: 1rem;
|
|
220
|
+
stroke-width: 2.5;
|
|
221
|
+
}
|
|
222
|
+
/* Where they touch, no corners: the video's and the next one's right,
|
|
223
|
+
the panel's left. */
|
|
224
|
+
@media (min-width: 48rem) {
|
|
225
|
+
[data-pg-reels-pair] [data-pg-reels-screen],
|
|
226
|
+
[data-pg-reels-pair] [data-pg-reels-view-peek] {
|
|
227
|
+
border-top-right-radius: 0;
|
|
228
|
+
border-bottom-right-radius: 0;
|
|
229
|
+
}
|
|
230
|
+
[data-pg-reels-pair] [data-pg-reels-panel] {
|
|
231
|
+
border-top-left-radius: 0;
|
|
232
|
+
border-bottom-left-radius: 0;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
173
236
|
/* The video, the group before it out of sight above, the next one's top
|
|
174
237
|
under it: a feed that a finger drags, or the ↑ ↓ slide, by a video and
|
|
175
238
|
its gap. */
|
|
@@ -357,8 +420,8 @@ dialog[data-pg-reels-viewer] svg {
|
|
|
357
420
|
display: block;
|
|
358
421
|
}
|
|
359
422
|
|
|
360
|
-
/* ↑ ↓: the group before, the next —
|
|
361
|
-
and grey, their name beside them under the mouse. */
|
|
423
|
+
/* ↑ ↓: the group before, the next — left of the video, at its middle,
|
|
424
|
+
round and grey, their name beside them under the mouse. */
|
|
362
425
|
[data-pg-reels-view-steps] {
|
|
363
426
|
display: flex;
|
|
364
427
|
flex-direction: column;
|
|
@@ -484,6 +547,15 @@ dialog[data-pg-reels-viewer] [data-pg-reels-panel-close] svg {
|
|
|
484
547
|
display: block;
|
|
485
548
|
padding: 0;
|
|
486
549
|
}
|
|
550
|
+
[data-pg-reels-pair] {
|
|
551
|
+
display: contents;
|
|
552
|
+
}
|
|
553
|
+
[data-pg-reels-column] {
|
|
554
|
+
position: static;
|
|
555
|
+
}
|
|
556
|
+
dialog[data-pg-reels-viewer] [data-pg-reels-view-side] {
|
|
557
|
+
display: none;
|
|
558
|
+
}
|
|
487
559
|
[data-pg-reels-feed] {
|
|
488
560
|
position: absolute;
|
|
489
561
|
inset: 0;
|
package/index.ts
CHANGED
|
@@ -48,7 +48,8 @@
|
|
|
48
48
|
* The full view — a <dialog>, built here on <body>, its contents copies:
|
|
49
49
|
* the clip playing, the group's data-pg-reels-head, the clip's product.
|
|
50
50
|
* Within a group: the bars on top, a press on the video's right or left,
|
|
51
|
-
*
|
|
51
|
+
* the ‹ › on either side of the video and its panel (none before the
|
|
52
|
+
* first clip or after the last), → and ←. Between groups: a finger (or the mouse) dragging the video up
|
|
52
53
|
* or down — it follows, the next group coming in under it, and let go
|
|
53
54
|
* goes on or back — its ↑ and ↓ buttons, a wheel, ↑ and ↓; after a
|
|
54
55
|
* group's last clip, the next group. The product changes once it has
|
|
@@ -212,6 +213,8 @@ const ICONS = {
|
|
|
212
213
|
up: '<path d="M12 19V5M5 12l7-7 7 7"/>',
|
|
213
214
|
down: '<path d="M12 5v14M19 12l-7 7-7-7"/>',
|
|
214
215
|
chevron: '<path d="m6 15 6-6 6 6"/>',
|
|
216
|
+
prev: '<path d="m15 6-6 6 6 6"/>',
|
|
217
|
+
next: '<path d="m9 6 6 6-6 6"/>',
|
|
215
218
|
};
|
|
216
219
|
|
|
217
220
|
/* ---------- One group ---------- */
|
|
@@ -612,6 +615,13 @@ export function initReels(): () => void {
|
|
|
612
615
|
dialog.tabIndex = -1;
|
|
613
616
|
dialog.innerHTML = `
|
|
614
617
|
<div data-pg-reels-stage>
|
|
618
|
+
<div data-pg-reels-view-steps>
|
|
619
|
+
<button type="button" data-pg-reels-view-up aria-label="Previous reel">${svg(ICONS.up)}</button>
|
|
620
|
+
<button type="button" data-pg-reels-view-down aria-label="Next reel">${svg(ICONS.down)}</button>
|
|
621
|
+
</div>
|
|
622
|
+
<div data-pg-reels-pair>
|
|
623
|
+
<button type="button" data-pg-reels-view-side="prev" aria-label="Previous">${svg(ICONS.prev)}</button>
|
|
624
|
+
<div data-pg-reels-column>
|
|
615
625
|
<div data-pg-reels-feed>
|
|
616
626
|
<div data-pg-reels-view-peek="before" aria-hidden="true" hidden></div>
|
|
617
627
|
<div data-pg-reels-screen>
|
|
@@ -633,9 +643,6 @@ export function initReels(): () => void {
|
|
|
633
643
|
</div>
|
|
634
644
|
<button type="button" data-pg-reels-view-peek="after" tabindex="-1" aria-label="Next reel" hidden></button>
|
|
635
645
|
</div>
|
|
636
|
-
<div data-pg-reels-view-steps>
|
|
637
|
-
<button type="button" data-pg-reels-view-up aria-label="Previous reel">${svg(ICONS.up)}</button>
|
|
638
|
-
<button type="button" data-pg-reels-view-down aria-label="Next reel">${svg(ICONS.down)}</button>
|
|
639
646
|
</div>
|
|
640
647
|
<aside data-pg-reels-panel>
|
|
641
648
|
<div data-pg-reels-panel-head>
|
|
@@ -649,6 +656,8 @@ export function initReels(): () => void {
|
|
|
649
656
|
<div data-pg-reels-panel-detail></div>
|
|
650
657
|
<div data-pg-reels-panel-foot></div>
|
|
651
658
|
</aside>
|
|
659
|
+
<button type="button" data-pg-reels-view-side="next" aria-label="Next">${svg(ICONS.next)}</button>
|
|
660
|
+
</div>
|
|
652
661
|
</div>`;
|
|
653
662
|
const part = (name: string): HTMLElement => dialog.querySelector<HTMLElement>(`[data-pg-reels-${name}]`)!;
|
|
654
663
|
const media = part("view-media");
|
|
@@ -659,6 +668,8 @@ export function initReels(): () => void {
|
|
|
659
668
|
const viewBars = part("view-bars");
|
|
660
669
|
const playButton = part("view-play");
|
|
661
670
|
const upButton = part("view-up") as HTMLButtonElement;
|
|
671
|
+
const sidePrev = dialog.querySelector<HTMLElement>('[data-pg-reels-view-side="prev"]')!;
|
|
672
|
+
const sideNext = dialog.querySelector<HTMLElement>('[data-pg-reels-view-side="next"]')!;
|
|
662
673
|
const downButton = part("view-down") as HTMLButtonElement;
|
|
663
674
|
const toggle = part("panel-toggle");
|
|
664
675
|
document.body.append(dialog);
|
|
@@ -783,6 +794,10 @@ export function initReels(): () => void {
|
|
|
783
794
|
|
|
784
795
|
upButton.disabled = view.gi === 0;
|
|
785
796
|
downButton.disabled = view.gi === view.list.length - 1;
|
|
797
|
+
// The arrows beside the video: none before the very first clip,
|
|
798
|
+
// none after the very last.
|
|
799
|
+
sidePrev.hidden = view.gi === 0 && view.ci === 0;
|
|
800
|
+
sideNext.hidden = view.gi === view.list.length - 1 && view.ci === n - 1;
|
|
786
801
|
view.shown = 0;
|
|
787
802
|
view.since = performance.now();
|
|
788
803
|
playView();
|
|
@@ -976,8 +991,8 @@ export function initReels(): () => void {
|
|
|
976
991
|
if (t === dialog || t.hasAttribute("data-pg-reels-stage")) return closeView();
|
|
977
992
|
if (t.closest("[data-pg-reels-view-close], [data-pg-reels-panel-close]")) return closeView();
|
|
978
993
|
if (sliding) return;
|
|
979
|
-
if (t.closest(
|
|
980
|
-
if (t.closest(
|
|
994
|
+
if (t.closest('[data-pg-reels-view-on], [data-pg-reels-view-side="next"]')) return nextClip();
|
|
995
|
+
if (t.closest('[data-pg-reels-view-back], [data-pg-reels-view-side="prev"]')) return prevClip();
|
|
981
996
|
if (t.closest("[data-pg-reels-view-up]")) return prevGroup();
|
|
982
997
|
if (t.closest('[data-pg-reels-view-down], [data-pg-reels-view-peek="after"]')) return nextGroup();
|
|
983
998
|
const bar = t.closest<HTMLElement>(`[${VIEW_BAR}]`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plusguard/reels",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.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",
|