@plusguard/reels 1.4.1 → 1.5.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 +9 -7
- package/dist/index.js +19 -6
- package/index.css +54 -4
- package/index.ts +19 -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.5.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.5.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 either side of the video on
|
|
143
|
+
a computer — none before the very first clip, none after the very last
|
|
144
|
+
— → 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
|
|
@@ -293,8 +295,8 @@ shows them. See [`examples/react/Example.tsx`](examples/react/Example.tsx)
|
|
|
293
295
|
## Example
|
|
294
296
|
|
|
295
297
|
[`examples/static/index.html`](examples/static/index.html) — six groups of
|
|
296
|
-
|
|
297
|
-
|
|
298
|
+
three to five clips, videos (`?duration=2s` sets a picture's time; `?seen=off`,
|
|
299
|
+
`?seen-for=1h` for the rings), each clip with a product and its
|
|
298
300
|
details: its category (a link), its name in the panel's head, a big
|
|
299
301
|
picture at 4:3, small ones — nine for the first product, a row that
|
|
300
302
|
scrolls — the price, a line about it, a link. Under the card the product
|
|
@@ -307,6 +309,6 @@ third four from a pasta and mantı maker, the fourth four from a
|
|
|
307
309
|
jeweller, the fifth four from a nut and sweet shop — a coffee with four
|
|
308
310
|
weights (variants, each its pictures and price) and three categories,
|
|
309
311
|
each listing a few of its products — the sixth three from a pastırma and
|
|
310
|
-
sucuk shop
|
|
312
|
+
sucuk shop — each with its product. The food products'
|
|
311
313
|
further photos are from [Unsplash](https://unsplash.com/license) (free to
|
|
312
314
|
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 ‹ › beside it (none before the first clip or after the last), → and
|
|
52
|
+
* ←. 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,12 @@ 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-column>
|
|
605
|
+
<button type="button" data-pg-reels-view-side="prev" aria-label="Previous">${svg(ICONS.prev)}</button>
|
|
597
606
|
<div data-pg-reels-feed>
|
|
598
607
|
<div data-pg-reels-view-peek="before" aria-hidden="true" hidden></div>
|
|
599
608
|
<div data-pg-reels-screen>
|
|
@@ -615,9 +624,7 @@ export function initReels() {
|
|
|
615
624
|
</div>
|
|
616
625
|
<button type="button" data-pg-reels-view-peek="after" tabindex="-1" aria-label="Next reel" hidden></button>
|
|
617
626
|
</div>
|
|
618
|
-
<
|
|
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>
|
|
627
|
+
<button type="button" data-pg-reels-view-side="next" aria-label="Next">${svg(ICONS.next)}</button>
|
|
621
628
|
</div>
|
|
622
629
|
<aside data-pg-reels-panel>
|
|
623
630
|
<div data-pg-reels-panel-head>
|
|
@@ -641,6 +648,8 @@ export function initReels() {
|
|
|
641
648
|
const viewBars = part("view-bars");
|
|
642
649
|
const playButton = part("view-play");
|
|
643
650
|
const upButton = part("view-up");
|
|
651
|
+
const sidePrev = dialog.querySelector('[data-pg-reels-view-side="prev"]');
|
|
652
|
+
const sideNext = dialog.querySelector('[data-pg-reels-view-side="next"]');
|
|
644
653
|
const downButton = part("view-down");
|
|
645
654
|
const toggle = part("panel-toggle");
|
|
646
655
|
document.body.append(dialog);
|
|
@@ -757,6 +766,10 @@ export function initReels() {
|
|
|
757
766
|
dialog.toggleAttribute(NO_PRODUCT, !product);
|
|
758
767
|
upButton.disabled = view.gi === 0;
|
|
759
768
|
downButton.disabled = view.gi === view.list.length - 1;
|
|
769
|
+
// The arrows beside the video: none before the very first clip,
|
|
770
|
+
// none after the very last.
|
|
771
|
+
sidePrev.hidden = view.gi === 0 && view.ci === 0;
|
|
772
|
+
sideNext.hidden = view.gi === view.list.length - 1 && view.ci === n - 1;
|
|
760
773
|
view.shown = 0;
|
|
761
774
|
view.since = performance.now();
|
|
762
775
|
playView();
|
|
@@ -969,9 +982,9 @@ export function initReels() {
|
|
|
969
982
|
return closeView();
|
|
970
983
|
if (sliding)
|
|
971
984
|
return;
|
|
972
|
-
if (t.closest(
|
|
985
|
+
if (t.closest('[data-pg-reels-view-on], [data-pg-reels-view-side="next"]'))
|
|
973
986
|
return nextClip();
|
|
974
|
-
if (t.closest(
|
|
987
|
+
if (t.closest('[data-pg-reels-view-back], [data-pg-reels-view-side="prev"]'))
|
|
975
988
|
return prevClip();
|
|
976
989
|
if (t.closest("[data-pg-reels-view-up]"))
|
|
977
990
|
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 - 17rem) / 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) - 17rem) * 16 / 9));
|
|
164
164
|
display: flex;
|
|
165
165
|
align-items: flex-start;
|
|
166
166
|
justify-content: center;
|
|
@@ -170,6 +170,49 @@ dialog[data-pg-reels-viewer] svg {
|
|
|
170
170
|
box-sizing: border-box;
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
+
/* The video's column: the feed, and the ‹ › on either side of the
|
|
174
|
+
video's middle — the clip before, the next; none before the very first
|
|
175
|
+
or after the very last. */
|
|
176
|
+
[data-pg-reels-column] {
|
|
177
|
+
position: relative;
|
|
178
|
+
flex: none;
|
|
179
|
+
margin-inline: 3.25rem;
|
|
180
|
+
}
|
|
181
|
+
dialog[data-pg-reels-viewer] [data-pg-reels-view-side] {
|
|
182
|
+
position: absolute;
|
|
183
|
+
z-index: 2;
|
|
184
|
+
top: calc(var(--h) / 2);
|
|
185
|
+
translate: 0 -50%;
|
|
186
|
+
display: grid;
|
|
187
|
+
place-items: center;
|
|
188
|
+
width: 2.25rem;
|
|
189
|
+
height: 2.25rem;
|
|
190
|
+
padding: 0;
|
|
191
|
+
border: 0;
|
|
192
|
+
border-radius: 50%;
|
|
193
|
+
background: rgb(255 255 255 / 0.92);
|
|
194
|
+
color: #111;
|
|
195
|
+
box-shadow: 0 0.125rem 0.5rem rgb(0 0 0 / 0.3);
|
|
196
|
+
cursor: pointer;
|
|
197
|
+
transition: background-color 0.15s;
|
|
198
|
+
}
|
|
199
|
+
dialog[data-pg-reels-viewer] [data-pg-reels-view-side]:hover {
|
|
200
|
+
background: #fff;
|
|
201
|
+
}
|
|
202
|
+
[data-pg-reels-view-side="prev"] {
|
|
203
|
+
right: calc(100% + 0.75rem);
|
|
204
|
+
}
|
|
205
|
+
[data-pg-reels-view-side="next"] {
|
|
206
|
+
left: calc(100% + 0.75rem);
|
|
207
|
+
}
|
|
208
|
+
dialog[data-pg-reels-viewer] [data-pg-reels-view-side][hidden] {
|
|
209
|
+
display: none;
|
|
210
|
+
}
|
|
211
|
+
dialog[data-pg-reels-viewer] [data-pg-reels-view-side] svg {
|
|
212
|
+
width: 1.125rem;
|
|
213
|
+
height: 1.125rem;
|
|
214
|
+
}
|
|
215
|
+
|
|
173
216
|
/* The video, the group before it out of sight above, the next one's top
|
|
174
217
|
under it: a feed that a finger drags, or the ↑ ↓ slide, by a video and
|
|
175
218
|
its gap. */
|
|
@@ -357,8 +400,8 @@ dialog[data-pg-reels-viewer] svg {
|
|
|
357
400
|
display: block;
|
|
358
401
|
}
|
|
359
402
|
|
|
360
|
-
/* ↑ ↓: the group before, the next —
|
|
361
|
-
and grey, their name beside them under the mouse. */
|
|
403
|
+
/* ↑ ↓: the group before, the next — left of the video, at its middle,
|
|
404
|
+
round and grey, their name beside them under the mouse. */
|
|
362
405
|
[data-pg-reels-view-steps] {
|
|
363
406
|
display: flex;
|
|
364
407
|
flex-direction: column;
|
|
@@ -484,6 +527,13 @@ dialog[data-pg-reels-viewer] [data-pg-reels-panel-close] svg {
|
|
|
484
527
|
display: block;
|
|
485
528
|
padding: 0;
|
|
486
529
|
}
|
|
530
|
+
[data-pg-reels-column] {
|
|
531
|
+
position: static;
|
|
532
|
+
margin: 0;
|
|
533
|
+
}
|
|
534
|
+
dialog[data-pg-reels-viewer] [data-pg-reels-view-side] {
|
|
535
|
+
display: none;
|
|
536
|
+
}
|
|
487
537
|
[data-pg-reels-feed] {
|
|
488
538
|
position: absolute;
|
|
489
539
|
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 ‹ › beside it (none before the first clip or after the last), → and
|
|
52
|
+
* ←. 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,12 @@ 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-column>
|
|
623
|
+
<button type="button" data-pg-reels-view-side="prev" aria-label="Previous">${svg(ICONS.prev)}</button>
|
|
615
624
|
<div data-pg-reels-feed>
|
|
616
625
|
<div data-pg-reels-view-peek="before" aria-hidden="true" hidden></div>
|
|
617
626
|
<div data-pg-reels-screen>
|
|
@@ -633,9 +642,7 @@ export function initReels(): () => void {
|
|
|
633
642
|
</div>
|
|
634
643
|
<button type="button" data-pg-reels-view-peek="after" tabindex="-1" aria-label="Next reel" hidden></button>
|
|
635
644
|
</div>
|
|
636
|
-
<
|
|
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>
|
|
645
|
+
<button type="button" data-pg-reels-view-side="next" aria-label="Next">${svg(ICONS.next)}</button>
|
|
639
646
|
</div>
|
|
640
647
|
<aside data-pg-reels-panel>
|
|
641
648
|
<div data-pg-reels-panel-head>
|
|
@@ -659,6 +666,8 @@ export function initReels(): () => void {
|
|
|
659
666
|
const viewBars = part("view-bars");
|
|
660
667
|
const playButton = part("view-play");
|
|
661
668
|
const upButton = part("view-up") as HTMLButtonElement;
|
|
669
|
+
const sidePrev = dialog.querySelector<HTMLElement>('[data-pg-reels-view-side="prev"]')!;
|
|
670
|
+
const sideNext = dialog.querySelector<HTMLElement>('[data-pg-reels-view-side="next"]')!;
|
|
662
671
|
const downButton = part("view-down") as HTMLButtonElement;
|
|
663
672
|
const toggle = part("panel-toggle");
|
|
664
673
|
document.body.append(dialog);
|
|
@@ -783,6 +792,10 @@ export function initReels(): () => void {
|
|
|
783
792
|
|
|
784
793
|
upButton.disabled = view.gi === 0;
|
|
785
794
|
downButton.disabled = view.gi === view.list.length - 1;
|
|
795
|
+
// The arrows beside the video: none before the very first clip,
|
|
796
|
+
// none after the very last.
|
|
797
|
+
sidePrev.hidden = view.gi === 0 && view.ci === 0;
|
|
798
|
+
sideNext.hidden = view.gi === view.list.length - 1 && view.ci === n - 1;
|
|
786
799
|
view.shown = 0;
|
|
787
800
|
view.since = performance.now();
|
|
788
801
|
playView();
|
|
@@ -976,8 +989,8 @@ export function initReels(): () => void {
|
|
|
976
989
|
if (t === dialog || t.hasAttribute("data-pg-reels-stage")) return closeView();
|
|
977
990
|
if (t.closest("[data-pg-reels-view-close], [data-pg-reels-panel-close]")) return closeView();
|
|
978
991
|
if (sliding) return;
|
|
979
|
-
if (t.closest(
|
|
980
|
-
if (t.closest(
|
|
992
|
+
if (t.closest('[data-pg-reels-view-on], [data-pg-reels-view-side="next"]')) return nextClip();
|
|
993
|
+
if (t.closest('[data-pg-reels-view-back], [data-pg-reels-view-side="prev"]')) return prevClip();
|
|
981
994
|
if (t.closest("[data-pg-reels-view-up]")) return prevGroup();
|
|
982
995
|
if (t.closest('[data-pg-reels-view-down], [data-pg-reels-view-peek="after"]')) return nextGroup();
|
|
983
996
|
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.5.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",
|