@open-slide/core 1.12.0 → 1.13.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 +2 -0
- package/dist/{build-L2yL1hTo.js → build-OAZ8maw5.js} +1 -1
- package/dist/cli/bin.js +3 -3
- package/dist/{config-OT4T-im0.js → config-CU_NISD6.js} +49 -4
- package/dist/{config-C2C3cut3.d.ts → config-x493taft.d.ts} +1 -1
- package/dist/{dev-DJUpPCGT.js → dev-C78J1TLR.js} +1 -1
- package/dist/{format-zplQGJPI.js → format-7j0EzhuV.js} +4 -0
- package/dist/index.d.ts +31 -9
- package/dist/index.js +22 -2
- package/dist/locale/index.d.ts +1 -1
- package/dist/locale/index.js +1 -1
- package/dist/{preview-Bf8up6-P.js → preview-DZLZ3L9v.js} +1 -1
- package/dist/{types-uNHQlioH.d.ts → types-CHmFPIG_.d.ts} +1 -0
- package/dist/vite/index.d.ts +2 -2
- package/dist/vite/index.js +1 -1
- package/package.json +5 -5
- package/src/app/components/inspector/inspect-overlay.tsx +39 -18
- package/src/app/components/inspector/inspector-panel.tsx +5 -1
- package/src/app/components/inspector/inspector-provider.tsx +54 -6
- package/src/app/components/overview-grid.tsx +200 -69
- package/src/app/components/player.tsx +66 -3
- package/src/app/components/present/control-bar.tsx +99 -7
- package/src/app/components/shared-element.tsx +48 -0
- package/src/app/components/slide-canvas.tsx +24 -14
- package/src/app/components/slide-transition-layer.tsx +506 -4
- package/src/app/lib/export-html.ts +1 -1
- package/src/app/lib/transition.ts +7 -0
- package/src/app/lib/use-click-page-navigation.ts +10 -2
- package/src/app/routes/slide.tsx +175 -143
- package/src/locale/en.ts +1 -0
- package/src/locale/ja.ts +1 -0
- package/src/locale/types.ts +1 -0
- package/src/locale/zh-cn.ts +1 -0
- package/src/locale/zh-tw.ts +1 -0
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { X } from 'lucide-react';
|
|
2
|
-
import { useEffect, useRef, useState } from 'react';
|
|
1
|
+
import { ListOrdered, type LucideIcon, Sparkles, X } from 'lucide-react';
|
|
2
|
+
import { type Ref, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
|
|
3
4
|
import { format, useLocale } from '@/lib/use-locale';
|
|
4
5
|
import { cn } from '@/lib/utils';
|
|
5
6
|
import type { DesignSystem } from '../lib/design';
|
|
6
7
|
import { SlidePageProvider } from '../lib/page-context';
|
|
7
8
|
import type { Page } from '../lib/sdk';
|
|
8
9
|
import { CANVAS_HEIGHT, CANVAS_WIDTH } from '../lib/sdk';
|
|
10
|
+
import type { SlideTransition } from '../lib/transition';
|
|
9
11
|
import { SlideCanvas } from './slide-canvas';
|
|
10
12
|
|
|
11
13
|
const THUMB_W = 320;
|
|
@@ -21,6 +23,8 @@ type Props = {
|
|
|
21
23
|
onClose: () => void;
|
|
22
24
|
onSelect: (index: number) => void;
|
|
23
25
|
variant?: OverviewVariant;
|
|
26
|
+
moduleTransition?: SlideTransition;
|
|
27
|
+
tooltipContainer?: HTMLElement | null;
|
|
24
28
|
};
|
|
25
29
|
|
|
26
30
|
export function OverviewGrid({
|
|
@@ -31,6 +35,8 @@ export function OverviewGrid({
|
|
|
31
35
|
onClose,
|
|
32
36
|
onSelect,
|
|
33
37
|
variant = 'present',
|
|
38
|
+
moduleTransition,
|
|
39
|
+
tooltipContainer,
|
|
34
40
|
}: Props) {
|
|
35
41
|
const [focused, setFocused] = useState(current);
|
|
36
42
|
const gridRef = useRef<HTMLDivElement>(null);
|
|
@@ -124,78 +130,201 @@ export function OverviewGrid({
|
|
|
124
130
|
</div>
|
|
125
131
|
</div>
|
|
126
132
|
<div ref={gridRef} className="min-h-0 flex-1 overflow-auto px-8 pb-8">
|
|
127
|
-
<
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
>
|
|
162
|
-
<SlideCanvas
|
|
163
|
-
scale={THUMB_W / CANVAS_WIDTH}
|
|
164
|
-
center={false}
|
|
165
|
-
flat
|
|
166
|
-
freezeMotion
|
|
167
|
-
design={design}
|
|
168
|
-
>
|
|
169
|
-
<SlidePageProvider index={i} total={pages.length}>
|
|
170
|
-
<PageComp />
|
|
171
|
-
</SlidePageProvider>
|
|
172
|
-
</SlideCanvas>
|
|
173
|
-
{isCurrent && (
|
|
174
|
-
<span
|
|
175
|
-
aria-hidden
|
|
176
|
-
className="pointer-events-none absolute top-1.5 right-1.5 rounded-[3px] bg-[var(--brand,#ef4444)] px-1.5 py-0.5 font-mono text-[9.5px] tracking-[0.06em] uppercase text-white"
|
|
177
|
-
>
|
|
178
|
-
{t.present.nowBadge}
|
|
179
|
-
</span>
|
|
180
|
-
)}
|
|
181
|
-
</div>
|
|
182
|
-
<span
|
|
183
|
-
className={cn(
|
|
184
|
-
'font-mono text-[10.5px] tracking-[0.08em] tabular-nums uppercase',
|
|
185
|
-
isFocused || isCurrent ? styles.labelActive : styles.labelMuted,
|
|
186
|
-
)}
|
|
187
|
-
>
|
|
188
|
-
{(i + 1).toString().padStart(2, '0')}
|
|
189
|
-
</span>
|
|
190
|
-
</button>
|
|
191
|
-
);
|
|
192
|
-
})}
|
|
193
|
-
</div>
|
|
133
|
+
<TooltipProvider delayDuration={200}>
|
|
134
|
+
<div
|
|
135
|
+
className="grid justify-center gap-5"
|
|
136
|
+
style={{
|
|
137
|
+
gridTemplateColumns: `repeat(auto-fill, ${THUMB_W}px)`,
|
|
138
|
+
}}
|
|
139
|
+
>
|
|
140
|
+
{pages.map((PageComp, i) => {
|
|
141
|
+
const isFocused = i === focused;
|
|
142
|
+
const isCurrent = i === current;
|
|
143
|
+
return (
|
|
144
|
+
<OverviewThumb
|
|
145
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: pages list is render-stable
|
|
146
|
+
key={i}
|
|
147
|
+
buttonRef={isFocused ? focusedRef : undefined}
|
|
148
|
+
page={PageComp}
|
|
149
|
+
index={i}
|
|
150
|
+
total={pages.length}
|
|
151
|
+
design={design}
|
|
152
|
+
isFocused={isFocused}
|
|
153
|
+
isCurrent={isCurrent}
|
|
154
|
+
styles={styles}
|
|
155
|
+
moduleTransition={moduleTransition}
|
|
156
|
+
tooltipContainer={tooltipContainer}
|
|
157
|
+
onFocus={() => setFocused(i)}
|
|
158
|
+
onSelect={() => {
|
|
159
|
+
onSelect(i);
|
|
160
|
+
onClose();
|
|
161
|
+
}}
|
|
162
|
+
/>
|
|
163
|
+
);
|
|
164
|
+
})}
|
|
165
|
+
</div>
|
|
166
|
+
</TooltipProvider>
|
|
194
167
|
</div>
|
|
195
168
|
</div>
|
|
196
169
|
);
|
|
197
170
|
}
|
|
198
171
|
|
|
172
|
+
function OverviewThumb({
|
|
173
|
+
page: PageComp,
|
|
174
|
+
index,
|
|
175
|
+
total,
|
|
176
|
+
design,
|
|
177
|
+
isFocused,
|
|
178
|
+
isCurrent,
|
|
179
|
+
styles,
|
|
180
|
+
moduleTransition,
|
|
181
|
+
tooltipContainer,
|
|
182
|
+
onFocus,
|
|
183
|
+
onSelect,
|
|
184
|
+
buttonRef,
|
|
185
|
+
}: {
|
|
186
|
+
page: Page;
|
|
187
|
+
index: number;
|
|
188
|
+
total: number;
|
|
189
|
+
design?: DesignSystem;
|
|
190
|
+
isFocused: boolean;
|
|
191
|
+
isCurrent: boolean;
|
|
192
|
+
styles: OverviewStyles;
|
|
193
|
+
moduleTransition?: SlideTransition;
|
|
194
|
+
tooltipContainer?: HTMLElement | null;
|
|
195
|
+
onFocus: () => void;
|
|
196
|
+
onSelect: () => void;
|
|
197
|
+
buttonRef?: Ref<HTMLButtonElement>;
|
|
198
|
+
}) {
|
|
199
|
+
const t = useLocale();
|
|
200
|
+
const boxRef = useRef<HTMLDivElement | null>(null);
|
|
201
|
+
const [hasSteps, setHasSteps] = useState(false);
|
|
202
|
+
const hasTransition = Boolean(PageComp.transition ?? moduleTransition);
|
|
203
|
+
|
|
204
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: re-detect when the page at this slot changes
|
|
205
|
+
useEffect(() => {
|
|
206
|
+
setHasSteps(boxRef.current?.querySelector('[data-osd-step]') != null);
|
|
207
|
+
}, [PageComp]);
|
|
208
|
+
|
|
209
|
+
return (
|
|
210
|
+
<button
|
|
211
|
+
ref={buttonRef}
|
|
212
|
+
type="button"
|
|
213
|
+
onClick={onSelect}
|
|
214
|
+
onMouseEnter={onFocus}
|
|
215
|
+
onFocus={onFocus}
|
|
216
|
+
aria-label={format(t.present.overviewGoToAria, { n: index + 1 })}
|
|
217
|
+
aria-current={isCurrent ? 'true' : undefined}
|
|
218
|
+
className={cn(
|
|
219
|
+
'group/thumb flex flex-col items-start gap-2 rounded-[6px] p-1.5 outline-none transition-colors',
|
|
220
|
+
isFocused ? styles.thumbFocused : styles.thumbHover,
|
|
221
|
+
)}
|
|
222
|
+
>
|
|
223
|
+
<div
|
|
224
|
+
ref={boxRef}
|
|
225
|
+
className={cn(
|
|
226
|
+
'relative w-full overflow-hidden rounded-[4px] ring-1 transition-shadow',
|
|
227
|
+
styles.thumbSurface,
|
|
228
|
+
isFocused ? 'ring-2 ring-[var(--brand,#ef4444)]' : styles.thumbRing,
|
|
229
|
+
)}
|
|
230
|
+
style={{ height: THUMB_H }}
|
|
231
|
+
>
|
|
232
|
+
<SlideCanvas
|
|
233
|
+
scale={THUMB_W / CANVAS_WIDTH}
|
|
234
|
+
center={false}
|
|
235
|
+
flat
|
|
236
|
+
freezeMotion
|
|
237
|
+
design={design}
|
|
238
|
+
>
|
|
239
|
+
<SlidePageProvider index={index} total={total}>
|
|
240
|
+
<PageComp />
|
|
241
|
+
</SlidePageProvider>
|
|
242
|
+
</SlideCanvas>
|
|
243
|
+
{isCurrent && (
|
|
244
|
+
<span
|
|
245
|
+
aria-hidden
|
|
246
|
+
className="pointer-events-none absolute top-1.5 right-1.5 rounded-[3px] bg-[var(--brand,#ef4444)] px-1.5 py-0.5 font-mono text-[9.5px] tracking-[0.06em] uppercase text-white"
|
|
247
|
+
>
|
|
248
|
+
{t.present.nowBadge}
|
|
249
|
+
</span>
|
|
250
|
+
)}
|
|
251
|
+
</div>
|
|
252
|
+
<div className="flex h-4 w-full items-center justify-between gap-2">
|
|
253
|
+
<span
|
|
254
|
+
className={cn(
|
|
255
|
+
'font-mono text-[10.5px] tracking-[0.08em] tabular-nums uppercase',
|
|
256
|
+
isFocused || isCurrent ? styles.labelActive : styles.labelMuted,
|
|
257
|
+
)}
|
|
258
|
+
>
|
|
259
|
+
{(index + 1).toString().padStart(2, '0')}
|
|
260
|
+
</span>
|
|
261
|
+
{(hasTransition || hasSteps) && (
|
|
262
|
+
<span className="flex items-center gap-1">
|
|
263
|
+
{hasTransition && (
|
|
264
|
+
<OverviewIndicator
|
|
265
|
+
icon={Sparkles}
|
|
266
|
+
label={t.thumbnailRail.transitionIndicator}
|
|
267
|
+
className={styles.indicator}
|
|
268
|
+
tooltipContainer={tooltipContainer}
|
|
269
|
+
/>
|
|
270
|
+
)}
|
|
271
|
+
{hasSteps && (
|
|
272
|
+
<OverviewIndicator
|
|
273
|
+
icon={ListOrdered}
|
|
274
|
+
label={t.thumbnailRail.stepsIndicator}
|
|
275
|
+
className={styles.indicator}
|
|
276
|
+
tooltipContainer={tooltipContainer}
|
|
277
|
+
/>
|
|
278
|
+
)}
|
|
279
|
+
</span>
|
|
280
|
+
)}
|
|
281
|
+
</div>
|
|
282
|
+
</button>
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function OverviewIndicator({
|
|
287
|
+
icon: Icon,
|
|
288
|
+
label,
|
|
289
|
+
className,
|
|
290
|
+
tooltipContainer,
|
|
291
|
+
}: {
|
|
292
|
+
icon: LucideIcon;
|
|
293
|
+
label: string;
|
|
294
|
+
className: string;
|
|
295
|
+
tooltipContainer?: HTMLElement | null;
|
|
296
|
+
}) {
|
|
297
|
+
return (
|
|
298
|
+
<Tooltip>
|
|
299
|
+
<TooltipTrigger asChild>
|
|
300
|
+
<span
|
|
301
|
+
role="img"
|
|
302
|
+
aria-label={label}
|
|
303
|
+
className={cn('flex size-4 items-center justify-center', className)}
|
|
304
|
+
>
|
|
305
|
+
<Icon className="size-3.5" strokeWidth={1.9} />
|
|
306
|
+
</span>
|
|
307
|
+
</TooltipTrigger>
|
|
308
|
+
<TooltipContent side="top" sideOffset={6} container={tooltipContainer ?? undefined}>
|
|
309
|
+
{label}
|
|
310
|
+
</TooltipContent>
|
|
311
|
+
</Tooltip>
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
type OverviewStyles = {
|
|
316
|
+
surface: string;
|
|
317
|
+
eyebrow: string;
|
|
318
|
+
thumbFocused: string;
|
|
319
|
+
thumbHover: string;
|
|
320
|
+
thumbSurface: string;
|
|
321
|
+
thumbRing: string;
|
|
322
|
+
labelActive: string;
|
|
323
|
+
labelMuted: string;
|
|
324
|
+
indicator: string;
|
|
325
|
+
closeButton: string;
|
|
326
|
+
};
|
|
327
|
+
|
|
199
328
|
const presentStyles = {
|
|
200
329
|
surface: 'bg-black/95',
|
|
201
330
|
eyebrow: 'text-white/55',
|
|
@@ -205,6 +334,7 @@ const presentStyles = {
|
|
|
205
334
|
thumbRing: 'ring-white/10',
|
|
206
335
|
labelActive: 'text-white/85',
|
|
207
336
|
labelMuted: 'text-white/45',
|
|
337
|
+
indicator: 'text-white/45 transition-colors group-hover/thumb:text-white/75',
|
|
208
338
|
closeButton:
|
|
209
339
|
'text-white/55 hover:bg-white/10 hover:text-white focus-visible:ring-2 focus-visible:ring-white/40',
|
|
210
340
|
} as const;
|
|
@@ -218,6 +348,7 @@ const editorStyles = {
|
|
|
218
348
|
thumbRing: 'ring-hairline',
|
|
219
349
|
labelActive: 'text-foreground',
|
|
220
350
|
labelMuted: 'text-muted-foreground/60',
|
|
351
|
+
indicator: 'text-muted-foreground/60 transition-colors group-hover/thumb:text-muted-foreground',
|
|
221
352
|
closeButton:
|
|
222
353
|
'text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring',
|
|
223
354
|
} as const;
|
|
@@ -6,6 +6,7 @@ import type { DesignSystem } from '../lib/design';
|
|
|
6
6
|
import type { Page } from '../lib/sdk';
|
|
7
7
|
import type { EntryDirection, StepAggregate, StepController } from '../lib/step-context';
|
|
8
8
|
import type { SlideTransition } from '../lib/transition';
|
|
9
|
+
import { useIsMobile } from '../lib/use-is-mobile';
|
|
9
10
|
import { usePrefersReducedMotion } from '../lib/use-prefers-reduced-motion';
|
|
10
11
|
import { OverviewGrid } from './overview-grid';
|
|
11
12
|
import { PresentBlackoutOverlay } from './present/blackout-overlay';
|
|
@@ -27,6 +28,7 @@ import { SlideTransitionLayer } from './slide-transition-layer';
|
|
|
27
28
|
|
|
28
29
|
const IDLE_HIDE_MS = 2000;
|
|
29
30
|
const BAR_HOTZONE_PX = 160;
|
|
31
|
+
const MOBILE_CHROME_HIDE_MS = 2200;
|
|
30
32
|
|
|
31
33
|
type Props = {
|
|
32
34
|
pages: Page[];
|
|
@@ -58,6 +60,7 @@ export function Player({
|
|
|
58
60
|
slideId,
|
|
59
61
|
fullscreen = true,
|
|
60
62
|
}: Props) {
|
|
63
|
+
const isMobile = useIsMobile();
|
|
61
64
|
const prefersReducedMotion = usePrefersReducedMotion();
|
|
62
65
|
const rootRef = useRef<HTMLDivElement | null>(null);
|
|
63
66
|
// Mirrored as state so descendants portaling *into* the player subtree
|
|
@@ -74,6 +77,8 @@ export function Player({
|
|
|
74
77
|
const [blackout, setBlackout] = useState<'black' | 'white' | null>(null);
|
|
75
78
|
const [laser, setLaser] = useState(false);
|
|
76
79
|
const [keyboardDriven, setKeyboardDriven] = useState(false);
|
|
80
|
+
const [mobileChromeVisible, setMobileChromeVisible] = useState(false);
|
|
81
|
+
const [mobileChromeDeadline, setMobileChromeDeadline] = useState(0);
|
|
77
82
|
const [startedAt] = useState(() => Date.now());
|
|
78
83
|
const [windowed, setWindowed] = useState(!fullscreen);
|
|
79
84
|
// Mirror windowed into a ref so the fullscreenchange listener can read the
|
|
@@ -118,6 +123,54 @@ export function Player({
|
|
|
118
123
|
}, [index, pages.length, handleIndexChange]);
|
|
119
124
|
|
|
120
125
|
const overlayActive = controls && (overviewOpen || helpOpen);
|
|
126
|
+
const overlayActiveRef = useRef(overlayActive);
|
|
127
|
+
const showMobileChrome = useCallback(() => {
|
|
128
|
+
if (!controls || !isMobile) return;
|
|
129
|
+
setMobileChromeVisible(true);
|
|
130
|
+
setMobileChromeDeadline(Date.now() + MOBILE_CHROME_HIDE_MS);
|
|
131
|
+
}, [controls, isMobile]);
|
|
132
|
+
const handleMobileViewportClick = useCallback(
|
|
133
|
+
({ y }: { x: number; y: number }) => {
|
|
134
|
+
if (!controls || !isMobile || y < 0.5) return;
|
|
135
|
+
showMobileChrome();
|
|
136
|
+
},
|
|
137
|
+
[controls, isMobile, showMobileChrome],
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
if (!controls || !isMobile) {
|
|
142
|
+
setMobileChromeVisible(false);
|
|
143
|
+
setMobileChromeDeadline(0);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
setMobileChromeVisible(true);
|
|
147
|
+
setMobileChromeDeadline(Date.now() + MOBILE_CHROME_HIDE_MS);
|
|
148
|
+
}, [controls, isMobile]);
|
|
149
|
+
|
|
150
|
+
useEffect(() => {
|
|
151
|
+
const wasOverlayActive = overlayActiveRef.current;
|
|
152
|
+
overlayActiveRef.current = overlayActive;
|
|
153
|
+
if (wasOverlayActive && !overlayActive) showMobileChrome();
|
|
154
|
+
}, [overlayActive, showMobileChrome]);
|
|
155
|
+
|
|
156
|
+
useEffect(() => {
|
|
157
|
+
if (
|
|
158
|
+
!controls ||
|
|
159
|
+
!isMobile ||
|
|
160
|
+
overlayActive ||
|
|
161
|
+
!mobileChromeVisible ||
|
|
162
|
+
mobileChromeDeadline === 0
|
|
163
|
+
) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const id = window.setTimeout(
|
|
167
|
+
() => {
|
|
168
|
+
setMobileChromeVisible(false);
|
|
169
|
+
},
|
|
170
|
+
Math.max(0, mobileChromeDeadline - Date.now()),
|
|
171
|
+
);
|
|
172
|
+
return () => window.clearTimeout(id);
|
|
173
|
+
}, [controls, isMobile, mobileChromeDeadline, mobileChromeVisible, overlayActive]);
|
|
121
174
|
|
|
122
175
|
useClickPageNavigation({
|
|
123
176
|
ref: rootRef,
|
|
@@ -126,6 +179,7 @@ export function Player({
|
|
|
126
179
|
canNext,
|
|
127
180
|
onPrev: goPrev,
|
|
128
181
|
onNext: goNext,
|
|
182
|
+
onViewportClick: controls && isMobile ? handleMobileViewportClick : undefined,
|
|
129
183
|
});
|
|
130
184
|
|
|
131
185
|
useWheelPageNavigation({
|
|
@@ -318,8 +372,11 @@ export function Player({
|
|
|
318
372
|
// The control bar + progress strip only surface when the pointer is in
|
|
319
373
|
// the bottom hot zone. Keyboard nav (arrows / space / PgDn) never reveals
|
|
320
374
|
// them — intentional so the deck stays clean during a talk.
|
|
321
|
-
const pointerNearBottom = usePointerNearBottom(
|
|
322
|
-
|
|
375
|
+
const pointerNearBottom = usePointerNearBottom(
|
|
376
|
+
BAR_HOTZONE_PX,
|
|
377
|
+
controls && !overlayActive && !isMobile,
|
|
378
|
+
);
|
|
379
|
+
const chromeVisible = overlayActive || (isMobile ? mobileChromeVisible : pointerNearBottom);
|
|
323
380
|
const idle = useIdle(IDLE_HIDE_MS, controls && !overlayActive);
|
|
324
381
|
|
|
325
382
|
useEffect(() => {
|
|
@@ -330,7 +387,9 @@ export function Player({
|
|
|
330
387
|
}, [keyboardDriven]);
|
|
331
388
|
|
|
332
389
|
const hideCursor =
|
|
333
|
-
controls &&
|
|
390
|
+
controls &&
|
|
391
|
+
!isMobile &&
|
|
392
|
+
(laser || keyboardDriven || (idle && !overlayActive && !pointerNearBottom));
|
|
334
393
|
|
|
335
394
|
return (
|
|
336
395
|
<div
|
|
@@ -340,6 +399,7 @@ export function Player({
|
|
|
340
399
|
controls && 'select-none',
|
|
341
400
|
controls && (hideCursor ? 'cursor-none' : 'cursor-default'),
|
|
342
401
|
)}
|
|
402
|
+
style={design ? { background: design.palette.bg } : undefined}
|
|
343
403
|
>
|
|
344
404
|
<SlideCanvas flat design={design}>
|
|
345
405
|
<SlideTransitionLayer
|
|
@@ -372,6 +432,7 @@ export function Player({
|
|
|
372
432
|
windowed={windowed}
|
|
373
433
|
onPrev={goPrev}
|
|
374
434
|
onNext={goNext}
|
|
435
|
+
onMobileInteraction={showMobileChrome}
|
|
375
436
|
onOverview={() => setOverviewOpen(true)}
|
|
376
437
|
onBlackout={(mode) => setBlackout((c) => (c === mode ? null : mode))}
|
|
377
438
|
onLaser={() => setLaser((v) => !v)}
|
|
@@ -388,6 +449,8 @@ export function Player({
|
|
|
388
449
|
onClose={() => setOverviewOpen(false)}
|
|
389
450
|
onSelect={handleIndexChange}
|
|
390
451
|
variant="present"
|
|
452
|
+
moduleTransition={transition}
|
|
453
|
+
tooltipContainer={rootEl}
|
|
391
454
|
/>
|
|
392
455
|
<PresentHelpOverlay open={helpOpen} onOpenChange={setHelpOpen} container={rootEl} />
|
|
393
456
|
</div>
|
|
@@ -29,6 +29,7 @@ type Props = {
|
|
|
29
29
|
windowed: boolean;
|
|
30
30
|
onPrev: () => void;
|
|
31
31
|
onNext: () => void;
|
|
32
|
+
onMobileInteraction: () => void;
|
|
32
33
|
onOverview: () => void;
|
|
33
34
|
onBlackout: (mode: 'black' | 'white') => void;
|
|
34
35
|
onLaser: () => void;
|
|
@@ -55,6 +56,7 @@ export function PresentControlBar({
|
|
|
55
56
|
windowed,
|
|
56
57
|
onPrev,
|
|
57
58
|
onNext,
|
|
59
|
+
onMobileInteraction,
|
|
58
60
|
onOverview,
|
|
59
61
|
onBlackout,
|
|
60
62
|
onLaser,
|
|
@@ -65,11 +67,17 @@ export function PresentControlBar({
|
|
|
65
67
|
tooltipContainer,
|
|
66
68
|
}: Props) {
|
|
67
69
|
const t = useLocale();
|
|
70
|
+
const fullscreenAria = windowed ? t.present.enterFullscreenAria : t.present.exitFullscreenAria;
|
|
71
|
+
const handleMobileAction = (action: () => void) => {
|
|
72
|
+
action();
|
|
73
|
+
onMobileInteraction();
|
|
74
|
+
};
|
|
75
|
+
|
|
68
76
|
return (
|
|
69
77
|
<div
|
|
70
78
|
data-state={visible ? 'visible' : 'hidden'}
|
|
71
79
|
className={cn(
|
|
72
|
-
'pointer-events-none absolute inset-x-0 bottom-0 z-40 flex justify-center px-4 pb-4',
|
|
80
|
+
'pointer-events-none absolute inset-x-0 bottom-0 z-40 flex justify-center px-3 pb-[calc(0.75rem+env(safe-area-inset-bottom))] md:px-4 md:pb-4',
|
|
73
81
|
'will-change-[translate,scale,opacity,filter]',
|
|
74
82
|
'motion-safe:transition-[translate,scale,opacity,filter]',
|
|
75
83
|
'motion-safe:duration-[420ms] motion-safe:[transition-timing-function:cubic-bezier(0.22,1,0.36,1)]',
|
|
@@ -80,7 +88,12 @@ export function PresentControlBar({
|
|
|
80
88
|
>
|
|
81
89
|
<TooltipProvider delayDuration={300}>
|
|
82
90
|
<TooltipContainerCtx.Provider value={tooltipContainer ?? null}>
|
|
83
|
-
<div
|
|
91
|
+
<div
|
|
92
|
+
className={cn(
|
|
93
|
+
'hidden h-11 items-center gap-1 rounded-full border border-white/10 bg-black/55 px-2 text-white/85 shadow-[0_8px_30px_-8px_oklch(0_0_0/0.6)] backdrop-blur-md md:flex',
|
|
94
|
+
visible ? 'pointer-events-auto' : 'pointer-events-none',
|
|
95
|
+
)}
|
|
96
|
+
>
|
|
84
97
|
<BarButton label={t.present.prevSlideAria} onClick={onPrev} disabled={index === 0}>
|
|
85
98
|
<ChevronLeft className="size-4" />
|
|
86
99
|
</BarButton>
|
|
@@ -129,10 +142,7 @@ export function PresentControlBar({
|
|
|
129
142
|
<BarButton label={t.present.presenterAria} onClick={onPresenter}>
|
|
130
143
|
<MonitorSpeaker className="size-4" />
|
|
131
144
|
</BarButton>
|
|
132
|
-
<BarButton
|
|
133
|
-
label={windowed ? t.present.enterFullscreenAria : t.present.exitFullscreenAria}
|
|
134
|
-
onClick={onToggleFullscreen}
|
|
135
|
-
>
|
|
145
|
+
<BarButton label={fullscreenAria} onClick={onToggleFullscreen}>
|
|
136
146
|
{windowed ? <Maximize className="size-4" /> : <Minimize className="size-4" />}
|
|
137
147
|
</BarButton>
|
|
138
148
|
<BarButton label={t.present.helpAria} onClick={onHelp}>
|
|
@@ -148,12 +158,91 @@ export function PresentControlBar({
|
|
|
148
158
|
</>
|
|
149
159
|
)}
|
|
150
160
|
</div>
|
|
161
|
+
|
|
162
|
+
<div
|
|
163
|
+
className={cn(
|
|
164
|
+
'flex w-fit max-w-[calc(100vw-1.5rem)] md:hidden',
|
|
165
|
+
visible ? 'pointer-events-auto' : 'pointer-events-none',
|
|
166
|
+
)}
|
|
167
|
+
>
|
|
168
|
+
<div className="flex h-10 w-fit items-center gap-0.5 rounded-full border border-white/10 bg-black/60 px-1 text-white/85 shadow-[0_8px_30px_-8px_oklch(0_0_0/0.65)] backdrop-blur-md">
|
|
169
|
+
<MobileBarButton
|
|
170
|
+
label={t.present.prevSlideAria}
|
|
171
|
+
onClick={() => handleMobileAction(onPrev)}
|
|
172
|
+
disabled={index === 0}
|
|
173
|
+
>
|
|
174
|
+
<ChevronLeft className="size-4" />
|
|
175
|
+
</MobileBarButton>
|
|
176
|
+
<span className="min-w-[3.5rem] px-1 text-center font-mono text-[11.5px] tabular-nums text-white/80 select-none">
|
|
177
|
+
<span className="text-white">{index + 1}</span>
|
|
178
|
+
<span className="px-1 text-white/35">/</span>
|
|
179
|
+
<span>{total}</span>
|
|
180
|
+
</span>
|
|
181
|
+
<MobileBarButton
|
|
182
|
+
label={t.present.nextSlideAria}
|
|
183
|
+
onClick={() => handleMobileAction(onNext)}
|
|
184
|
+
disabled={index >= total - 1}
|
|
185
|
+
>
|
|
186
|
+
<ChevronRight className="size-4" />
|
|
187
|
+
</MobileBarButton>
|
|
188
|
+
<MobileDivider />
|
|
189
|
+
<MobileBarButton
|
|
190
|
+
label={t.present.overviewAria}
|
|
191
|
+
onClick={() => handleMobileAction(onOverview)}
|
|
192
|
+
>
|
|
193
|
+
<Grid2x2 className="size-4" />
|
|
194
|
+
</MobileBarButton>
|
|
195
|
+
{allowExit && (
|
|
196
|
+
<MobileBarButton
|
|
197
|
+
label={t.present.exitAria}
|
|
198
|
+
onClick={() => handleMobileAction(onExit)}
|
|
199
|
+
>
|
|
200
|
+
<LogOut className="size-4" />
|
|
201
|
+
</MobileBarButton>
|
|
202
|
+
)}
|
|
203
|
+
</div>
|
|
204
|
+
</div>
|
|
151
205
|
</TooltipContainerCtx.Provider>
|
|
152
206
|
</TooltipProvider>
|
|
153
207
|
</div>
|
|
154
208
|
);
|
|
155
209
|
}
|
|
156
210
|
|
|
211
|
+
function MobileBarButton({
|
|
212
|
+
children,
|
|
213
|
+
label,
|
|
214
|
+
onClick,
|
|
215
|
+
disabled,
|
|
216
|
+
}: {
|
|
217
|
+
children: React.ReactNode;
|
|
218
|
+
label: string;
|
|
219
|
+
onClick: () => void;
|
|
220
|
+
disabled?: boolean;
|
|
221
|
+
}) {
|
|
222
|
+
return (
|
|
223
|
+
<button
|
|
224
|
+
type="button"
|
|
225
|
+
aria-label={label}
|
|
226
|
+
disabled={disabled}
|
|
227
|
+
onClick={(event) => {
|
|
228
|
+
event.stopPropagation();
|
|
229
|
+
onClick();
|
|
230
|
+
}}
|
|
231
|
+
className={cn(
|
|
232
|
+
'inline-flex size-8 shrink-0 touch-manipulation items-center justify-center rounded-full transition-colors',
|
|
233
|
+
'text-white/85 hover:bg-white/12 focus-visible:bg-white/12 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/35',
|
|
234
|
+
'disabled:pointer-events-none disabled:opacity-30',
|
|
235
|
+
)}
|
|
236
|
+
>
|
|
237
|
+
{children}
|
|
238
|
+
</button>
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function MobileDivider() {
|
|
243
|
+
return <span aria-hidden className="mx-0.5 h-3.5 w-px shrink-0 bg-white/15" />;
|
|
244
|
+
}
|
|
245
|
+
|
|
157
246
|
function BarButton({
|
|
158
247
|
children,
|
|
159
248
|
label,
|
|
@@ -175,7 +264,10 @@ function BarButton({
|
|
|
175
264
|
type="button"
|
|
176
265
|
aria-label={label}
|
|
177
266
|
disabled={disabled}
|
|
178
|
-
onClick={
|
|
267
|
+
onClick={(event) => {
|
|
268
|
+
event.stopPropagation();
|
|
269
|
+
onClick();
|
|
270
|
+
}}
|
|
179
271
|
className={cn(
|
|
180
272
|
'inline-flex size-8 items-center justify-center rounded-full transition-colors',
|
|
181
273
|
'hover:bg-white/12 focus-visible:bg-white/12 focus-visible:outline-none',
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Children,
|
|
3
|
+
type CSSProperties,
|
|
4
|
+
cloneElement,
|
|
5
|
+
isValidElement,
|
|
6
|
+
type ReactElement,
|
|
7
|
+
type ReactNode,
|
|
8
|
+
} from 'react';
|
|
9
|
+
|
|
10
|
+
export type unstable_SharedElementProps = {
|
|
11
|
+
id: string;
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
className?: string;
|
|
14
|
+
style?: CSSProperties;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
type SharedElementChildProps = {
|
|
18
|
+
className?: string;
|
|
19
|
+
style?: CSSProperties;
|
|
20
|
+
'data-osd-shared-element'?: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export function unstable_SharedElement({
|
|
24
|
+
id,
|
|
25
|
+
children,
|
|
26
|
+
className,
|
|
27
|
+
style,
|
|
28
|
+
}: unstable_SharedElementProps) {
|
|
29
|
+
const child = Children.toArray(children)[0] ?? null;
|
|
30
|
+
|
|
31
|
+
if (
|
|
32
|
+
Children.count(children) === 1 &&
|
|
33
|
+
isValidElement<SharedElementChildProps>(child) &&
|
|
34
|
+
typeof child.type === 'string'
|
|
35
|
+
) {
|
|
36
|
+
return cloneElement(child as ReactElement<SharedElementChildProps>, {
|
|
37
|
+
'data-osd-shared-element': id,
|
|
38
|
+
className: [child.props.className, className].filter(Boolean).join(' ') || undefined,
|
|
39
|
+
style: style ? { ...child.props.style, ...style } : child.props.style,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<div className={className} style={style} data-osd-shared-element={id}>
|
|
45
|
+
{children}
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
}
|