@sdxc/ui 2026.11.11 → 2026.11.17
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 +114 -61
- package/dist/app/app-shell-toggle.d.ts +2 -0
- package/dist/app/app-shell-toggle.js +5 -2
- package/dist/app/app-shell.d.ts +25 -1
- package/dist/app/app-shell.js +73 -38
- package/dist/app/auto-refresh.d.ts +2 -0
- package/dist/app/auto-refresh.js +3 -3
- package/dist/app/behaviors/refresh-schedule.d.ts +8 -3
- package/dist/app/behaviors/refresh-schedule.js +4 -3
- package/dist/app/board.d.ts +123 -0
- package/dist/app/board.js +224 -0
- package/dist/app/chart.d.ts +2 -2
- package/dist/app/chart.js +7 -3
- package/dist/app/check-runs.d.ts +116 -0
- package/dist/app/check-runs.js +201 -0
- package/dist/app/code-view.d.ts +172 -0
- package/dist/app/code-view.js +414 -0
- package/dist/app/command-palette.d.ts +38 -3
- package/dist/app/command-palette.js +53 -5
- package/dist/app/contribution-graph.d.ts +106 -0
- package/dist/app/contribution-graph.js +289 -0
- package/dist/app/detail-sheet.d.ts +7 -0
- package/dist/app/detail-sheet.js +7 -7
- package/dist/app/diff.d.ts +200 -0
- package/dist/app/diff.js +702 -0
- package/dist/app/filter-bar.d.ts +20 -0
- package/dist/app/filter-bar.js +35 -15
- package/dist/app/filter-menu.d.ts +144 -0
- package/dist/app/filter-menu.js +480 -0
- package/dist/app/gantt.d.ts +108 -0
- package/dist/app/gantt.js +420 -0
- package/dist/app/index.d.ts +20 -0
- package/dist/app/index.js +20 -0
- package/dist/app/log-viewer.d.ts +120 -0
- package/dist/app/log-viewer.js +384 -0
- package/dist/app/merge-box.d.ts +97 -0
- package/dist/app/merge-box.js +227 -0
- package/dist/app/mixins/app-shell-controls.d.ts +4 -1
- package/dist/app/mixins/app-shell-controls.js +64 -4
- package/dist/app/mixins/auto-refresh.d.ts +5 -2
- package/dist/app/mixins/auto-refresh.js +9 -3
- package/dist/app/mixins/close-popover-on-submit.d.ts +16 -0
- package/dist/app/mixins/close-popover-on-submit.js +32 -0
- package/dist/app/mixins/code-view-selection.d.ts +60 -0
- package/dist/app/mixins/code-view-selection.js +276 -0
- package/dist/app/mixins/command-palette.d.ts +15 -4
- package/dist/app/mixins/command-palette.js +94 -6
- package/dist/app/mixins/contribution-graph-keys.d.ts +19 -0
- package/dist/app/mixins/contribution-graph-keys.js +155 -0
- package/dist/app/mixins/diff-interactions.d.ts +72 -0
- package/dist/app/mixins/diff-interactions.js +269 -0
- package/dist/app/mixins/filter-menu-keys.d.ts +41 -0
- package/dist/app/mixins/filter-menu-keys.js +91 -0
- package/dist/app/mixins/gantt-today.d.ts +17 -0
- package/dist/app/mixins/gantt-today.js +50 -0
- package/dist/app/mixins/log-viewer.d.ts +29 -0
- package/dist/app/mixins/log-viewer.js +347 -0
- package/dist/app/mixins/optimistic-toggle-sync.d.ts +5 -0
- package/dist/app/mixins/optimistic-toggle-sync.js +25 -1
- package/dist/app/mixins/save-bar-sync.d.ts +7 -1
- package/dist/app/mixins/save-bar-sync.js +23 -4
- package/dist/app/mixins/save-status-sync.js +23 -1
- package/dist/app/mixins/split-view.js +1 -1
- package/dist/app/mixins/submit-on-close.d.ts +17 -0
- package/dist/app/mixins/submit-on-close.js +52 -0
- package/dist/app/mixins/tree-filter.d.ts +44 -0
- package/dist/app/mixins/tree-filter.js +111 -0
- package/dist/app/mixins/tree-navigation.d.ts +50 -0
- package/dist/app/mixins/tree-navigation.js +216 -0
- package/dist/app/optimistic-toggle.d.ts +8 -0
- package/dist/app/optimistic-toggle.js +3 -2
- package/dist/app/page-header.d.ts +18 -3
- package/dist/app/page-header.js +105 -50
- package/dist/app/profile-picker.d.ts +47 -0
- package/dist/app/profile-picker.js +104 -0
- package/dist/app/review-thread.d.ts +115 -0
- package/dist/app/review-thread.js +116 -0
- package/dist/app/save-bar.d.ts +5 -0
- package/dist/app/save-bar.js +1 -1
- package/dist/app/save-status.js +1 -1
- package/dist/app/settings-layout.d.ts +5 -0
- package/dist/app/settings-layout.js +5 -5
- package/dist/app/skeleton.d.ts +9 -0
- package/dist/app/skeleton.js +28 -0
- package/dist/app/split-view.d.ts +4 -0
- package/dist/app/split-view.js +3 -3
- package/dist/app/styles/code-tokens.d.ts +24 -0
- package/dist/app/styles/code-tokens.js +47 -0
- package/dist/app/tab-bar.d.ts +59 -0
- package/dist/app/tab-bar.js +111 -0
- package/dist/app/tree.d.ts +111 -14
- package/dist/app/tree.js +202 -15
- package/dist/app/utils/ansi.d.ts +55 -0
- package/dist/app/utils/ansi.js +157 -0
- package/dist/app/utils/diff-rows.d.ts +82 -0
- package/dist/app/utils/diff-rows.js +209 -0
- package/dist/app/utils/fuzzy-path.d.ts +58 -0
- package/dist/app/utils/fuzzy-path.js +202 -0
- package/dist/app/utils/line-range.d.ts +48 -0
- package/dist/app/utils/line-range.js +61 -0
- package/dist/app/utils/log-lines.d.ts +107 -0
- package/dist/app/utils/log-lines.js +170 -0
- package/dist/app/utils/tree-filter.d.ts +19 -0
- package/dist/app/utils/tree-filter.js +26 -0
- package/dist/app/view-options.d.ts +2 -0
- package/dist/app/view-options.js +2 -2
- package/dist/chat/activity.d.ts +72 -0
- package/dist/chat/activity.js +184 -0
- package/dist/chat/composer-submit.d.ts +38 -0
- package/dist/chat/composer-submit.js +44 -0
- package/dist/chat/composer.d.ts +47 -0
- package/dist/chat/composer.js +100 -0
- package/dist/chat/index.d.ts +6 -0
- package/dist/chat/index.js +6 -0
- package/dist/chat/mixins/composer-send.d.ts +32 -0
- package/dist/chat/mixins/composer-send.js +121 -0
- package/dist/chat/mixins/reveal-stream.d.ts +68 -0
- package/dist/chat/mixins/reveal-stream.js +184 -0
- package/dist/chat/mixins/stream-target.d.ts +18 -0
- package/dist/chat/mixins/stream-target.js +38 -0
- package/dist/components/button.js +7 -1
- package/dist/components/character-count.d.ts +44 -0
- package/dist/components/character-count.js +68 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -0
- package/dist/components/label-chip.d.ts +42 -0
- package/dist/components/label-chip.js +86 -0
- package/dist/components/property-list.d.ts +9 -2
- package/dist/components/property-list.js +37 -10
- package/dist/components/textarea.js +6 -1
- package/dist/components/timeline.d.ts +62 -5
- package/dist/components/timeline.js +124 -5
- package/dist/docs/code-block.js +8 -31
- package/dist/docs/file-tree.js +3 -48
- package/dist/landing/case-study.d.ts +79 -0
- package/dist/landing/case-study.js +162 -0
- package/dist/landing/contributor-wall.d.ts +72 -0
- package/dist/landing/contributor-wall.js +129 -0
- package/dist/landing/countdown.d.ts +88 -0
- package/dist/landing/countdown.js +91 -0
- package/dist/landing/episode-player.d.ts +87 -0
- package/dist/landing/episode-player.js +113 -0
- package/dist/landing/faq-band.d.ts +3 -2
- package/dist/landing/faq-band.js +4 -3
- package/dist/landing/index.d.ts +7 -0
- package/dist/landing/index.js +7 -0
- package/dist/landing/landing-header.js +15 -4
- package/dist/landing/mixins/countdown-tick.d.ts +29 -0
- package/dist/landing/mixins/countdown-tick.js +65 -0
- package/dist/landing/mixins/usage-estimate-live.d.ts +32 -0
- package/dist/landing/mixins/usage-estimate-live.js +120 -0
- package/dist/landing/phone-frame.d.ts +2 -1
- package/dist/landing/price-list.d.ts +68 -0
- package/dist/landing/price-list.js +125 -0
- package/dist/landing/scroll-scene.d.ts +59 -0
- package/dist/landing/scroll-scene.js +70 -0
- package/dist/landing/sponsor-wall.d.ts +30 -6
- package/dist/landing/sponsor-wall.js +70 -14
- package/dist/landing/typed-terminal.d.ts +24 -6
- package/dist/landing/typed-terminal.js +22 -14
- package/dist/landing/usage-estimate.d.ts +127 -0
- package/dist/landing/usage-estimate.js +164 -0
- package/dist/landing/utils/countdown.d.ts +33 -0
- package/dist/landing/utils/countdown.js +42 -0
- package/dist/landing/utils/pause-toggle.d.ts +2 -1
- package/dist/mixins/character-count.d.ts +62 -0
- package/dist/mixins/character-count.js +139 -0
- package/dist/mixins/index.d.ts +6 -2
- package/dist/mixins/index.js +6 -2
- package/dist/mixins/invoker-fields.d.ts +18 -0
- package/dist/mixins/invoker-fields.js +60 -0
- package/dist/mixins/media-sync.d.ts +58 -0
- package/dist/mixins/media-sync.js +102 -0
- package/dist/mixins/menu-keys.d.ts +11 -0
- package/dist/mixins/menu-keys.js +79 -70
- package/dist/mixins/sortable.d.ts +96 -0
- package/dist/mixins/sortable.js +433 -0
- package/dist/utils/code-lines.d.ts +26 -0
- package/dist/utils/code-lines.js +29 -0
- package/dist/utils/file-icon.d.ts +31 -0
- package/dist/utils/file-icon.js +60 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/write-cookie.d.ts +15 -15
- package/dist/utils/write-cookie.js +10 -16
- package/dist/video/episode-list.d.ts +48 -0
- package/dist/video/episode-list.js +161 -0
- package/dist/video/index.d.ts +15 -0
- package/dist/video/index.js +15 -0
- package/dist/video/mixins/video-player-sync.d.ts +27 -0
- package/dist/video/mixins/video-player-sync.js +413 -0
- package/dist/video/mixins/video-shelf-steps.d.ts +20 -0
- package/dist/video/mixins/video-shelf-steps.js +79 -0
- package/dist/video/title-hero.d.ts +51 -0
- package/dist/video/title-hero.js +170 -0
- package/dist/video/utils/timeline.d.ts +55 -0
- package/dist/video/utils/timeline.js +90 -0
- package/dist/video/video-card.d.ts +51 -0
- package/dist/video/video-card.js +135 -0
- package/dist/video/video-player.d.ts +261 -0
- package/dist/video/video-player.js +927 -0
- package/dist/video/video-shelf.d.ts +58 -0
- package/dist/video/video-shelf.js +155 -0
- package/package.json +6 -3
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why JS: seeking in place, marking what plays, and a custom control bar all need the media
|
|
3
|
+
* element's API. No-JS baseline: every time is a `#t=` link into the file, and the video
|
|
4
|
+
* keeps the browser's own controls; this mixin swaps them for the bar when it runs.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import { createMixin } from "remix/component";
|
|
10
|
+
import { installMediaSync, markPlaying } from "../../mixins/media-sync.js";
|
|
11
|
+
import { installMenuKeys } from "../../mixins/menu-keys.js";
|
|
12
|
+
import { formatVideoTime, playedShare } from "../utils/timeline.js";
|
|
13
|
+
/** Items the top level of a settings menu walks: its rows, and none inside a submenu. */
|
|
14
|
+
const MENU_ITEMS = '[data-video-item]:not([data-slot="video-player-submenu-panel"] *)';
|
|
15
|
+
/** The playing-order lists a video player marks: its chapter links and transcript lines. */
|
|
16
|
+
const MARKS = ['[data-slot="video-player-chapters"] a', '[data-slot="video-player-cue"]'];
|
|
17
|
+
/**
|
|
18
|
+
* Fills each scrubber segment to its played share at `time`, and scrolls a newly current
|
|
19
|
+
* transcript line into view inside the transcript alone.
|
|
20
|
+
*/
|
|
21
|
+
function paintTimeline(root, time, changed) {
|
|
22
|
+
for (let bar of root.querySelectorAll('[data-slot="video-player-segment"]')) {
|
|
23
|
+
let share = playedShare(Number(bar.dataset.start), Number(bar.dataset.end), time);
|
|
24
|
+
bar.style.setProperty("--ui-video-player-played", `${share * 100}%`);
|
|
25
|
+
}
|
|
26
|
+
let line = changed.find((item) => item.dataset.slot === "video-player-cue");
|
|
27
|
+
let region = root.querySelector('[data-slot="video-player-transcript"]');
|
|
28
|
+
if (line && region)
|
|
29
|
+
region.scrollTop = line.offsetTop - region.clientHeight / 3;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Brings a player's marks to `time`: the chapter link and transcript line playing then
|
|
33
|
+
* carry `aria-current`, each scrubber segment fills to its played share, and a newly
|
|
34
|
+
* current line scrolls into view inside the transcript alone.
|
|
35
|
+
*
|
|
36
|
+
* @param root The player's `<figure>`.
|
|
37
|
+
* @param time The video's current time in seconds.
|
|
38
|
+
*/
|
|
39
|
+
export function syncVideo(root, time) {
|
|
40
|
+
let changed = MARKS.map((selector) => markPlaying(root.querySelectorAll(selector), time)).filter((item) => item !== undefined);
|
|
41
|
+
paintTimeline(root, time, changed);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The text tracks the captions controls choose between, in document order; a captions
|
|
45
|
+
* track written from an empty transcript is left out.
|
|
46
|
+
*/
|
|
47
|
+
function captionTracks(video) {
|
|
48
|
+
return [...video.querySelectorAll("track")]
|
|
49
|
+
.filter((track) => track.kind === "captions" || track.kind === "subtitles")
|
|
50
|
+
.filter((track) => !track.hasAttribute("data-empty"))
|
|
51
|
+
.map((track) => track.track);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Mirrors a menu input's checked state into `aria-checked`, which its menu item role
|
|
55
|
+
* requires; a radio updates every radio of its name.
|
|
56
|
+
*/
|
|
57
|
+
function syncChecked(input) {
|
|
58
|
+
let group = input.type === "radio"
|
|
59
|
+
? input.closest('[role="menu"]')?.querySelectorAll("input[type=radio]")
|
|
60
|
+
: undefined;
|
|
61
|
+
for (let item of group ?? [input])
|
|
62
|
+
item.setAttribute("aria-checked", String(item.checked));
|
|
63
|
+
}
|
|
64
|
+
/** Length of the video: the file's once known, else the timeline's the page declared. */
|
|
65
|
+
function lengthOf(video, progress) {
|
|
66
|
+
if (Number.isFinite(video.duration) && video.duration > 0)
|
|
67
|
+
return video.duration;
|
|
68
|
+
return Number(progress?.max ?? 0);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Wires one player's custom bar, with every handler ending when `signal` aborts: the bar
|
|
72
|
+
* replaces the native controls, buttons drive the video, built-in menu rows set speed,
|
|
73
|
+
* quality and captions, and the settings menu walks its panels by keyboard.
|
|
74
|
+
*/
|
|
75
|
+
class VideoControls {
|
|
76
|
+
root;
|
|
77
|
+
video;
|
|
78
|
+
signal;
|
|
79
|
+
/** The captions track the toggle turns back on, which the last choice decides. */
|
|
80
|
+
lastCaptions = 0;
|
|
81
|
+
constructor(root, video, signal) {
|
|
82
|
+
this.root = root;
|
|
83
|
+
this.video = video;
|
|
84
|
+
this.signal = signal;
|
|
85
|
+
}
|
|
86
|
+
/** Every control of `name` in the player. */
|
|
87
|
+
all(selector) {
|
|
88
|
+
return [...this.root.querySelectorAll(selector)];
|
|
89
|
+
}
|
|
90
|
+
/** Hides the native controls, reveals the bar, and restores both when the signal aborts. */
|
|
91
|
+
install(bar) {
|
|
92
|
+
let { root, signal, video } = this;
|
|
93
|
+
video.controls = false;
|
|
94
|
+
bar.hidden = false;
|
|
95
|
+
signal.addEventListener("abort", () => {
|
|
96
|
+
video.controls = true;
|
|
97
|
+
bar.hidden = true;
|
|
98
|
+
});
|
|
99
|
+
if (!document.fullscreenEnabled) {
|
|
100
|
+
for (let button of this.all('[data-video-action="fullscreen"]'))
|
|
101
|
+
button.hidden = true;
|
|
102
|
+
}
|
|
103
|
+
root.addEventListener("click", (event) => this.onClick(event), { signal });
|
|
104
|
+
root.addEventListener("change", (event) => this.onChange(event), { signal });
|
|
105
|
+
root.addEventListener("input", (event) => this.onInput(event), { signal });
|
|
106
|
+
root.addEventListener("keydown", (event) => this.onKeydown(event), { signal });
|
|
107
|
+
for (let type of ["play", "pause", "ended", "timeupdate", "durationchange", "ratechange"]) {
|
|
108
|
+
video.addEventListener(type, () => this.render(), { signal });
|
|
109
|
+
}
|
|
110
|
+
document.addEventListener("fullscreenchange", () => this.render(), { signal });
|
|
111
|
+
for (let menu of this.all('[data-slot="video-player-settings"]'))
|
|
112
|
+
this.installMenu(menu);
|
|
113
|
+
this.showCaptions(this.checkedCaptions());
|
|
114
|
+
this.render();
|
|
115
|
+
}
|
|
116
|
+
/** Runs the menu keyboard on each panel, and opens the menu on its top level. */
|
|
117
|
+
installMenu(menu) {
|
|
118
|
+
let { signal } = this;
|
|
119
|
+
let main = menu.querySelector('[data-slot="video-player-menu"]');
|
|
120
|
+
if (main)
|
|
121
|
+
installMenuKeys(main, signal, { itemSelector: MENU_ITEMS });
|
|
122
|
+
for (let panel of menu.querySelectorAll('[data-slot="video-player-submenu-panel"]')) {
|
|
123
|
+
installMenuKeys(panel, signal, { itemSelector: "[data-video-item]" });
|
|
124
|
+
}
|
|
125
|
+
menu.addEventListener("toggle", (event) => {
|
|
126
|
+
if (event.newState !== "open")
|
|
127
|
+
return;
|
|
128
|
+
this.closePanels(menu);
|
|
129
|
+
main?.querySelector(MENU_ITEMS)?.focus();
|
|
130
|
+
}, { signal });
|
|
131
|
+
}
|
|
132
|
+
/** Brings every control's state to the video's: playing, time, progress, captions, screen. */
|
|
133
|
+
render() {
|
|
134
|
+
let { root, video } = this;
|
|
135
|
+
let playing = !video.paused && !video.ended;
|
|
136
|
+
root.toggleAttribute("data-playing", playing);
|
|
137
|
+
for (let button of this.all('[data-video-action="play"]')) {
|
|
138
|
+
let label = playing ? button.dataset.labelPause : button.dataset.labelPlay;
|
|
139
|
+
if (label)
|
|
140
|
+
button.setAttribute("aria-label", label);
|
|
141
|
+
}
|
|
142
|
+
let progress = root.querySelector('[data-slot="video-player-progress"]');
|
|
143
|
+
let length = lengthOf(video, progress);
|
|
144
|
+
for (let elapsed of this.all('[data-slot="video-player-elapsed"]')) {
|
|
145
|
+
elapsed.textContent = formatVideoTime(video.currentTime);
|
|
146
|
+
}
|
|
147
|
+
for (let total of this.all('[data-slot="video-player-length"]')) {
|
|
148
|
+
total.textContent = formatVideoTime(length);
|
|
149
|
+
}
|
|
150
|
+
for (let input of this.all('[data-slot="video-player-progress"]')) {
|
|
151
|
+
input.max = String(length);
|
|
152
|
+
input.value = String(video.currentTime);
|
|
153
|
+
input.setAttribute("aria-valuetext", `${formatVideoTime(video.currentTime)} / ${formatVideoTime(length)}`);
|
|
154
|
+
input.style.setProperty("--ui-video-player-progress", `${length > 0 ? (video.currentTime / length) * 100 : 0}%`);
|
|
155
|
+
}
|
|
156
|
+
let screen = root.querySelector('[data-slot="video-player-screen"]');
|
|
157
|
+
let fullscreen = screen !== null && document.fullscreenElement === screen;
|
|
158
|
+
for (let button of this.all('[data-video-action="fullscreen"]')) {
|
|
159
|
+
button.setAttribute("aria-pressed", String(fullscreen));
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/** Runs a bar button, seeks from a time link, or plays and pauses from the picture. */
|
|
163
|
+
onClick(event) {
|
|
164
|
+
let target = event.target;
|
|
165
|
+
let button = target?.closest("[data-video-action]");
|
|
166
|
+
if (button) {
|
|
167
|
+
this.act(button);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (target instanceof HTMLVideoElement && target === this.video)
|
|
171
|
+
this.togglePlay();
|
|
172
|
+
}
|
|
173
|
+
/** What one bar button does. */
|
|
174
|
+
act(button) {
|
|
175
|
+
let { root } = this;
|
|
176
|
+
switch (button.dataset.videoAction) {
|
|
177
|
+
case "play":
|
|
178
|
+
this.togglePlay();
|
|
179
|
+
return;
|
|
180
|
+
case "captions": {
|
|
181
|
+
let showing = captionTracks(this.video).some((track) => track.mode === "showing");
|
|
182
|
+
this.showCaptions(showing ? -1 : this.lastCaptions);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
case "theater": {
|
|
186
|
+
let on = !root.hasAttribute("data-theater");
|
|
187
|
+
root.toggleAttribute("data-theater", on);
|
|
188
|
+
button.setAttribute("aria-pressed", String(on));
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
case "fullscreen":
|
|
192
|
+
void this.toggleFullscreen();
|
|
193
|
+
return;
|
|
194
|
+
case "open":
|
|
195
|
+
this.openPanel(button);
|
|
196
|
+
return;
|
|
197
|
+
case "back":
|
|
198
|
+
this.closePanel(button.closest('[data-slot="video-player-submenu-panel"]'));
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/** Plays a paused video and pauses a playing one. */
|
|
202
|
+
togglePlay() {
|
|
203
|
+
let { video } = this;
|
|
204
|
+
if (video.paused || video.ended)
|
|
205
|
+
void video.play().catch(() => undefined);
|
|
206
|
+
else
|
|
207
|
+
video.pause();
|
|
208
|
+
}
|
|
209
|
+
/** Puts the player's screen, bar included, in full screen, or takes it out. */
|
|
210
|
+
async toggleFullscreen() {
|
|
211
|
+
let screen = this.root.querySelector('[data-slot="video-player-screen"]');
|
|
212
|
+
if (!screen)
|
|
213
|
+
return;
|
|
214
|
+
if (document.fullscreenElement === screen)
|
|
215
|
+
await document.exitFullscreen();
|
|
216
|
+
else
|
|
217
|
+
await screen.requestFullscreen().catch(() => undefined);
|
|
218
|
+
}
|
|
219
|
+
/** Seeks as the progress slider moves. */
|
|
220
|
+
onInput(event) {
|
|
221
|
+
let input = event.target;
|
|
222
|
+
if (!(input instanceof HTMLInputElement))
|
|
223
|
+
return;
|
|
224
|
+
if (input.dataset.slot !== "video-player-progress")
|
|
225
|
+
return;
|
|
226
|
+
this.video.currentTime = Number(input.value);
|
|
227
|
+
syncVideo(this.root, this.video.currentTime);
|
|
228
|
+
this.render();
|
|
229
|
+
}
|
|
230
|
+
/** Applies a built-in setting, names the choice on its row and returns to the top level. */
|
|
231
|
+
onChange(event) {
|
|
232
|
+
let input = event.target;
|
|
233
|
+
if (!(input instanceof HTMLInputElement) || !input.hasAttribute("data-video-item"))
|
|
234
|
+
return;
|
|
235
|
+
syncChecked(input);
|
|
236
|
+
if (input.type !== "radio")
|
|
237
|
+
return;
|
|
238
|
+
let panel = input.closest('[data-slot="video-player-submenu-panel"]');
|
|
239
|
+
if (!panel)
|
|
240
|
+
return;
|
|
241
|
+
switch (panel.dataset.videoSetting) {
|
|
242
|
+
case "rate":
|
|
243
|
+
this.video.playbackRate = Number(input.value);
|
|
244
|
+
this.video.defaultPlaybackRate = Number(input.value);
|
|
245
|
+
break;
|
|
246
|
+
case "quality":
|
|
247
|
+
this.swapSource(Number(input.value));
|
|
248
|
+
break;
|
|
249
|
+
case "captions":
|
|
250
|
+
this.showCaptions(Number(input.value));
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
this.nameChoice(panel, input);
|
|
254
|
+
this.closePanel(panel);
|
|
255
|
+
}
|
|
256
|
+
/** Copies the checked option's label onto the row that opens its submenu. */
|
|
257
|
+
nameChoice(panel, input) {
|
|
258
|
+
let label = input
|
|
259
|
+
.closest("label")
|
|
260
|
+
?.querySelector('[data-slot="video-player-option-label"]')?.textContent;
|
|
261
|
+
let value = this.root
|
|
262
|
+
.querySelector(`[aria-controls="${panel.id}"]`)
|
|
263
|
+
?.querySelector('[data-slot="video-player-row-value"]');
|
|
264
|
+
if (value && label !== undefined && label !== null)
|
|
265
|
+
value.textContent = label;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* The menu keys the shared pattern leaves to the surface: → opens a submenu, ← returns from
|
|
269
|
+
* one, and Enter flips a checkbox or picks a radio the way Space does.
|
|
270
|
+
*/
|
|
271
|
+
onKeydown(event) {
|
|
272
|
+
let target = event.target;
|
|
273
|
+
if (!target?.closest('[data-slot="video-player-settings"]'))
|
|
274
|
+
return;
|
|
275
|
+
let panel = target.closest('[data-slot="video-player-submenu-panel"]');
|
|
276
|
+
if (event.key === "ArrowRight" && target.dataset.videoAction === "open") {
|
|
277
|
+
event.preventDefault();
|
|
278
|
+
this.openPanel(target);
|
|
279
|
+
}
|
|
280
|
+
else if (event.key === "ArrowLeft" && panel) {
|
|
281
|
+
event.preventDefault();
|
|
282
|
+
this.closePanel(panel);
|
|
283
|
+
}
|
|
284
|
+
else if (event.key === "ArrowRight" && panel) {
|
|
285
|
+
event.preventDefault();
|
|
286
|
+
}
|
|
287
|
+
else if (event.key === "Enter" && target instanceof HTMLInputElement) {
|
|
288
|
+
event.preventDefault();
|
|
289
|
+
target.click();
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
/** Shows the submenu a row opens in place of the top level, focusing its checked option. */
|
|
293
|
+
openPanel(trigger) {
|
|
294
|
+
let id = trigger.getAttribute("aria-controls");
|
|
295
|
+
let panel = id ? document.getElementById(id) : null;
|
|
296
|
+
let main = trigger.closest('[data-slot="video-player-menu"]');
|
|
297
|
+
if (!panel || !main)
|
|
298
|
+
return;
|
|
299
|
+
main.setAttribute("data-submenu", "");
|
|
300
|
+
panel.hidden = false;
|
|
301
|
+
trigger.setAttribute("aria-expanded", "true");
|
|
302
|
+
let checked = panel.querySelector("[data-video-item]:checked");
|
|
303
|
+
(checked ?? panel.querySelector("[data-video-item]"))?.focus();
|
|
304
|
+
}
|
|
305
|
+
/** Returns from a submenu to the top level, focusing the row that opened it. */
|
|
306
|
+
closePanel(panel) {
|
|
307
|
+
if (!panel || panel.hidden)
|
|
308
|
+
return;
|
|
309
|
+
panel.hidden = true;
|
|
310
|
+
let trigger = this.root.querySelector(`[aria-controls="${panel.id}"]`);
|
|
311
|
+
trigger?.setAttribute("aria-expanded", "false");
|
|
312
|
+
trigger?.closest('[data-slot="video-player-menu"]')?.removeAttribute("data-submenu");
|
|
313
|
+
trigger?.focus();
|
|
314
|
+
}
|
|
315
|
+
/** Puts a menu back on its top level, as it opens. */
|
|
316
|
+
closePanels(menu) {
|
|
317
|
+
for (let panel of menu.querySelectorAll('[data-slot="video-player-submenu-panel"]')) {
|
|
318
|
+
panel.hidden = true;
|
|
319
|
+
}
|
|
320
|
+
for (let trigger of menu.querySelectorAll('[data-video-action="open"]')) {
|
|
321
|
+
trigger.setAttribute("aria-expanded", "false");
|
|
322
|
+
}
|
|
323
|
+
menu.querySelector('[data-slot="video-player-menu"]')?.removeAttribute("data-submenu");
|
|
324
|
+
}
|
|
325
|
+
/** The captions option the server rendered checked, `-1` for off. */
|
|
326
|
+
checkedCaptions() {
|
|
327
|
+
let checked = this.root.querySelector('[data-video-setting="captions"] input:checked');
|
|
328
|
+
return checked ? Number(checked.value) : -1;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Shows the captions track at `index` and hides the rest, `-1` hiding them all; the toggle,
|
|
332
|
+
* the captions menu and its row follow.
|
|
333
|
+
*/
|
|
334
|
+
showCaptions(index) {
|
|
335
|
+
let tracks = captionTracks(this.video);
|
|
336
|
+
for (let [position, track] of tracks.entries()) {
|
|
337
|
+
track.mode = position === index ? "showing" : "disabled";
|
|
338
|
+
}
|
|
339
|
+
if (index >= 0)
|
|
340
|
+
this.lastCaptions = index;
|
|
341
|
+
let on = index >= 0 && index < tracks.length;
|
|
342
|
+
for (let button of this.all('[data-video-action="captions"]')) {
|
|
343
|
+
button.setAttribute("aria-pressed", String(on));
|
|
344
|
+
}
|
|
345
|
+
for (let panel of this.all('[data-video-setting="captions"]')) {
|
|
346
|
+
let input = panel.querySelector(`input[value="${on ? index : -1}"]`);
|
|
347
|
+
if (!input)
|
|
348
|
+
continue;
|
|
349
|
+
input.checked = true;
|
|
350
|
+
syncChecked(input);
|
|
351
|
+
this.nameChoice(panel, input);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Plays the source at `index` from the moment the current one reached, keeping its speed and
|
|
356
|
+
* whether it was playing; the settings badges follow the new source's badge.
|
|
357
|
+
*/
|
|
358
|
+
swapSource(index) {
|
|
359
|
+
let { signal, video } = this;
|
|
360
|
+
let source = video.querySelectorAll("source")[index];
|
|
361
|
+
if (!source)
|
|
362
|
+
return;
|
|
363
|
+
let time = video.currentTime;
|
|
364
|
+
let playing = !video.paused;
|
|
365
|
+
video.addEventListener("loadedmetadata", () => {
|
|
366
|
+
video.currentTime = time;
|
|
367
|
+
if (playing)
|
|
368
|
+
void video.play().catch(() => undefined);
|
|
369
|
+
}, { once: true, signal });
|
|
370
|
+
video.src = source.src;
|
|
371
|
+
for (let badge of this.all('[data-slot="video-player-badge"][data-follows-quality]')) {
|
|
372
|
+
badge.textContent = source.dataset.badge ?? "";
|
|
373
|
+
badge.hidden = !source.dataset.badge;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Wires one player until `signal` aborts: time links seek in place, the marks follow the
|
|
379
|
+
* video, and a control bar, when the player has one, replaces the native controls.
|
|
380
|
+
*/
|
|
381
|
+
function wirePlayer(root, video, signal) {
|
|
382
|
+
installMediaSync(root, video, signal, {
|
|
383
|
+
marks: MARKS,
|
|
384
|
+
onTime: (time, changed) => paintTimeline(root, time, changed),
|
|
385
|
+
});
|
|
386
|
+
let bar = root.querySelector('[data-slot="video-player-controls"]');
|
|
387
|
+
if (bar)
|
|
388
|
+
new VideoControls(root, video, signal).install(bar);
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Keeps a video player's links, marks, bar and video in step from a node inside its
|
|
392
|
+
* `[data-slot="video-player"]` root. A plain click on a time link seeks and plays; a
|
|
393
|
+
* modified click still opens the file itself.
|
|
394
|
+
*
|
|
395
|
+
* @returns A mixin descriptor for any element inside the player.
|
|
396
|
+
* @example <span hidden mix={[videoPlayerSync()]} />
|
|
397
|
+
*/
|
|
398
|
+
export const videoPlayerSync = createMixin((handle) => {
|
|
399
|
+
let controller;
|
|
400
|
+
handle.addEventListener("insert", (event) => {
|
|
401
|
+
controller?.abort();
|
|
402
|
+
let root = event.node.closest('[data-slot="video-player"]');
|
|
403
|
+
let video = root?.querySelector("video");
|
|
404
|
+
if (!root || !video)
|
|
405
|
+
return;
|
|
406
|
+
controller = new AbortController();
|
|
407
|
+
wirePlayer(root, video, controller.signal);
|
|
408
|
+
});
|
|
409
|
+
handle.addEventListener("remove", () => {
|
|
410
|
+
controller?.abort();
|
|
411
|
+
controller = undefined;
|
|
412
|
+
});
|
|
413
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why JS: paging a scroller by one screenful and disabling a button at the end it points to
|
|
3
|
+
* both need the scroller's live width and position, which CSS cannot read.
|
|
4
|
+
* No-JS baseline: the shelf scrolls by touch, trackpad, wheel and the Tab key through its
|
|
5
|
+
* cards, with its scrollbar showing and its paging buttons hidden.
|
|
6
|
+
*
|
|
7
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
8
|
+
* @copyright Sergio Xalambrí 2026
|
|
9
|
+
*/
|
|
10
|
+
import type { MixinFactory } from "remix/component";
|
|
11
|
+
/** Set on the scroller once its paging buttons run, which then hide its scrollbar. */
|
|
12
|
+
export declare const READY_ATTRIBUTE = "data-video-shelf-ready";
|
|
13
|
+
/** The attribute a paging button carries: `-1` steps back, `1` steps forward. */
|
|
14
|
+
export declare const STEP_ATTRIBUTE = "data-video-shelf-step";
|
|
15
|
+
/**
|
|
16
|
+
* Runs the paging buttons of the shelf it sits in: each step moves one screenful, flipped under
|
|
17
|
+
* right-to-left, and each button disables at the end it points to as the scroller moves or
|
|
18
|
+
* resizes.
|
|
19
|
+
*/
|
|
20
|
+
export declare const videoShelfSteps: MixinFactory<HTMLElement>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why JS: paging a scroller by one screenful and disabling a button at the end it points to
|
|
3
|
+
* both need the scroller's live width and position, which CSS cannot read.
|
|
4
|
+
* No-JS baseline: the shelf scrolls by touch, trackpad, wheel and the Tab key through its
|
|
5
|
+
* cards, with its scrollbar showing and its paging buttons hidden.
|
|
6
|
+
*
|
|
7
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
8
|
+
* @copyright Sergio Xalambrí 2026
|
|
9
|
+
*/
|
|
10
|
+
import { createMixin } from "remix/component";
|
|
11
|
+
/** Set on the scroller once its paging buttons run, which then hide its scrollbar. */
|
|
12
|
+
export const READY_ATTRIBUTE = "data-video-shelf-ready";
|
|
13
|
+
/** The attribute a paging button carries: `-1` steps back, `1` steps forward. */
|
|
14
|
+
export const STEP_ATTRIBUTE = "data-video-shelf-step";
|
|
15
|
+
/**
|
|
16
|
+
* Runs the paging buttons of the shelf it sits in: each step moves one screenful, flipped under
|
|
17
|
+
* right-to-left, and each button disables at the end it points to as the scroller moves or
|
|
18
|
+
* resizes.
|
|
19
|
+
*/
|
|
20
|
+
export const videoShelfSteps = createMixin((handle) => {
|
|
21
|
+
let controller;
|
|
22
|
+
handle.addEventListener("insert", (event) => {
|
|
23
|
+
controller?.abort();
|
|
24
|
+
let shelf = event.node.closest("[data-slot=video-shelf]");
|
|
25
|
+
let scroller = shelf?.querySelector("[data-slot=video-shelf-scroller]");
|
|
26
|
+
if (!shelf || !scroller)
|
|
27
|
+
return;
|
|
28
|
+
controller = new AbortController();
|
|
29
|
+
wireShelf(shelf, scroller, controller.signal);
|
|
30
|
+
});
|
|
31
|
+
handle.addEventListener("remove", () => {
|
|
32
|
+
controller?.abort();
|
|
33
|
+
controller = undefined;
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
/**
|
|
37
|
+
* Reveals a shelf's paging buttons and runs them until `signal` aborts, when the buttons hide
|
|
38
|
+
* again and the scroller gets its scrollbar back.
|
|
39
|
+
*
|
|
40
|
+
* @param shelf The shelf's root.
|
|
41
|
+
* @param view Its scroller.
|
|
42
|
+
* @param signal Ends the wiring.
|
|
43
|
+
*/
|
|
44
|
+
function wireShelf(shelf, view, signal) {
|
|
45
|
+
let buttons = [...shelf.querySelectorAll(`[${STEP_ATTRIBUTE}]`)];
|
|
46
|
+
/** Disables the button that points past the end the scroller sits at. */
|
|
47
|
+
function sync() {
|
|
48
|
+
let rtl = getComputedStyle(view).direction === "rtl";
|
|
49
|
+
let position = rtl ? -view.scrollLeft : view.scrollLeft;
|
|
50
|
+
let max = view.scrollWidth - view.clientWidth;
|
|
51
|
+
for (let button of buttons) {
|
|
52
|
+
let forward = button.getAttribute(STEP_ATTRIBUTE) === "1";
|
|
53
|
+
button.disabled = forward ? position >= max - 1 : position <= 1;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/** Scrolls one screenful less a peek of half a card, so the card at the edge stays in view. */
|
|
57
|
+
function step(button) {
|
|
58
|
+
let rtl = getComputedStyle(view).direction === "rtl";
|
|
59
|
+
let direction = Number(button.getAttribute(STEP_ATTRIBUTE)) * (rtl ? -1 : 1);
|
|
60
|
+
let item = view.querySelector("[data-slot=video-shelf-item]");
|
|
61
|
+
let peek = item === null ? 0 : item.getBoundingClientRect().width / 2;
|
|
62
|
+
view.scrollBy({ left: direction * Math.max(view.clientWidth - peek, peek) });
|
|
63
|
+
}
|
|
64
|
+
for (let button of buttons) {
|
|
65
|
+
button.hidden = false;
|
|
66
|
+
button.addEventListener("click", () => step(button), { signal });
|
|
67
|
+
}
|
|
68
|
+
view.setAttribute(READY_ATTRIBUTE, "");
|
|
69
|
+
view.addEventListener("scroll", sync, { passive: true, signal });
|
|
70
|
+
let observer = new ResizeObserver(sync);
|
|
71
|
+
observer.observe(view);
|
|
72
|
+
sync();
|
|
73
|
+
signal.addEventListener("abort", () => {
|
|
74
|
+
observer.disconnect();
|
|
75
|
+
view.removeAttribute(READY_ATTRIBUTE);
|
|
76
|
+
for (let button of buttons)
|
|
77
|
+
button.hidden = true;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A video title's hero: its art edge to edge behind the page's top bar, faded into the page at
|
|
3
|
+
* its foot and toward the text, with an eyebrow, the title, a row of facts, a summary and the
|
|
4
|
+
* actions. A catalogue's home features a title with it, and a title's page opens on it.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { Handle, Props as TagProps, RemixNode } from "remix/component";
|
|
10
|
+
/** Prop types for {@link TitleHero} and its parts. */
|
|
11
|
+
export declare namespace TitleHero {
|
|
12
|
+
/** `feature` for a home's billboard, `title` for the head of a title's own page. */
|
|
13
|
+
type Size = "feature" | "title";
|
|
14
|
+
/** Every native `<section>` attribute, plus the art behind it and its size. */
|
|
15
|
+
interface Props extends TagProps<"section"> {
|
|
16
|
+
/** The picture behind the hero, drawn edge to edge: an `<img>`, `<picture>` or `<video>`. */
|
|
17
|
+
art: RemixNode;
|
|
18
|
+
/** Default: `"feature"`. */
|
|
19
|
+
size?: Size;
|
|
20
|
+
/** The hero's parts: eyebrow, title, facts, summary and actions, in reading order. */
|
|
21
|
+
children: RemixNode;
|
|
22
|
+
}
|
|
23
|
+
/** Every native heading attribute, plus the heading's level. */
|
|
24
|
+
interface TitleProps extends TagProps<"h1"> {
|
|
25
|
+
/** `1` on a title's own page, `2` when the page has its own `h1`. */
|
|
26
|
+
level: 1 | 2;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Renders the hero. It pulls itself up under a sticky top bar by `--ui-title-hero-offset`
|
|
31
|
+
* (the bar's height), so the art starts at the window's edge while the text clears the bar;
|
|
32
|
+
* under reduced motion the art holds still instead of drifting.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* <TitleHero art={<img src="/art/tidewater.jpg" alt="" />} aria-labelledby="hero-title">
|
|
36
|
+
* <TitleHero.Eyebrow>Original</TitleHero.Eyebrow>
|
|
37
|
+
* <TitleHero.Title id="hero-title" level={1}>Tidewater</TitleHero.Title>
|
|
38
|
+
* <TitleHero.Facts><span>2026</span><span>2 seasons</span></TitleHero.Facts>
|
|
39
|
+
* <TitleHero.Summary>A harbour town keeps one secret a season.</TitleHero.Summary>
|
|
40
|
+
* <TitleHero.Actions><LinkButton href="/watch/tidewater">Play</LinkButton></TitleHero.Actions>
|
|
41
|
+
* </TitleHero>
|
|
42
|
+
*/
|
|
43
|
+
export declare function TitleHero(handle: Handle<TitleHero.Props>): () => import("remix/component").RemixElement;
|
|
44
|
+
export declare namespace TitleHero {
|
|
45
|
+
var Eyebrow: (handle: Handle<TagProps<"span">>) => () => import("remix/component").RemixElement;
|
|
46
|
+
var Title: (handle: Handle<TitleHero.TitleProps>) => () => import("remix/component").RemixElement;
|
|
47
|
+
var Facts: (handle: Handle<TagProps<"p">>) => () => import("remix/component").RemixElement;
|
|
48
|
+
var Rating: (handle: Handle<TagProps<"span">>) => () => import("remix/component").RemixElement;
|
|
49
|
+
var Summary: (handle: Handle<TagProps<"p">>) => () => import("remix/component").RemixElement;
|
|
50
|
+
var Actions: (handle: Handle<TagProps<"div">>) => () => import("remix/component").RemixElement;
|
|
51
|
+
}
|