cursedbelt 5.74.0 → 5.74.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/dist/react/components/Page.d.ts.map +1 -1
- package/dist/react/components/Page.js +10 -1
- package/dist/react/components/Page.js.map +1 -1
- package/dist/react/media/DenseGalleryShell.d.ts.map +1 -1
- package/dist/react/media/DenseGalleryShell.js +73 -9
- package/dist/react/media/DenseGalleryShell.js.map +1 -1
- package/dist/react/media/HoverScrubVideoThumb.d.ts +11 -9
- package/dist/react/media/HoverScrubVideoThumb.d.ts.map +1 -1
- package/dist/react/media/HoverScrubVideoThumb.js +98 -25
- package/dist/react/media/HoverScrubVideoThumb.js.map +1 -1
- package/dist/react/media/denseGallery.css +103 -7
- package/dist/react/media-gallery/GalleryTable.js +7 -9
- package/dist/react/media-gallery/GalleryTable.js.map +1 -1
- package/dist/react/media-gallery/MediaGallery.d.ts.map +1 -1
- package/dist/react/media-gallery/MediaGallery.js +19 -7
- package/dist/react/media-gallery/MediaGallery.js.map +1 -1
- package/dist/react/media-gallery/playbackPreferences.d.ts +2 -2
- package/dist/react/media-gallery/playbackPreferences.js +2 -2
- package/dist/styles-areas/core.css +8 -6
- package/dist/styles-utilities.css +8 -0
- package/package.json +1 -1
- package/src/react/components/Page.tsx +11 -1
- package/src/react/media/DenseGalleryShell.tsx +90 -6
- package/src/react/media/HoverScrubVideoThumb.spec.tsx +82 -0
- package/src/react/media/HoverScrubVideoThumb.tsx +116 -28
- package/src/react/media/denseGallery.css +103 -7
- package/src/react/media-gallery/GalleryTable.tsx +7 -9
- package/src/react/media-gallery/MediaGallery.tsx +18 -7
- package/src/react/media-gallery/playbackPreferences.ts +2 -2
- package/src/styles-areas/core.css +8 -6
- package/src/styles-utilities.css +8 -0
|
@@ -176,8 +176,8 @@ const THUMB_AUTOPLAY_KEY = 'cbmg:thumb-autoplay';
|
|
|
176
176
|
* a toggle, which is a thing you turn on; a default-on preview is a thing you have to
|
|
177
177
|
* discover in order to turn off.
|
|
178
178
|
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
179
|
+
* On a phone it previews too (2026-10-10 — a pressed "Preview all" that moved nothing was the
|
|
180
|
+
* bug), and {@link HoverScrubVideoThumb}'s on-screen gate keeps it to the tiles in view.
|
|
181
181
|
*/
|
|
182
182
|
export function readThumbAutoplay() {
|
|
183
183
|
try {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* after an app's responsive variant (task 2124). An app that imports every area gets exactly
|
|
16
16
|
* what `cursedbelt/styles-utilities.css` emits — proved rule by rule in
|
|
17
17
|
* src/stylesAreas.spec.ts, which is also what fails when this file is stale.
|
|
18
|
-
*
|
|
18
|
+
* 922 candidate(s).
|
|
19
19
|
*
|
|
20
20
|
* Written by scripts/generateAreaStyles.ts (`bun run styles:areas`), which
|
|
21
21
|
* `bun run build` runs. The map of what is in which area, and why the areas are
|
|
@@ -38,11 +38,13 @@
|
|
|
38
38
|
@source inline("[&_[data-icon]]:text-accent [&_[data-icon]]:text-destructive [&_[data-icon]]:text-success");
|
|
39
39
|
@source inline("[&_[data-icon]]:text-warning [&_sup]:leading-none [&_svg]:shrink-0 [&_svg]:size-12");
|
|
40
40
|
@source inline("[&_svg]:size-4 [&_svg]:size-5 [&_svg]:size-6 [--cbfk-sticky-top:-1rem]");
|
|
41
|
-
@source inline("[-webkit-touch-callout:none]
|
|
42
|
-
@source inline("
|
|
43
|
-
@source inline("
|
|
44
|
-
@source inline("
|
|
45
|
-
@source inline("
|
|
41
|
+
@source inline("[-webkit-touch-callout:none] [@media(orientation:landscape)_and_(max-height:500px)]:py-1.5");
|
|
42
|
+
@source inline("[@media(orientation:landscape)_and_(max-height:500px)]:text-h3 a absolute act active");
|
|
43
|
+
@source inline("active:bg-accent active:scale-100 active:scale-[var(--press-scale)]");
|
|
44
|
+
@source inline("active:scale-[var(--press-scale-surface)] alert alert-icon align align-middle an animate");
|
|
45
|
+
@source inline("animate-in animate-progress-indeterminate animate-pulse animate-spin aria");
|
|
46
|
+
@source inline("aria-[invalid=true]:border-field-error aria-[invalid=true]:ring-field-error/30 aria-disabled");
|
|
47
|
+
@source inline("aria-disabled:active:scale-100 aria-disabled:cursor-not-allowed");
|
|
46
48
|
@source inline("aria-disabled:hover:bg-transparent aria-disabled:opacity-30 aria-disabled:opacity-50");
|
|
47
49
|
@source inline("aria-disabled:pointer-events-none aria-pressed aria-pressed:bg-accent/10 aria-pressed:border");
|
|
48
50
|
@source inline("aria-pressed:border-accent aria-pressed:text-accent auto auto-cols-[minmax(min-content,1fr)] b");
|
|
@@ -5451,6 +5451,14 @@
|
|
|
5451
5451
|
width: calc(var(--spacing) * 3.5);
|
|
5452
5452
|
height: calc(var(--spacing) * 3.5);
|
|
5453
5453
|
}
|
|
5454
|
+
@media (orientation:landscape) and (max-height:500px) {
|
|
5455
|
+
.\[\@media\(orientation\:landscape\)_and_\(max-height\:500px\)\]\:py-1\.5 {
|
|
5456
|
+
padding-block: calc(var(--spacing) * 1.5);
|
|
5457
|
+
}
|
|
5458
|
+
.\[\@media\(orientation\:landscape\)_and_\(max-height\:500px\)\]\:text-h3 {
|
|
5459
|
+
font-size: clamp(1.125rem, 1rem + 0.5vw, 1.25rem);
|
|
5460
|
+
}
|
|
5461
|
+
}
|
|
5454
5462
|
}
|
|
5455
5463
|
@property --tw-translate-x {
|
|
5456
5464
|
syntax: "*";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cursedbelt",
|
|
3
|
-
"version": "5.74.
|
|
3
|
+
"version": "5.74.1",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "The React design system of the cursedbelt split — components, styles, theme. cursedbelt-core below it; server tier in cursedbelt-server.",
|
|
@@ -130,6 +130,11 @@ export interface PageHeaderProps {
|
|
|
130
130
|
className?: string;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
+
/** Under a phone held sideways (`orientation: landscape` and at most 500px tall) — literal
|
|
134
|
+
* class strings, because Tailwind's scanner reads them out of the source. */
|
|
135
|
+
const SHORT_LANDSCAPE_PAD = '[@media(orientation:landscape)_and_(max-height:500px)]:py-1.5';
|
|
136
|
+
const SHORT_LANDSCAPE_TITLE = '[@media(orientation:landscape)_and_(max-height:500px)]:text-h3';
|
|
137
|
+
|
|
133
138
|
/**
|
|
134
139
|
* The page title row: an `<h1>` (fluid `text-h1`) + optional subtitle, with metric
|
|
135
140
|
* pills (`meta`) beside the title and optional actions pushed to the trailing edge.
|
|
@@ -157,6 +162,11 @@ export function PageHeader({
|
|
|
157
162
|
// pushing off-viewport (phone-overflow bug class).
|
|
158
163
|
'flex-wrap gap-y-2 border-b border-border',
|
|
159
164
|
dense ? 'px-0 py-2' : inContainer ? 'px-0 pb-4' : 'px-4 py-4 sm:px-6 lg:px-8',
|
|
165
|
+
// 🔴 A phone on its side is ~340px tall under Safari's bars, and a roomy page header
|
|
166
|
+
// took a quarter of it. Owner, 2026-10-10, collections on an iPhone: *"landscape view
|
|
167
|
+
// has the scrollable content area too short … the outer rows should be much shorter."*
|
|
168
|
+
// One tight line there: the same title, at h3 scale (below).
|
|
169
|
+
!dense && SHORT_LANDSCAPE_PAD,
|
|
160
170
|
sticky && 'sticky top-0 z-20 bg-background/90 backdrop-blur-md',
|
|
161
171
|
className,
|
|
162
172
|
)}
|
|
@@ -166,7 +176,7 @@ export function PageHeader({
|
|
|
166
176
|
<Heading
|
|
167
177
|
className={cn(
|
|
168
178
|
'font-bold tracking-tight text-foreground',
|
|
169
|
-
dense ? 'text-h3' : 'text-h1',
|
|
179
|
+
dense ? 'text-h3' : cn('text-h1', SHORT_LANDSCAPE_TITLE),
|
|
170
180
|
!titleOnMobile && 'hidden sm:block',
|
|
171
181
|
)}
|
|
172
182
|
>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import './denseGallery.css';
|
|
2
|
-
import { ChevronLeft, ChevronRight, Maximize2, Minimize2 } from 'lucide-react';
|
|
2
|
+
import { ChevronDown, ChevronLeft, ChevronRight, ChevronUp, Maximize2, Minimize2 } from 'lucide-react';
|
|
3
3
|
import {
|
|
4
4
|
type ButtonHTMLAttributes,
|
|
5
5
|
type CSSProperties,
|
|
@@ -8,6 +8,8 @@ import {
|
|
|
8
8
|
type Ref,
|
|
9
9
|
useCallback,
|
|
10
10
|
useEffect,
|
|
11
|
+
useId,
|
|
12
|
+
useLayoutEffect,
|
|
11
13
|
useState,
|
|
12
14
|
} from 'react';
|
|
13
15
|
import { VirtualMediaGrid } from './VirtualMediaGrid.js';
|
|
@@ -558,8 +560,23 @@ export function DenseGalleryDetail({
|
|
|
558
560
|
*/
|
|
559
561
|
const top = watchEl.querySelector('.cbgd-watch-top');
|
|
560
562
|
const frame = watchEl.querySelector('.cbgd-watch-player-box');
|
|
561
|
-
|
|
562
|
-
|
|
563
|
+
/*
|
|
564
|
+
* 🔴 A phone on its SIDE puts the titlebar BESIDE the frame (`--cbgd-stage-beside`, set by
|
|
565
|
+
* `denseGallery.css`'s short-landscape block), so nothing of the chrome is under the
|
|
566
|
+
* picture: only the region's own padding is. Measuring the region there would be a loop —
|
|
567
|
+
* the titlebar's column is whatever width the frame leaves it, so its height depends on
|
|
568
|
+
* the frame's — and the stylesheet's share (`--cbgd-stage-share`) is the whole height.
|
|
569
|
+
*/
|
|
570
|
+
const style = getComputedStyle(watchEl);
|
|
571
|
+
const beside = style.getPropertyValue('--cbgd-stage-beside').trim() === '1';
|
|
572
|
+
const shareVar = Number.parseFloat(style.getPropertyValue('--cbgd-stage-share'));
|
|
573
|
+
const share = Number.isFinite(shareVar) && shareVar > 0 ? shareVar : STAGE_SHARE;
|
|
574
|
+
const topStyle = top ? getComputedStyle(top) : null;
|
|
575
|
+
const chromePx = beside
|
|
576
|
+
? Math.round(
|
|
577
|
+
Number.parseFloat(topStyle?.paddingTop ?? '0') + Number.parseFloat(topStyle?.paddingBottom ?? '0'),
|
|
578
|
+
)
|
|
579
|
+
: top && frame
|
|
563
580
|
? Math.round(
|
|
564
581
|
top.getBoundingClientRect().height - frame.getBoundingClientRect().height,
|
|
565
582
|
)
|
|
@@ -569,8 +586,12 @@ export function DenseGalleryDetail({
|
|
|
569
586
|
// `max()`, because a rule that can GROW the stage tracks the content it is measuring
|
|
570
587
|
// and chases itself. That guard reads the source text, so the JS clamp is written in a
|
|
571
588
|
// form that cannot be mistaken for the thing it forbids.
|
|
572
|
-
|
|
573
|
-
|
|
589
|
+
// Beside, the frame is measured against the SCROLLER itself: its parent also holds the
|
|
590
|
+
// app's page header, and the whole point is that the picture fits the scroller's height.
|
|
591
|
+
// Loop-free — the scroller's box is its parent's layout, not its content's.
|
|
592
|
+
const room = beside ? watchEl.clientHeight : available;
|
|
593
|
+
const usable = room > chromePx ? room - chromePx : 0;
|
|
594
|
+
const fit = `min(${Math.round(usable * share)}px, var(--cbgd-stage-default))`;
|
|
574
595
|
if (fit === last) return;
|
|
575
596
|
last = fit;
|
|
576
597
|
watchEl.style.setProperty('--cbgd-stage-fit', fit);
|
|
@@ -689,6 +710,51 @@ export function DenseGalleryDetail({
|
|
|
689
710
|
|
|
690
711
|
const effectiveStageHeight = dragHeight !== null ? `${dragHeight}px` : stageHeight;
|
|
691
712
|
|
|
713
|
+
/*
|
|
714
|
+
* 🔴 On a phone the action row is ONE line, and what does not fit FOLDS behind a toggle.
|
|
715
|
+
*
|
|
716
|
+
* Owner, 2026-10-10, on an iPhone: *"the icons over the media player go out of the right side
|
|
717
|
+
* of the screen."* The row scrolled sideways with its scrollbar hidden (task 2424 chose one
|
|
718
|
+
* row over three wrapped ones), so it read as icons cut off by the screen's edge with no sign
|
|
719
|
+
* there were more. Now the row wraps but is clipped to its first line, and a toggle at its end
|
|
720
|
+
* — drawn only when something is actually clipped — opens the rest in place, the way iOS
|
|
721
|
+
* Photos and Linear's mobile issue bar do. One line stays the default, so the files are still
|
|
722
|
+
* right under the picture.
|
|
723
|
+
*
|
|
724
|
+
* The CSS decides WHERE the fold applies (`.cbgd-actions-more` is `display: none` outside the
|
|
725
|
+
* phone block); this only measures whether anything is past the first line. Measured on every
|
|
726
|
+
* render because the row's contents change (an inline rename swaps buttons for a form) without
|
|
727
|
+
* its clipped box changing size, and on resize for the width.
|
|
728
|
+
*/
|
|
729
|
+
const actionsId = useId();
|
|
730
|
+
const [actionsEl, setActionsEl] = useState<HTMLElement | null>(null);
|
|
731
|
+
const [actionsOpen, setActionsOpen] = useState(false);
|
|
732
|
+
const [actionsFold, setActionsFold] = useState(false);
|
|
733
|
+
const measureFold = useCallback(() => {
|
|
734
|
+
if (!actionsEl) return;
|
|
735
|
+
const kids = [...actionsEl.children] as HTMLElement[];
|
|
736
|
+
const first = Math.min(...kids.map((kid) => kid.offsetTop));
|
|
737
|
+
let folds = false;
|
|
738
|
+
for (const kid of kids) {
|
|
739
|
+
const folded = kid.offsetTop > first + 4;
|
|
740
|
+
folds ||= folded;
|
|
741
|
+
// A control on a folded line is out of reach, so it is out of the tab order and the
|
|
742
|
+
// accessibility tree too (`visibility: hidden` in the phone block), not merely clipped.
|
|
743
|
+
kid.toggleAttribute('data-cbgd-folded', folded && !actionsOpen);
|
|
744
|
+
}
|
|
745
|
+
setActionsFold((current) => (current === folds ? current : folds));
|
|
746
|
+
}, [actionsEl, actionsOpen]);
|
|
747
|
+
// No dependency list: every render, on purpose — see above.
|
|
748
|
+
useLayoutEffect(() => {
|
|
749
|
+
measureFold();
|
|
750
|
+
});
|
|
751
|
+
useEffect(() => {
|
|
752
|
+
if (!actionsEl || typeof ResizeObserver === 'undefined') return;
|
|
753
|
+
const observer = new ResizeObserver(measureFold);
|
|
754
|
+
observer.observe(actionsEl);
|
|
755
|
+
return () => observer.disconnect();
|
|
756
|
+
}, [actionsEl, measureFold]);
|
|
757
|
+
|
|
692
758
|
return (
|
|
693
759
|
<div
|
|
694
760
|
ref={setWatchEl}
|
|
@@ -743,7 +809,11 @@ export function DenseGalleryDetail({
|
|
|
743
809
|
<div className='cbgd-watch-titlebar'>
|
|
744
810
|
<span className='cbgd-watch-title'>{title}</span>
|
|
745
811
|
{meta ? <span className='cbgd-meta-line'>{meta}</span> : null}
|
|
746
|
-
<span
|
|
812
|
+
<span
|
|
813
|
+
ref={setActionsEl}
|
|
814
|
+
className={`cbgd-watch-actions${actionsOpen ? ' is-open' : ''}`}
|
|
815
|
+
id={actionsId}
|
|
816
|
+
>
|
|
747
817
|
{/*
|
|
748
818
|
* 🔴 Stepping lives in the TITLEBAR now, not on the picture.
|
|
749
819
|
*
|
|
@@ -811,6 +881,20 @@ export function DenseGalleryDetail({
|
|
|
811
881
|
</button>
|
|
812
882
|
</Tooltip>
|
|
813
883
|
</span>
|
|
884
|
+
{actionsFold || actionsOpen ? (
|
|
885
|
+
<span className='cbgd-actions-more'>
|
|
886
|
+
<GalleryActionButton
|
|
887
|
+
iconOnly
|
|
888
|
+
tooltip={actionsOpen ? 'Fold the actions back to one line' : 'Show every action'}
|
|
889
|
+
aria-label={actionsOpen ? 'Fewer actions' : 'More actions'}
|
|
890
|
+
aria-expanded={actionsOpen}
|
|
891
|
+
aria-controls={actionsId}
|
|
892
|
+
onClick={() => setActionsOpen(!actionsOpen)}
|
|
893
|
+
>
|
|
894
|
+
{actionsOpen ? <ChevronUp aria-hidden /> : <ChevronDown aria-hidden />}
|
|
895
|
+
</GalleryActionButton>
|
|
896
|
+
</span>
|
|
897
|
+
) : null}
|
|
814
898
|
</div>
|
|
815
899
|
</div>
|
|
816
900
|
{rail ? (
|
|
@@ -3,6 +3,10 @@ import { cleanup, fireEvent, render, waitFor } from '@testing-library/react';
|
|
|
3
3
|
import type { PlayableVideo } from 'cursedbelt-core/media';
|
|
4
4
|
import { HoverScrubVideoThumb } from './HoverScrubVideoThumb.js';
|
|
5
5
|
|
|
6
|
+
/** `HoverScrubVideoThumb`'s hold threshold (300ms), spelled here so this file still loads against
|
|
7
|
+
* a tile that predates the hold — the proof that these specs fail without it. */
|
|
8
|
+
const TOUCH_HOLD_MS = 300;
|
|
9
|
+
|
|
6
10
|
afterEach(cleanup);
|
|
7
11
|
|
|
8
12
|
const video: PlayableVideo = {
|
|
@@ -91,4 +95,82 @@ describe('HoverScrubVideoThumb', () => {
|
|
|
91
95
|
expect(opened).toBe(1);
|
|
92
96
|
expect(getByText('meta line')).toBeDefined();
|
|
93
97
|
});
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* 🔴 On a PHONE. Owner, 2026-10-10, on an iPhone: *"The play icon above the player clicked but
|
|
101
|
+
* it did not make all the video thumbnails start playing like I thought it would."* The tile
|
|
102
|
+
* dropped `autoPlay` under a coarse pointer, so "Preview all" lit up and nothing moved.
|
|
103
|
+
*/
|
|
104
|
+
test('🔴 autoPlay previews on a touch screen too', async () => {
|
|
105
|
+
const real = window.matchMedia;
|
|
106
|
+
window.matchMedia = ((query: string) => ({ ...real.call(window, query), matches: false })) as typeof window.matchMedia;
|
|
107
|
+
try {
|
|
108
|
+
const { container } = render(<HoverScrubVideoThumb video={video} onOpen={() => {}} autoPlay />);
|
|
109
|
+
await waitFor(() => expect(container.querySelector('video')).not.toBeNull());
|
|
110
|
+
} finally {
|
|
111
|
+
window.matchMedia = real;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
describe('🔴 touch-and-hold previews, and the preview stays after the finger lifts', () => {
|
|
116
|
+
const hold = async (tile: HTMLElement, opts: { moveBy?: number } = {}) => {
|
|
117
|
+
fireEvent.pointerDown(tile, { pointerType: 'touch', clientX: 50, clientY: 50 });
|
|
118
|
+
if (opts.moveBy) fireEvent.pointerMove(tile, { pointerType: 'touch', clientX: 50, clientY: 50 + opts.moveBy });
|
|
119
|
+
await new Promise((resolve) => setTimeout(resolve, TOUCH_HOLD_MS + 60));
|
|
120
|
+
fireEvent.pointerUp(tile, { pointerType: 'touch' });
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
test('a hold starts the preview, lifting keeps it, and the lift does not open the file', async () => {
|
|
124
|
+
let opened = 0;
|
|
125
|
+
const { container, getByRole } = render(
|
|
126
|
+
<HoverScrubVideoThumb video={video} onOpen={() => (opened += 1)} />,
|
|
127
|
+
);
|
|
128
|
+
const tile = getByRole('button', { name: 'Open Clip one' });
|
|
129
|
+
await hold(tile);
|
|
130
|
+
expect(container.querySelector('video')).not.toBeNull();
|
|
131
|
+
// The click the lift produces is the hold's, not a tap.
|
|
132
|
+
fireEvent.click(tile);
|
|
133
|
+
expect(opened).toBe(0);
|
|
134
|
+
expect(container.querySelector('video')).not.toBeNull();
|
|
135
|
+
// A real tap afterwards opens as always.
|
|
136
|
+
fireEvent.click(tile);
|
|
137
|
+
expect(opened).toBe(1);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
test('a quick tap is a tap — no preview, it opens', () => {
|
|
141
|
+
let opened = 0;
|
|
142
|
+
const { container, getByRole } = render(
|
|
143
|
+
<HoverScrubVideoThumb video={video} onOpen={() => (opened += 1)} />,
|
|
144
|
+
);
|
|
145
|
+
const tile = getByRole('button', { name: 'Open Clip one' });
|
|
146
|
+
fireEvent.pointerDown(tile, { pointerType: 'touch', clientX: 50, clientY: 50 });
|
|
147
|
+
fireEvent.pointerUp(tile, { pointerType: 'touch' });
|
|
148
|
+
fireEvent.click(tile);
|
|
149
|
+
expect(opened).toBe(1);
|
|
150
|
+
expect(container.querySelector('video')).toBeNull();
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
test('a finger that moves is a scroll, not a hold', async () => {
|
|
154
|
+
const { container, getByRole } = render(<HoverScrubVideoThumb video={video} onOpen={() => {}} />);
|
|
155
|
+
await hold(getByRole('button', { name: 'Open Clip one' }), { moveBy: 40 });
|
|
156
|
+
expect(container.querySelector('video')).toBeNull();
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
test('holding a second tile stops the first', async () => {
|
|
160
|
+
const other: PlayableVideo = { ...video, id: 'v2', name: 'Clip two' };
|
|
161
|
+
const { container, getByRole } = render(
|
|
162
|
+
<>
|
|
163
|
+
<HoverScrubVideoThumb video={video} onOpen={() => {}} />
|
|
164
|
+
<HoverScrubVideoThumb video={other} onOpen={() => {}} />
|
|
165
|
+
</>,
|
|
166
|
+
);
|
|
167
|
+
await hold(getByRole('button', { name: 'Open Clip one' }));
|
|
168
|
+
expect(container.querySelectorAll('video').length).toBe(1);
|
|
169
|
+
await hold(getByRole('button', { name: 'Open Clip two' }));
|
|
170
|
+
const playing = container.querySelectorAll('[data-held-preview="true"]');
|
|
171
|
+
expect(playing.length).toBe(1);
|
|
172
|
+
expect(playing[0]?.getAttribute('aria-label')).toBe('Open Clip two');
|
|
173
|
+
expect(container.querySelectorAll('video').length).toBe(1);
|
|
174
|
+
});
|
|
175
|
+
});
|
|
94
176
|
});
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { Play } from 'lucide-react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
type CSSProperties,
|
|
4
|
+
type MouseEvent,
|
|
5
|
+
type PointerEvent,
|
|
6
|
+
type ReactNode,
|
|
7
|
+
useEffect,
|
|
8
|
+
useRef,
|
|
9
|
+
useState,
|
|
10
|
+
} from 'react';
|
|
3
11
|
import type { PlayableVideo } from 'cursedbelt-core/media';
|
|
4
12
|
import { formatTimecode } from 'cursedbelt-core/media';
|
|
5
13
|
import { cn } from '../lib/cn.js';
|
|
@@ -31,7 +39,17 @@ function turnStyle(orientation: MediaOrientation | undefined): CSSProperties | u
|
|
|
31
39
|
/** Source offsets (fractions of duration) a scrub preview steps through. */
|
|
32
40
|
const SCRUB_POINTS = [0.1, 0.3, 0.5, 0.7, 0.9];
|
|
33
41
|
const SCRUB_STEP_MS = 900;
|
|
42
|
+
/** How long a finger rests on a tile before it counts as a hold rather than a tap. */
|
|
34
43
|
const TOUCH_HOLD_MS = 300;
|
|
44
|
+
/** How far a finger may wander during a hold before it is a scroll instead — a resting thumb is
|
|
45
|
+
* never perfectly still, and a hold that any jitter cancelled would read as one that never works. */
|
|
46
|
+
const TOUCH_HOLD_SLOP_PX = 10;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The one tile a touch-and-hold is previewing — so holding a SECOND tile stops the first, and a
|
|
50
|
+
* phone never accumulates a preview per tile the reader has ever held.
|
|
51
|
+
*/
|
|
52
|
+
let stopHeldPreview: (() => void) | null = null;
|
|
35
53
|
|
|
36
54
|
/**
|
|
37
55
|
* Step a muted preview through spaced source offsets, so a preview tours the WHOLE video
|
|
@@ -74,14 +92,10 @@ export function useScrubPreview(
|
|
|
74
92
|
/**
|
|
75
93
|
* True only on devices that can actually hover with a fine pointer (a mouse).
|
|
76
94
|
*
|
|
77
|
-
* Touch phones/tablets report `(hover: none)
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* mount.
|
|
81
|
-
*
|
|
82
|
-
* 🔴 Exported alongside {@link useScrubPreview} for the same reason — the table view has to
|
|
83
|
-
* make the SAME decision about coarse pointers as the grid, and two copies of a media query is
|
|
84
|
-
* how one view ends up playing ninety clips on a phone.
|
|
95
|
+
* Touch phones/tablets report `(hover: none)`. It no longer gates `autoPlay` (see that prop's
|
|
96
|
+
* note); it decides what a press-and-hold MEANS — a drag to re-file the tile
|
|
97
|
+
* with a mouse, a preview under a finger — so the gallery's tile wrapper is draggable only where
|
|
98
|
+
* this is true. Starts `false`, then resolves after mount.
|
|
85
99
|
*/
|
|
86
100
|
export function useCanHover(): boolean {
|
|
87
101
|
const [canHover, setCanHover] = useState(false);
|
|
@@ -107,11 +121,17 @@ export interface HoverScrubVideoThumbProps {
|
|
|
107
121
|
*/
|
|
108
122
|
previewMode?: 'scrub' | 'loop';
|
|
109
123
|
/**
|
|
110
|
-
* Preview continuously without hover — the
|
|
124
|
+
* Preview continuously without hover — the gallery's "Preview all".
|
|
111
125
|
*
|
|
112
126
|
* 🔴 Gated: the preview starts only once the tile is ON SCREEN and has stayed there for
|
|
113
127
|
* `PREVIEW_SETTLE_MS` (`previewGate.ts`), so a grid scrolled past fast never opens a stream
|
|
114
128
|
* per row. Without an `IntersectionObserver` the tile counts as visible.
|
|
129
|
+
*
|
|
130
|
+
* 🔴 Honoured on a TOUCH screen too. It was suppressed under a coarse pointer until
|
|
131
|
+
* 2026-10-10, so the "Preview all" button on a phone lit up and nothing moved — owner, on an
|
|
132
|
+
* iPhone: *"The play icon above the player clicked but it did not make all the video
|
|
133
|
+
* thumbnails start playing like I thought it would."* A control the reader pressed is the
|
|
134
|
+
* request; the gate above is what keeps it to the tiles actually on screen.
|
|
115
135
|
*/
|
|
116
136
|
autoPlay?: boolean;
|
|
117
137
|
/** Small overlay chips (top-left slot) — e.g. a quality badge. */
|
|
@@ -153,27 +173,83 @@ export function HoverScrubVideoThumb({
|
|
|
153
173
|
* poster that appears later arrives on the next load, which is the state the
|
|
154
174
|
* derived-poster contract already describes. */
|
|
155
175
|
const [posterFailed, setPosterFailed] = useState(false);
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
176
|
+
/**
|
|
177
|
+
* A touch-and-hold's preview — and it STAYS on after the finger lifts.
|
|
178
|
+
*
|
|
179
|
+
* Owner, 2026-10-10, on an iPhone: *"holding down on a thumbnail should make it start
|
|
180
|
+
* previewing the video."* It used to preview only while held: under the thumb that was
|
|
181
|
+
* holding it, and stopped by the very lift that then fired the tile's click and opened the
|
|
182
|
+
* file. So now a hold LATCHES the preview, the lift after a hold is not a click, a plain tap
|
|
183
|
+
* still opens, and the preview ends when the tile leaves the screen or another tile is held.
|
|
184
|
+
*/
|
|
185
|
+
const [held, setHeld] = useState(false);
|
|
160
186
|
const boxRef = useRef<HTMLDivElement>(null);
|
|
161
|
-
const wantsAuto = autoPlay && canHover;
|
|
162
187
|
// A hover is not gated: the pointer on the tile IS the intent the settle exists to infer.
|
|
163
|
-
const autoReady = useSettled(useInView(boxRef,
|
|
164
|
-
const
|
|
165
|
-
const
|
|
188
|
+
const autoReady = useSettled(useInView(boxRef, autoPlay));
|
|
189
|
+
const heldInView = useInView(boxRef, held);
|
|
190
|
+
const previewing = autoReady || hovering || held;
|
|
191
|
+
const hold = useRef<{ timer: ReturnType<typeof setTimeout>; x: number; y: number } | null>(null);
|
|
192
|
+
/** Set by a hold that latched, so the click the lift produces opens nothing. */
|
|
193
|
+
const swallowClick = useRef(false);
|
|
166
194
|
const videoRef = useRef<HTMLVideoElement>(null);
|
|
167
195
|
|
|
168
|
-
const
|
|
169
|
-
|
|
196
|
+
const stopHeld = useRef(() => setHeld(false)).current;
|
|
197
|
+
const clearHold = () => {
|
|
198
|
+
if (hold.current) clearTimeout(hold.current.timer);
|
|
199
|
+
hold.current = null;
|
|
170
200
|
};
|
|
171
|
-
const
|
|
172
|
-
if (
|
|
173
|
-
|
|
174
|
-
|
|
201
|
+
const onPointerDown = (event: PointerEvent<HTMLElement>) => {
|
|
202
|
+
if (event.pointerType !== 'touch') return;
|
|
203
|
+
clearHold();
|
|
204
|
+
const timer = setTimeout(() => {
|
|
205
|
+
hold.current = null;
|
|
206
|
+
if (stopHeldPreview && stopHeldPreview !== stopHeld) stopHeldPreview();
|
|
207
|
+
stopHeldPreview = stopHeld;
|
|
208
|
+
swallowClick.current = true;
|
|
209
|
+
setHeld(true);
|
|
210
|
+
}, TOUCH_HOLD_MS);
|
|
211
|
+
hold.current = { timer, x: event.clientX, y: event.clientY };
|
|
212
|
+
};
|
|
213
|
+
const onPointerMove = (event: PointerEvent<HTMLElement>) => {
|
|
214
|
+
const start = hold.current;
|
|
215
|
+
if (!start) return;
|
|
216
|
+
if (Math.hypot(event.clientX - start.x, event.clientY - start.y) > TOUCH_HOLD_SLOP_PX) clearHold();
|
|
217
|
+
};
|
|
218
|
+
const onClickCapture = (event: MouseEvent<HTMLElement>) => {
|
|
219
|
+
if (!swallowClick.current) return;
|
|
220
|
+
swallowClick.current = false;
|
|
221
|
+
event.preventDefault();
|
|
222
|
+
event.stopPropagation();
|
|
175
223
|
};
|
|
176
224
|
|
|
225
|
+
// A held preview ends when its tile scrolls away (and a hold that never got a click — the lift
|
|
226
|
+
// landed off the tile — must not eat the next real tap).
|
|
227
|
+
useEffect(() => {
|
|
228
|
+
if (!held) return;
|
|
229
|
+
const reset = setTimeout(() => {
|
|
230
|
+
swallowClick.current = false;
|
|
231
|
+
}, 1000);
|
|
232
|
+
return () => clearTimeout(reset);
|
|
233
|
+
}, [held]);
|
|
234
|
+
const seenInView = useRef(false);
|
|
235
|
+
useEffect(() => {
|
|
236
|
+
if (!held) {
|
|
237
|
+
seenInView.current = false;
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
if (heldInView) seenInView.current = true;
|
|
241
|
+
else if (seenInView.current) setHeld(false);
|
|
242
|
+
}, [held, heldInView]);
|
|
243
|
+
// Unmount only: a pending hold must not fire into an unmounted tile.
|
|
244
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: unmount-only cleanup; both read refs
|
|
245
|
+
useEffect(
|
|
246
|
+
() => () => {
|
|
247
|
+
if (hold.current) clearTimeout(hold.current.timer);
|
|
248
|
+
if (stopHeldPreview === stopHeld) stopHeldPreview = null;
|
|
249
|
+
},
|
|
250
|
+
[],
|
|
251
|
+
);
|
|
252
|
+
|
|
177
253
|
useScrubPreview(videoRef, {
|
|
178
254
|
active: previewing && previewMode === 'scrub',
|
|
179
255
|
durationSeconds: video.durationSeconds,
|
|
@@ -335,12 +411,24 @@ export function HoverScrubVideoThumb({
|
|
|
335
411
|
// GalleryApp "opens a video — navigation" precedent).
|
|
336
412
|
type='button'
|
|
337
413
|
onClick={onOpen}
|
|
414
|
+
onClickCapture={onClickCapture}
|
|
338
415
|
onMouseEnter={() => setHovering(true)}
|
|
339
416
|
onMouseLeave={() => setHovering(false)}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
417
|
+
onPointerDown={onPointerDown}
|
|
418
|
+
onPointerMove={onPointerMove}
|
|
419
|
+
onPointerUp={clearHold}
|
|
420
|
+
onPointerCancel={clearHold}
|
|
421
|
+
// A hold is a preview, not the browser's own long-press: no "Save image" callout, no text
|
|
422
|
+
// selection, no context menu (Android's long-press) over the tile.
|
|
423
|
+
onContextMenu={(event) => {
|
|
424
|
+
if (hold.current || swallowClick.current) event.preventDefault();
|
|
425
|
+
}}
|
|
426
|
+
data-held-preview={held ? 'true' : undefined}
|
|
427
|
+
className={cn(
|
|
428
|
+
RAW_BUTTON,
|
|
429
|
+
cardClassName,
|
|
430
|
+
'[-webkit-touch-callout:none] select-none hover:border-accent-solid focus-visible:ring-2 focus-visible:ring-accent-solid',
|
|
431
|
+
)}
|
|
344
432
|
aria-label={`Open ${video.name}`}
|
|
345
433
|
>
|
|
346
434
|
{media}
|
|
@@ -767,6 +767,11 @@
|
|
|
767
767
|
gap: 6px;
|
|
768
768
|
flex-wrap: wrap;
|
|
769
769
|
}
|
|
770
|
+
/* The phone's fold toggle (`DenseGalleryDetail`'s `actionsFold`) — only the phone block below
|
|
771
|
+
folds the row, so everywhere else the row wraps in full and the toggle is never drawn. */
|
|
772
|
+
.cbgd-actions-more {
|
|
773
|
+
display: none;
|
|
774
|
+
}
|
|
770
775
|
.cbgd-watch-rail {
|
|
771
776
|
display: flex;
|
|
772
777
|
flex-direction: column;
|
|
@@ -864,20 +869,111 @@
|
|
|
864
869
|
.cbgd-watch-player > .cbmr-rail {
|
|
865
870
|
max-width: 100%;
|
|
866
871
|
}
|
|
867
|
-
/*
|
|
868
|
-
|
|
872
|
+
/*
|
|
873
|
+
* 🔴 The titlebar's actions are ONE line, and the rest FOLD behind the toggle at its end.
|
|
874
|
+
*
|
|
875
|
+
* Three wrapped rows of 44px icons put the related files a whole screen below the picture
|
|
876
|
+
* (task 2424), so it became one row that scrolled sideways — with its scrollbar hidden, which
|
|
877
|
+
* the owner read as a bug on 2026-10-10: *"the icons over the media player go out of the right
|
|
878
|
+
* side of the screen."* Now the row wraps but shows only its first line (`overflow: clip`, so
|
|
879
|
+
* a focused button on the folded lines cannot scroll the row either), and `.cbgd-actions-more`
|
|
880
|
+
* beside it opens the rest in place. collections' `e2e/layout.browser.test.ts` measures it on a phone.
|
|
881
|
+
*/
|
|
869
882
|
.cbgd-watch-actions {
|
|
870
883
|
margin-left: 0;
|
|
871
|
-
flex
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
884
|
+
flex: 1 1 calc(100% - 60px);
|
|
885
|
+
min-width: 0;
|
|
886
|
+
flex-wrap: wrap;
|
|
887
|
+
/* One line of 44px pills, and the 2px either side. */
|
|
888
|
+
max-height: 48px;
|
|
889
|
+
/* guardrails-ignore no-raw-overflow: task 2424 — a CLIP, not a scroller; the folded lines wait behind the toggle above. */
|
|
890
|
+
overflow: clip;
|
|
876
891
|
padding-block: 2px;
|
|
877
892
|
}
|
|
893
|
+
.cbgd-watch-actions.is-open {
|
|
894
|
+
max-height: none;
|
|
895
|
+
}
|
|
878
896
|
.cbgd-watch-actions > * {
|
|
879
897
|
flex: none;
|
|
880
898
|
}
|
|
899
|
+
.cbgd-watch-actions > [data-cbgd-folded] {
|
|
900
|
+
visibility: hidden;
|
|
901
|
+
}
|
|
902
|
+
/* The way OUT leads the row, where a phone's back button always is — never on a folded line. */
|
|
903
|
+
.cbgd-watch-actions > .cbgd-action-lead {
|
|
904
|
+
order: -1;
|
|
905
|
+
}
|
|
906
|
+
.cbgd-actions-more {
|
|
907
|
+
display: inline-flex;
|
|
908
|
+
flex: none;
|
|
909
|
+
align-self: flex-start;
|
|
910
|
+
padding-block: 2px;
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
/*
|
|
915
|
+
* 🔴 A phone on its SIDE: the picture BESIDE its titlebar, as tall as the gallery's scroller.
|
|
916
|
+
*
|
|
917
|
+
* Owner, 2026-10-10, collections on an iPhone: *"landscape view has the scrollable content area
|
|
918
|
+
* too short."* Landscape is the width of a laptop and the height of a postcard (~340px under
|
|
919
|
+
* Safari's bars), and the stacked layout spent it on chrome: the resize rail, a titlebar that
|
|
920
|
+
* wrapped to three rows, and a share of what was left — measured, a 53×30 frame over a band of
|
|
921
|
+
* buttons, with the files below the fold. Beside each other, the frame takes the scroller's full
|
|
922
|
+
* height at 16:9, the actions wrap freely in the column it leaves, and the files are one scroll
|
|
923
|
+
* down in the same scroller. The resize rail goes: there is no height left to drag it into.
|
|
924
|
+
*
|
|
925
|
+
* `--cbgd-stage-beside` tells `DenseGalleryDetail`'s fit to measure only the region's padding
|
|
926
|
+
* (the titlebar is not under the frame here), and `--cbgd-stage-share` is how much of the
|
|
927
|
+
* scroller the frame may take — all of it, or a little over half when PINNED, so the pinned
|
|
928
|
+
* stage leaves a band of files to scroll under it.
|
|
929
|
+
*/
|
|
930
|
+
@media (orientation: landscape) and (max-height: 500px) {
|
|
931
|
+
.cbgd-watch {
|
|
932
|
+
--cbgd-stage-beside: 1;
|
|
933
|
+
--cbgd-stage-share: 1;
|
|
934
|
+
--cbgd-stage-default: 760px;
|
|
935
|
+
}
|
|
936
|
+
.cbgd-watch.cbgd-watch-sticky {
|
|
937
|
+
--cbgd-stage-share: 0.55;
|
|
938
|
+
}
|
|
939
|
+
.cbgd-watch:not(.cbgd-watch-full) .cbgd-watch-top {
|
|
940
|
+
grid-template-columns: 1fr;
|
|
941
|
+
padding: 6px 10px;
|
|
942
|
+
}
|
|
943
|
+
.cbgd-watch:not(.cbgd-watch-full) .cbgd-watch-rail {
|
|
944
|
+
display: none;
|
|
945
|
+
}
|
|
946
|
+
.cbgd-watch:not(.cbgd-watch-full) .cbgd-watch-main {
|
|
947
|
+
display: grid;
|
|
948
|
+
grid-template-columns:
|
|
949
|
+
minmax(0, calc(var(--cbgd-stage-h, var(--cbgd-stage-fit, var(--cbgd-stage-default))) * 16 / 9))
|
|
950
|
+
minmax(200px, 1fr);
|
|
951
|
+
gap: 12px;
|
|
952
|
+
align-items: start;
|
|
953
|
+
}
|
|
954
|
+
.cbgd-watch:not(.cbgd-watch-full) .cbgd-watch-player-box {
|
|
955
|
+
height: var(--cbgd-stage-h, var(--cbgd-stage-fit, var(--cbgd-stage-default)));
|
|
956
|
+
aspect-ratio: auto;
|
|
957
|
+
max-width: 100%;
|
|
958
|
+
max-height: none;
|
|
959
|
+
}
|
|
960
|
+
.cbgd-watch:not(.cbgd-watch-full) .cbgd-watch-player > .cbmr-rail {
|
|
961
|
+
display: none;
|
|
962
|
+
}
|
|
963
|
+
.cbgd-watch:not(.cbgd-watch-full) .cbgd-watch-titlebar {
|
|
964
|
+
align-content: flex-start;
|
|
965
|
+
padding-top: 0;
|
|
966
|
+
}
|
|
967
|
+
.cbgd-watch:not(.cbgd-watch-full) .cbgd-watch-actions {
|
|
968
|
+
margin-left: 0;
|
|
969
|
+
flex: 1 1 100%;
|
|
970
|
+
flex-wrap: wrap;
|
|
971
|
+
max-height: none;
|
|
972
|
+
overflow: visible;
|
|
973
|
+
}
|
|
974
|
+
.cbgd-watch:not(.cbgd-watch-full) .cbgd-actions-more {
|
|
975
|
+
display: none;
|
|
976
|
+
}
|
|
881
977
|
}
|
|
882
978
|
|
|
883
979
|
/* ≥44px touch target on coarse pointers only — mirrors `TAP_TARGET_HEIGHT` from
|