@anthusai/papyrus 1.0.0-next.4 → 1.0.0-next.41
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/amplify/auth/redirect-urls.js +54 -0
- package/amplify/auth/redirect-urls.ts +66 -0
- package/amplify/auth/resource.js +20 -5
- package/amplify/auth/resource.ts +27 -5
- package/amplify/data/resource.js +28 -70
- package/amplify/data/resource.ts +29 -70
- package/amplify/data/schema.js +33 -58
- package/amplify/data/schema.ts +34 -58
- package/amplify/functions/category-action/handler.ts +5 -3
- package/amplify/functions/console-chat-responder/py/execute_tactus_runner.py +0 -10
- package/amplify/functions/console-chat-responder/resource.js +0 -7
- package/amplify/functions/console-chat-responder/resource.ts +0 -8
- package/amplify/functions/console-chat-responder/src/main.rs +0 -9
- package/amplify/functions/content-actions/handler.py +45 -3
- package/amplify/functions/shared/reference-curation-metadata.ts +29 -0
- package/amplify/inbound-email/ses-intake.js +86 -0
- package/amplify/inbound-email/ses-intake.ts +110 -0
- package/amplify/rebuild-trigger-settings.js +22 -0
- package/amplify/rebuild-trigger-settings.ts +42 -0
- package/amplify/resolver-waves.js +26 -0
- package/amplify/resolver-waves.ts +34 -0
- package/amplify/site-backend-config.ts +36 -1
- package/amplify/site-backend-names.js +103 -0
- package/amplify/site-backend-names.ts +166 -0
- package/amplify/site-backend.js +93 -170
- package/amplify/site-backend.ts +126 -196
- package/amplify/storage/resource.js +3 -0
- package/amplify/storage/resource.ts +3 -0
- package/amplify/storage-backups/construct.js +31 -0
- package/amplify/storage-backups/construct.ts +47 -0
- package/app/%5F_preview/[[...path]]/route.ts +8 -0
- package/app/[year]/[month]/[day]/[articleSlug]/page.tsx +2 -0
- package/app/[year]/[month]/[day]/edition-route-page.tsx +2 -0
- package/app/api/media/[...path]/route.ts +5 -16
- package/app/api/revalidate/route.ts +8 -7
- package/app/articles/[slug]/page.tsx +6 -4
- package/app/blog-rhythm.css +278 -0
- package/app/globals.css +21 -0
- package/app/layout.tsx +16 -0
- package/app/newsroom/[section]/[...selection]/page.tsx +6 -5
- package/app/newsroom/[section]/page.tsx +4 -3
- package/app/newsroom/articles/[id]/page.tsx +15 -0
- package/app/newsroom/articles/page.tsx +13 -0
- package/app/newsroom/layout.tsx +4 -9
- package/app/page.tsx +18 -5
- package/app/robots.ts +2 -5
- package/bin/papyrus-app.mjs +12 -2
- package/bin/papyrus-infra.mjs +29 -3
- package/components/amplify-client-provider.tsx +4 -22
- package/components/archive-shell.tsx +2 -22
- package/components/article-video.tsx +247 -3
- package/components/blog-page-background.tsx +23 -6
- package/components/markus-ir-preview.tsx +300 -0
- package/components/news-desk-taxonomy-client.ts +51 -0
- package/components/newspaper.tsx +6 -2
- package/components/newsroom-access-gate.tsx +67 -0
- package/components/newsroom-article-editor.tsx +741 -0
- package/components/newsroom-articles-view.tsx +129 -0
- package/components/newsroom-client-shell.tsx +12 -0
- package/components/newsroom-ops-overview.tsx +28 -11
- package/components/newsroom-ops-shell.tsx +3 -1
- package/components/newsroom-references-view.tsx +83 -8
- package/components/papyrus-console-shell.tsx +4 -2
- package/components/pictogram-figure.tsx +9 -2
- package/components/presentation-header.tsx +135 -0
- package/components/presentation-rhythm-hrule.tsx +17 -0
- package/components/reference-cyclotron-status.tsx +109 -0
- package/components/reference-relevance-review.tsx +75 -0
- package/components/settings-page.tsx +2 -1
- package/components/topic-steering-workspace.tsx +54 -64
- package/components/use-blog-header-obstacles.ts +81 -0
- package/components/use-brand-fonts-ready.ts +28 -0
- package/components/use-rhythm-overlay.ts +29 -0
- package/infra/amplify-app-shell.js +228 -50
- package/infra/amplify-app-shell.ts +256 -53
- package/infra/build-specs.js +15 -5
- package/infra/build-specs.ts +18 -7
- package/infra/github-oidc-provider.js +24 -0
- package/infra/github-oidc-provider.ts +30 -0
- package/infra/index.js +1 -0
- package/infra/site-config.js +236 -11
- package/infra/site-config.ts +276 -15
- package/lib/amplify-outputs-path.ts +5 -1
- package/lib/blog-feature-solver.ts +459 -0
- package/lib/blog-rhythm.ts +134 -0
- package/lib/brand-fonts-watch.ts +43 -0
- package/lib/brand-fonts.ts +112 -0
- package/lib/cached-content-repository.ts +12 -0
- package/lib/category-repository.ts +42 -93
- package/lib/content-actions-demo.ts +190 -0
- package/lib/content-repository.ts +3 -0
- package/lib/content-source-context.ts +12 -2
- package/lib/content-types.ts +4 -0
- package/lib/edition-routes.ts +31 -29
- package/lib/graphql-content-repository.ts +61 -9
- package/lib/media-route-response.ts +45 -0
- package/lib/newspaper-layout.ts +3 -2
- package/lib/newsroom-articles.ts +325 -0
- package/lib/newsroom-base-path.ts +12 -3
- package/lib/newsroom-category-drilldown.ts +3 -2
- package/lib/newsroom-demo-articles.ts +90 -0
- package/lib/newsroom-forum-routes.ts +6 -4
- package/lib/newsroom-index-filters.ts +14 -10
- package/lib/newsroom-media-backend.ts +142 -0
- package/lib/newsroom-media.ts +182 -0
- package/lib/newsroom-nav.ts +3 -0
- package/lib/oauth-redirect-priority.ts +40 -0
- package/lib/papyrus-web-locations.ts +7 -6
- package/lib/presentation-footer.ts +3 -2
- package/lib/pretext-layout.ts +12 -3
- package/lib/reader-base-path.ts +24 -0
- package/lib/reader-static-params.ts +13 -0
- package/lib/reference-policy.ts +5 -0
- package/lib/relevance-decisions.ts +103 -0
- package/lib/relevance-status.ts +63 -0
- package/lib/renderer.ts +7 -0
- package/lib/revalidate-secret.ts +59 -0
- package/lib/robots-policy.ts +14 -0
- package/lib/root-route-redirect.ts +16 -0
- package/lib/semantic-graph.ts +7 -0
- package/lib/site-brand.ts +51 -0
- package/lib/staging-gated-path.ts +23 -0
- package/lib/staging-preview-object.ts +114 -0
- package/lib/video-mode.ts +42 -0
- package/lib/video-script.ts +77 -0
- package/middleware.ts +23 -18
- package/package.json +45 -1
- package/renderers/pretext/article-page.tsx +39 -3
- package/renderers/pretext/presentation-shared.tsx +113 -0
- package/renderers/pretext/presentation-shell.tsx +15 -102
- package/renderers/pretext/rhythm-article-page.tsx +165 -0
- package/renderers/pretext/rhythm-blog-presentation.tsx +279 -0
- package/renderers/pretext/rhythm-shell-style.ts +35 -0
- package/routes.manifest.json +45 -2
- package/scripts/videoml/build-browser-bundle.mjs +22 -0
- package/scripts/videoml/build-preview-bundle.mjs +50 -0
- package/scripts/videoml/bundle-common.mjs +129 -0
- package/scripts/videoml/preview/preview-entry.tsx +381 -0
- package/scripts/videoml/preview/preview-stage-fit.ts +28 -0
- package/scripts/videoml/preview/preview-timing.ts +42 -0
- package/scripts/videoml/preview.html +77 -0
- package/scripts/videoml/standard-entry.tsx +46 -0
- package/src/sync.mjs +30 -6
- package/src/with-papyrus.mjs +19 -2
- package/amplify/functions/graphql-jwt-authorizer/handler.ts +0 -193
- package/amplify/functions/graphql-jwt-authorizer/resource.js +0 -14
- package/amplify/functions/graphql-jwt-authorizer/resource.ts +0 -15
|
@@ -8,6 +8,8 @@ import { CookieStorage, Hub } from "aws-amplify/utils";
|
|
|
8
8
|
import { useEffect } from "react";
|
|
9
9
|
import { assertSandboxAmplifyOutputsForDev } from "../lib/amplify-outputs-guard";
|
|
10
10
|
import amplifyOutputs from "papyrus-amplify-outputs";
|
|
11
|
+
import { getPublicNewsroomBasePath } from "../lib/newsroom-base-path";
|
|
12
|
+
import { prioritizeRedirectUrlsForOrigin } from "../lib/oauth-redirect-priority";
|
|
11
13
|
|
|
12
14
|
let configured = false;
|
|
13
15
|
|
|
@@ -72,14 +74,10 @@ function prioritizeCurrentOrigin(config: ResourcesConfig): ResourcesConfig {
|
|
|
72
74
|
const auth = (config as { auth?: { oauth?: Record<string, unknown> } }).auth;
|
|
73
75
|
const oauth = auth?.oauth;
|
|
74
76
|
if (!auth || !oauth) return config;
|
|
75
|
-
const origin = normalizeUrlOrigin(window.location.origin);
|
|
76
77
|
const reorder = (urls: unknown) => {
|
|
77
78
|
if (!Array.isArray(urls)) return urls;
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
if (!head.length) return normalized;
|
|
81
|
-
const tail = normalized.filter((value) => normalizeUrlOrigin(value) !== origin);
|
|
82
|
-
return [...head, ...tail];
|
|
79
|
+
const strings = urls.filter((value): value is string => typeof value === "string");
|
|
80
|
+
return prioritizeRedirectUrlsForOrigin(strings, window.location.origin, getPublicNewsroomBasePath());
|
|
83
81
|
};
|
|
84
82
|
return {
|
|
85
83
|
...config,
|
|
@@ -111,22 +109,6 @@ function redirectLoopbackToLocalhost(): void {
|
|
|
111
109
|
window.location.replace(target);
|
|
112
110
|
}
|
|
113
111
|
|
|
114
|
-
function normalizeUrlOrigin(value: string): string {
|
|
115
|
-
const trimmed = value.replace(/\/+$/, "");
|
|
116
|
-
try {
|
|
117
|
-
const parsed = new URL(trimmed);
|
|
118
|
-
const hostname = normalizeLoopbackHostname(parsed.hostname);
|
|
119
|
-
return `${parsed.protocol}//${hostname}${parsed.port ? `:${parsed.port}` : ""}`;
|
|
120
|
-
} catch {
|
|
121
|
-
return trimmed;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function normalizeLoopbackHostname(hostname: string): string {
|
|
126
|
-
if (hostname === "127.0.0.1" || hostname === "::1") return "localhost";
|
|
127
|
-
return hostname;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
112
|
function extractAuthFailureDetail(error: unknown): string | null {
|
|
131
113
|
if (!error) return null;
|
|
132
114
|
if (typeof error === "string") return error;
|
|
@@ -1,27 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import type { ReactNode } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { useRhythmOverlay } from "./use-rhythm-overlay";
|
|
5
5
|
|
|
6
6
|
type ArchiveShellProps = {
|
|
7
7
|
children: ReactNode;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
export function ArchiveShell({ children }: ArchiveShellProps) {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
const handleKeyDown = (event: KeyboardEvent) => {
|
|
15
|
-
if (isEditableEventTarget(event.target)) return;
|
|
16
|
-
if ((event.key === "=" || event.code === "Equal") && event.ctrlKey && !event.metaKey && !event.altKey) {
|
|
17
|
-
event.preventDefault();
|
|
18
|
-
setShowRhythmOverlay((current) => !current);
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
window.addEventListener("keydown", handleKeyDown);
|
|
23
|
-
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
24
|
-
}, []);
|
|
11
|
+
const showRhythmOverlay = useRhythmOverlay();
|
|
25
12
|
|
|
26
13
|
return (
|
|
27
14
|
<main
|
|
@@ -32,10 +19,3 @@ export function ArchiveShell({ children }: ArchiveShellProps) {
|
|
|
32
19
|
</main>
|
|
33
20
|
);
|
|
34
21
|
}
|
|
35
|
-
|
|
36
|
-
function isEditableEventTarget(target: EventTarget | null): boolean {
|
|
37
|
-
if (!(target instanceof HTMLElement)) return false;
|
|
38
|
-
const tagName = target.tagName.toLowerCase();
|
|
39
|
-
if (tagName === "input" || tagName === "textarea" || tagName === "select") return true;
|
|
40
|
-
return target.isContentEditable || target.closest("[contenteditable='true']") !== null;
|
|
41
|
-
}
|
|
@@ -1,31 +1,232 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { useEffect, useState } from "react";
|
|
3
|
+
import { useCallback, useEffect, useRef, useState, type CSSProperties } from "react";
|
|
4
|
+
import { Pause, Play } from "lucide-react";
|
|
4
5
|
import type { ArticleVideoAsset } from "../lib/articles";
|
|
5
6
|
import { resolveThemedVideoSrc } from "../lib/themed-image";
|
|
6
7
|
import { useResolvedPapyrusTheme } from "./use-resolved-papyrus-theme";
|
|
8
|
+
import { getSiteBrand } from "../lib/site-brand";
|
|
9
|
+
import { normalizeDevPreviewDsl, type VideoScriptRef } from "../lib/video-script";
|
|
10
|
+
import { resolveVideoMode, resolveVideoModeFromEnv, type VideoMode } from "../lib/video-mode";
|
|
7
11
|
|
|
8
12
|
type ArticleVideoFigureProps = {
|
|
9
13
|
video: ArticleVideoAsset;
|
|
10
14
|
slug: string;
|
|
11
15
|
figureClassName?: string;
|
|
12
16
|
priority?: boolean;
|
|
17
|
+
videoScript?: VideoScriptRef | null;
|
|
13
18
|
};
|
|
14
19
|
|
|
15
|
-
|
|
20
|
+
const PREVIEW_STORAGE_PREFIX = "papyrus-video-preview:";
|
|
21
|
+
|
|
22
|
+
export function ArticleVideoFigure({
|
|
23
|
+
video,
|
|
24
|
+
slug,
|
|
25
|
+
figureClassName = "article-photo article-video",
|
|
26
|
+
videoScript = null,
|
|
27
|
+
}: ArticleVideoFigureProps) {
|
|
16
28
|
const theme = useResolvedPapyrusTheme();
|
|
17
29
|
const [hasHydrated, setHasHydrated] = useState(false);
|
|
30
|
+
const [videoMode, setVideoMode] = useState<VideoMode>(() => resolveVideoModeFromEnv());
|
|
31
|
+
const [isPlaying, setIsPlaying] = useState(false);
|
|
32
|
+
const [currentTime, setCurrentTime] = useState(0);
|
|
33
|
+
const [duration, setDuration] = useState(0);
|
|
34
|
+
const [previewReady, setPreviewReady] = useState(false);
|
|
35
|
+
const iframeRef = useRef<HTMLIFrameElement>(null);
|
|
36
|
+
const videoRef = useRef<HTMLVideoElement>(null);
|
|
37
|
+
const isFramed = getSiteBrand().videoPlayer === "framed";
|
|
18
38
|
|
|
19
39
|
useEffect(() => {
|
|
20
40
|
setHasHydrated(true);
|
|
41
|
+
setVideoMode(resolveVideoMode());
|
|
21
42
|
}, []);
|
|
22
43
|
|
|
23
44
|
// Match SSR to the default dark MP4 in `video.src` until after hydration.
|
|
24
45
|
const resolvedTheme = hasHydrated ? theme : "dark";
|
|
25
46
|
const src = resolveThemedVideoSrc(video.src, video.themeVariants, resolvedTheme);
|
|
47
|
+
const usePreview = videoMode === "preview" && Boolean(videoScript?.dsl);
|
|
48
|
+
const previewDsl = videoScript?.dsl
|
|
49
|
+
? normalizeDevPreviewDsl(videoScript.dsl, getSiteBrand().video?.sceneComponents)
|
|
50
|
+
: null;
|
|
51
|
+
const previewSrc = `/videoml/preview.html?target=${encodeURIComponent(slug)}&theme=${resolvedTheme}${
|
|
52
|
+
src ? `&audio=${encodeURIComponent(src)}` : ""
|
|
53
|
+
}`;
|
|
54
|
+
|
|
55
|
+
if (usePreview && previewDsl && typeof window !== "undefined") {
|
|
56
|
+
sessionStorage.setItem(`${PREVIEW_STORAGE_PREFIX}${slug}`, previewDsl);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
setPreviewReady(false);
|
|
61
|
+
setIsPlaying(false);
|
|
62
|
+
setCurrentTime(0);
|
|
63
|
+
setDuration(0);
|
|
64
|
+
}, [previewSrc, usePreview]);
|
|
65
|
+
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (!usePreview || !previewReady) return;
|
|
68
|
+
iframeRef.current?.contentWindow?.postMessage(
|
|
69
|
+
{ kind: "papyrus-video-refresh", target: slug, theme: resolvedTheme, audio: src || undefined },
|
|
70
|
+
"*",
|
|
71
|
+
);
|
|
72
|
+
}, [previewReady, resolvedTheme, slug, src, usePreview]);
|
|
73
|
+
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
if (!usePreview) return;
|
|
76
|
+
const onMessage = (event: MessageEvent) => {
|
|
77
|
+
const payload = event.data;
|
|
78
|
+
if (!payload || typeof payload !== "object" || payload.kind !== "papyrus-video-time") return;
|
|
79
|
+
if (typeof payload.currentTime === "number") setCurrentTime(payload.currentTime);
|
|
80
|
+
if (typeof payload.duration === "number") setDuration(payload.duration);
|
|
81
|
+
};
|
|
82
|
+
window.addEventListener("message", onMessage);
|
|
83
|
+
return () => window.removeEventListener("message", onMessage);
|
|
84
|
+
}, [usePreview]);
|
|
85
|
+
|
|
86
|
+
const togglePreviewPlayback = useCallback(() => {
|
|
87
|
+
iframeRef.current?.contentWindow?.postMessage({ kind: isPlaying ? "papyrus-video-pause" : "papyrus-video-play" }, "*");
|
|
88
|
+
setIsPlaying(!isPlaying);
|
|
89
|
+
}, [isPlaying]);
|
|
90
|
+
|
|
91
|
+
const seekPreview = useCallback((nextTime: number) => {
|
|
92
|
+
const clamped = Math.max(0, Number.isFinite(nextTime) ? nextTime : 0);
|
|
93
|
+
iframeRef.current?.contentWindow?.postMessage({ kind: "papyrus-video-seek", time: clamped }, "*");
|
|
94
|
+
setCurrentTime(clamped);
|
|
95
|
+
}, []);
|
|
96
|
+
|
|
97
|
+
const toggleNativePlayback = useCallback(() => {
|
|
98
|
+
const element = videoRef.current;
|
|
99
|
+
if (!element) return;
|
|
100
|
+
if (element.paused) void element.play().catch(() => setIsPlaying(false));
|
|
101
|
+
else element.pause();
|
|
102
|
+
}, []);
|
|
103
|
+
|
|
104
|
+
const seekNative = useCallback((nextTime: number) => {
|
|
105
|
+
const element = videoRef.current;
|
|
106
|
+
if (!element) return;
|
|
107
|
+
element.currentTime = Math.max(0, Number.isFinite(nextTime) ? nextTime : 0);
|
|
108
|
+
setCurrentTime(element.currentTime);
|
|
109
|
+
}, []);
|
|
110
|
+
|
|
111
|
+
const framedControls = (
|
|
112
|
+
<FramedVideoControls
|
|
113
|
+
currentTime={currentTime}
|
|
114
|
+
duration={duration}
|
|
115
|
+
isPlaying={isPlaying}
|
|
116
|
+
onSeek={usePreview ? seekPreview : seekNative}
|
|
117
|
+
onToggle={usePreview ? togglePreviewPlayback : toggleNativePlayback}
|
|
118
|
+
/>
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
if (isFramed && usePreview) {
|
|
122
|
+
return (
|
|
123
|
+
<figure
|
|
124
|
+
className={`${figureClassName} article-video--framed article-video--preview`}
|
|
125
|
+
data-media-type="videoml-preview"
|
|
126
|
+
data-video-theme={resolvedTheme}
|
|
127
|
+
data-video-mode={videoMode}
|
|
128
|
+
>
|
|
129
|
+
<div className="article-video__media">
|
|
130
|
+
{hasHydrated ? (
|
|
131
|
+
<iframe
|
|
132
|
+
key={`${slug}-${resolvedTheme}-${src}`}
|
|
133
|
+
ref={iframeRef}
|
|
134
|
+
className="article-video__preview-frame"
|
|
135
|
+
src={previewSrc}
|
|
136
|
+
title={video.alt}
|
|
137
|
+
onLoad={() => setPreviewReady(true)}
|
|
138
|
+
/>
|
|
139
|
+
) : null}
|
|
140
|
+
</div>
|
|
141
|
+
{framedControls}
|
|
142
|
+
<span className="sr-only" data-video-slug={slug}>
|
|
143
|
+
{video.alt}
|
|
144
|
+
</span>
|
|
145
|
+
</figure>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (usePreview) {
|
|
150
|
+
return (
|
|
151
|
+
<figure
|
|
152
|
+
className={`${figureClassName} article-video--preview`}
|
|
153
|
+
data-media-type="videoml-preview"
|
|
154
|
+
data-video-theme={resolvedTheme}
|
|
155
|
+
data-video-mode={videoMode}
|
|
156
|
+
>
|
|
157
|
+
{hasHydrated ? (
|
|
158
|
+
<iframe
|
|
159
|
+
key={`${slug}-${resolvedTheme}-${src}`}
|
|
160
|
+
ref={iframeRef}
|
|
161
|
+
className="article-video__preview-frame"
|
|
162
|
+
src={previewSrc}
|
|
163
|
+
title={video.alt}
|
|
164
|
+
onLoad={() => setPreviewReady(true)}
|
|
165
|
+
/>
|
|
166
|
+
) : null}
|
|
167
|
+
<div className="article-video__preview-controls">
|
|
168
|
+
<button type="button" onClick={togglePreviewPlayback} aria-pressed={isPlaying}>
|
|
169
|
+
{isPlaying ? "Pause video" : "Play video"}
|
|
170
|
+
</button>
|
|
171
|
+
<input
|
|
172
|
+
type="range"
|
|
173
|
+
min={0}
|
|
174
|
+
max={duration || 0}
|
|
175
|
+
step={0.1}
|
|
176
|
+
value={Math.min(currentTime, duration || 0)}
|
|
177
|
+
onChange={(event) => seekPreview(Number(event.target.value))}
|
|
178
|
+
aria-label="Seek video"
|
|
179
|
+
disabled={!duration}
|
|
180
|
+
/>
|
|
181
|
+
</div>
|
|
182
|
+
{video.caption ? <figcaption>{video.caption}</figcaption> : null}
|
|
183
|
+
{video.credit ? <p className="article-video__credit">{video.credit}</p> : null}
|
|
184
|
+
<span className="sr-only" data-video-slug={slug}>
|
|
185
|
+
{video.alt}
|
|
186
|
+
</span>
|
|
187
|
+
</figure>
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (isFramed) {
|
|
192
|
+
return (
|
|
193
|
+
<figure
|
|
194
|
+
className={`${figureClassName} article-video--framed`}
|
|
195
|
+
data-media-type="video"
|
|
196
|
+
data-video-theme={resolvedTheme}
|
|
197
|
+
data-video-mode={videoMode}
|
|
198
|
+
>
|
|
199
|
+
<div className="article-video__media">
|
|
200
|
+
<video
|
|
201
|
+
ref={videoRef}
|
|
202
|
+
playsInline
|
|
203
|
+
preload="metadata"
|
|
204
|
+
poster={video.posterSrc}
|
|
205
|
+
aria-label={video.alt}
|
|
206
|
+
className="article-video__player"
|
|
207
|
+
key={hasHydrated ? src : "ssr"}
|
|
208
|
+
onPlay={() => setIsPlaying(true)}
|
|
209
|
+
onPause={() => setIsPlaying(false)}
|
|
210
|
+
onEnded={() => setIsPlaying(false)}
|
|
211
|
+
onTimeUpdate={(event) => setCurrentTime(event.currentTarget.currentTime)}
|
|
212
|
+
onDurationChange={(event) => {
|
|
213
|
+
const nextDuration = event.currentTarget.duration;
|
|
214
|
+
if (Number.isFinite(nextDuration) && nextDuration > 0) setDuration(nextDuration);
|
|
215
|
+
}}
|
|
216
|
+
>
|
|
217
|
+
<source src={src} type="video/mp4" />
|
|
218
|
+
</video>
|
|
219
|
+
</div>
|
|
220
|
+
{framedControls}
|
|
221
|
+
<span className="sr-only" data-video-slug={slug}>
|
|
222
|
+
{video.alt}
|
|
223
|
+
</span>
|
|
224
|
+
</figure>
|
|
225
|
+
);
|
|
226
|
+
}
|
|
26
227
|
|
|
27
228
|
return (
|
|
28
|
-
<figure className={figureClassName} data-media-type="video" data-video-theme={resolvedTheme}>
|
|
229
|
+
<figure className={figureClassName} data-media-type="video" data-video-theme={resolvedTheme} data-video-mode={videoMode}>
|
|
29
230
|
<video
|
|
30
231
|
controls
|
|
31
232
|
playsInline
|
|
@@ -45,3 +246,46 @@ export function ArticleVideoFigure({ video, slug, figureClassName = "article-pho
|
|
|
45
246
|
</figure>
|
|
46
247
|
);
|
|
47
248
|
}
|
|
249
|
+
|
|
250
|
+
function FramedVideoControls({
|
|
251
|
+
currentTime,
|
|
252
|
+
duration,
|
|
253
|
+
isPlaying,
|
|
254
|
+
onSeek,
|
|
255
|
+
onToggle,
|
|
256
|
+
}: {
|
|
257
|
+
currentTime: number;
|
|
258
|
+
duration: number;
|
|
259
|
+
isPlaying: boolean;
|
|
260
|
+
onSeek: (nextTime: number) => void;
|
|
261
|
+
onToggle: () => void;
|
|
262
|
+
}) {
|
|
263
|
+
const seekProgress = duration > 0 ? (currentTime / duration) * 100 : 0;
|
|
264
|
+
return (
|
|
265
|
+
<div className="article-video__cta" data-playing={isPlaying ? "true" : "false"}>
|
|
266
|
+
<button type="button" className="article-video__cta-toggle" onClick={onToggle} aria-pressed={isPlaying}>
|
|
267
|
+
<span className="article-video__cta-label">
|
|
268
|
+
<span className="article-video__cta-label-sizer" aria-hidden="true">
|
|
269
|
+
Pause Video
|
|
270
|
+
</span>
|
|
271
|
+
<span className="article-video__cta-label-text">{isPlaying ? "Pause Video" : "Play Video"}</span>
|
|
272
|
+
</span>
|
|
273
|
+
<span className="article-video__cta-icon" aria-hidden="true">
|
|
274
|
+
{isPlaying ? <Pause /> : <Play />}
|
|
275
|
+
</span>
|
|
276
|
+
</button>
|
|
277
|
+
<input
|
|
278
|
+
className="article-video__cta-seek"
|
|
279
|
+
type="range"
|
|
280
|
+
min={0}
|
|
281
|
+
max={duration || 0}
|
|
282
|
+
step={0.1}
|
|
283
|
+
value={Math.min(currentTime, duration || 0)}
|
|
284
|
+
onChange={(event) => onSeek(Number(event.target.value))}
|
|
285
|
+
aria-label="Seek video"
|
|
286
|
+
disabled={!duration}
|
|
287
|
+
style={{ "--seek-progress": `${seekProgress}%` } as CSSProperties}
|
|
288
|
+
/>
|
|
289
|
+
</div>
|
|
290
|
+
);
|
|
291
|
+
}
|
|
@@ -2,18 +2,35 @@
|
|
|
2
2
|
|
|
3
3
|
import type { RefObject } from "react";
|
|
4
4
|
|
|
5
|
+
/** A rectangle, in the background layer's own coordinates, that header text occupies. */
|
|
6
|
+
export type BlogHeaderObstacle = {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/** Vertical rhythm grid the rhythm blog layout is built on. */
|
|
14
|
+
export type BlogBackgroundRhythm = {
|
|
15
|
+
rowHeight: number;
|
|
16
|
+
paintBuffer: number;
|
|
17
|
+
paintHeight: number;
|
|
18
|
+
};
|
|
19
|
+
|
|
5
20
|
export type BlogPageBackgroundProps = {
|
|
6
21
|
pageRef: RefObject<HTMLElement | null>;
|
|
22
|
+
/** Rhythm blog layout only: header text boxes the artwork should keep clear of. */
|
|
23
|
+
headerObstacles?: BlogHeaderObstacle[];
|
|
24
|
+
/** Rhythm blog layout only: the rhythm grid, so artwork can align to it. */
|
|
25
|
+
rhythm?: BlogBackgroundRhythm;
|
|
7
26
|
};
|
|
8
27
|
|
|
9
28
|
/**
|
|
10
29
|
* Default (no-op) blog page background for publications without a bespoke
|
|
11
|
-
* backdrop.
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* `renderers/pretext` falls back to
|
|
15
|
-
* Intelligence, so the blog layout loads cleanly without depending on TI's
|
|
16
|
-
* package.
|
|
30
|
+
* backdrop. A publication supplies header artwork through the
|
|
31
|
+
* `components.BlogPageBackground` brand slot; with the rhythm blog layout the
|
|
32
|
+
* slot also receives `headerObstacles` and `rhythm`. This is what
|
|
33
|
+
* `renderers/pretext` falls back to when no slot component is registered.
|
|
17
34
|
*/
|
|
18
35
|
export function BlogPageBackground(_props: BlogPageBackgroundProps) {
|
|
19
36
|
return null;
|