@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,170 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "remix/component/jsx-runtime";
|
|
2
|
+
import { mergeMix, raw } from "@sdxc/u/general";
|
|
3
|
+
import { motionSafe } from "@sdxc/u/responsive";
|
|
4
|
+
/** Container the hero declares, which its text column sizes against. */
|
|
5
|
+
const CONTAINER = "ui-title-hero";
|
|
6
|
+
/** How tall the hero stands per size, before its content asks for more. */
|
|
7
|
+
const MIN_SIZES = {
|
|
8
|
+
feature: "var(--ui-title-hero-feature-size, min(88svh, 52rem))",
|
|
9
|
+
title: "var(--ui-title-hero-title-size, min(70svh, 40rem))",
|
|
10
|
+
};
|
|
11
|
+
/** The page colour the art fades into, so its foot meets the page with no edge. */
|
|
12
|
+
const FADE = "var(--ui-title-hero-fade, var(--ui-bg))";
|
|
13
|
+
/**
|
|
14
|
+
* Renders the hero. It pulls itself up under a sticky top bar by `--ui-title-hero-offset`
|
|
15
|
+
* (the bar's height), so the art starts at the window's edge while the text clears the bar;
|
|
16
|
+
* under reduced motion the art holds still instead of drifting.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* <TitleHero art={<img src="/art/tidewater.jpg" alt="" />} aria-labelledby="hero-title">
|
|
20
|
+
* <TitleHero.Eyebrow>Original</TitleHero.Eyebrow>
|
|
21
|
+
* <TitleHero.Title id="hero-title" level={1}>Tidewater</TitleHero.Title>
|
|
22
|
+
* <TitleHero.Facts><span>2026</span><span>2 seasons</span></TitleHero.Facts>
|
|
23
|
+
* <TitleHero.Summary>A harbour town keeps one secret a season.</TitleHero.Summary>
|
|
24
|
+
* <TitleHero.Actions><LinkButton href="/watch/tidewater">Play</LinkButton></TitleHero.Actions>
|
|
25
|
+
* </TitleHero>
|
|
26
|
+
*/
|
|
27
|
+
export function TitleHero(handle) {
|
|
28
|
+
return () => {
|
|
29
|
+
let { art, children, mix, size = "feature", ...rest } = handle.props;
|
|
30
|
+
return (_jsxs("section", { ...rest, "data-slot": "title-hero", "data-size": size, mix: mergeMix([
|
|
31
|
+
raw({
|
|
32
|
+
containerName: CONTAINER,
|
|
33
|
+
containerType: "inline-size",
|
|
34
|
+
position: "relative",
|
|
35
|
+
isolation: "isolate",
|
|
36
|
+
display: "grid",
|
|
37
|
+
alignContent: "end",
|
|
38
|
+
marginBlockStart: "calc(-1 * var(--ui-title-hero-offset, 0px))",
|
|
39
|
+
minBlockSize: MIN_SIZES[size],
|
|
40
|
+
paddingInline: "var(--ui-title-hero-inset, 1rem)",
|
|
41
|
+
paddingBlock: "calc(var(--ui-title-hero-offset, 0px) + 2rem) clamp(2rem, 6vh, 4.5rem)",
|
|
42
|
+
overflow: "clip",
|
|
43
|
+
}),
|
|
44
|
+
], mix), children: [_jsx("div", { "data-slot": "title-hero-art", mix: [
|
|
45
|
+
raw({
|
|
46
|
+
position: "absolute",
|
|
47
|
+
inset: "0",
|
|
48
|
+
zIndex: "-1",
|
|
49
|
+
"& > *": {
|
|
50
|
+
position: "absolute",
|
|
51
|
+
inset: "0",
|
|
52
|
+
inlineSize: "100%",
|
|
53
|
+
blockSize: "100%",
|
|
54
|
+
objectFit: "cover",
|
|
55
|
+
},
|
|
56
|
+
"&::after": {
|
|
57
|
+
content: '""',
|
|
58
|
+
position: "absolute",
|
|
59
|
+
inset: "0",
|
|
60
|
+
background: `linear-gradient(to top, ${FADE} 0%, color-mix(in oklch, ${FADE}, transparent 30%) 22%, transparent 55%), linear-gradient(to right, color-mix(in oklch, ${FADE}, transparent 15%) 0%, transparent 62%)`,
|
|
61
|
+
},
|
|
62
|
+
"@keyframes ui-title-hero-drift": {
|
|
63
|
+
from: { scale: "1.06" },
|
|
64
|
+
to: { scale: "1" },
|
|
65
|
+
},
|
|
66
|
+
}),
|
|
67
|
+
motionSafe(raw({
|
|
68
|
+
"& > :first-child": { animation: "ui-title-hero-drift 14s ease-out both" },
|
|
69
|
+
})),
|
|
70
|
+
], children: art }), _jsx("div", { "data-slot": "title-hero-content", mix: [raw({ display: "grid", gap: "1rem", maxInlineSize: "38rem" })], children: children })] }));
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/** The small line over the title, such as "Original" or "New season". */
|
|
74
|
+
TitleHero.Eyebrow = function TitleHeroEyebrow(handle) {
|
|
75
|
+
return () => {
|
|
76
|
+
let { mix, ...rest } = handle.props;
|
|
77
|
+
return (_jsx("span", { ...rest, "data-slot": "title-hero-eyebrow", mix: mergeMix([
|
|
78
|
+
raw({
|
|
79
|
+
fontSize: "0.75rem",
|
|
80
|
+
fontWeight: "700",
|
|
81
|
+
letterSpacing: "0.28em",
|
|
82
|
+
textTransform: "uppercase",
|
|
83
|
+
color: "var(--ui-title-hero-accent, var(--ui-brand-fg))",
|
|
84
|
+
}),
|
|
85
|
+
], mix) }));
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* The title as the hero's heading, large and balanced; a page sets its own lettering through
|
|
90
|
+
* `mix`, so each title can read in its own type.
|
|
91
|
+
*/
|
|
92
|
+
TitleHero.Title = function TitleHeroTitle(handle) {
|
|
93
|
+
return () => {
|
|
94
|
+
let { children, level, mix, ...rest } = handle.props;
|
|
95
|
+
let merged = mergeMix([
|
|
96
|
+
raw({
|
|
97
|
+
margin: "0",
|
|
98
|
+
fontSize: "clamp(2.25rem, 9cqi, 4.75rem)",
|
|
99
|
+
lineHeight: "0.95",
|
|
100
|
+
color: "var(--ui-neutral-fg-emphasis)",
|
|
101
|
+
textWrap: "balance",
|
|
102
|
+
textShadow: "0 2px 24px rgb(0 0 0 / 0.45)",
|
|
103
|
+
}),
|
|
104
|
+
], mix);
|
|
105
|
+
return level === 1 ? (_jsx("h1", { ...rest, "data-slot": "title-hero-title", mix: merged, children: children })) : (_jsx("h2", { ...rest, "data-slot": "title-hero-title", mix: merged, children: children }));
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
/** The facts under the title (rating, year, length, genres) as one wrapping row. */
|
|
109
|
+
TitleHero.Facts = function TitleHeroFacts(handle) {
|
|
110
|
+
return () => {
|
|
111
|
+
let { mix, ...rest } = handle.props;
|
|
112
|
+
return (_jsx("p", { ...rest, "data-slot": "title-hero-facts", mix: mergeMix([
|
|
113
|
+
raw({
|
|
114
|
+
display: "flex",
|
|
115
|
+
flexWrap: "wrap",
|
|
116
|
+
alignItems: "center",
|
|
117
|
+
gap: "0.375rem 0.75rem",
|
|
118
|
+
margin: "0",
|
|
119
|
+
fontSize: "0.9375rem",
|
|
120
|
+
color: "var(--ui-neutral-fg-emphasis)",
|
|
121
|
+
fontVariantNumeric: "tabular-nums",
|
|
122
|
+
}),
|
|
123
|
+
], mix) }));
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
/** An age rating in the facts row, outlined so it reads as a label rather than a fact. */
|
|
127
|
+
TitleHero.Rating = function TitleHeroRating(handle) {
|
|
128
|
+
return () => {
|
|
129
|
+
let { mix, ...rest } = handle.props;
|
|
130
|
+
return (_jsx("span", { ...rest, "data-slot": "title-hero-rating", mix: mergeMix([
|
|
131
|
+
raw({
|
|
132
|
+
paddingInline: "0.375rem",
|
|
133
|
+
borderRadius: "var(--ui-radius-sm, 0.25rem)",
|
|
134
|
+
boxShadow: "inset 0 0 0 1px color-mix(in oklch, currentColor 45%, transparent)",
|
|
135
|
+
fontSize: "0.8125rem",
|
|
136
|
+
fontWeight: "600",
|
|
137
|
+
}),
|
|
138
|
+
], mix) }));
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
/** The title's synopsis or tagline, shadowed so it reads over any art. */
|
|
142
|
+
TitleHero.Summary = function TitleHeroSummary(handle) {
|
|
143
|
+
return () => {
|
|
144
|
+
let { mix, ...rest } = handle.props;
|
|
145
|
+
return (_jsx("p", { ...rest, "data-slot": "title-hero-summary", mix: mergeMix([
|
|
146
|
+
raw({
|
|
147
|
+
margin: "0",
|
|
148
|
+
fontSize: "clamp(0.9375rem, 2.2cqi, 1.0625rem)",
|
|
149
|
+
lineHeight: "1.6",
|
|
150
|
+
color: "var(--ui-neutral-fg)",
|
|
151
|
+
textWrap: "pretty",
|
|
152
|
+
textShadow: "0 1px 8px rgb(0 0 0 / 0.5)",
|
|
153
|
+
}),
|
|
154
|
+
], mix) }));
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
/** The hero's buttons, primary first, wrapping onto a second line on a narrow screen. */
|
|
158
|
+
TitleHero.Actions = function TitleHeroActions(handle) {
|
|
159
|
+
return () => {
|
|
160
|
+
let { mix, ...rest } = handle.props;
|
|
161
|
+
return (_jsx("div", { ...rest, "data-slot": "title-hero-actions", mix: mergeMix([
|
|
162
|
+
raw({
|
|
163
|
+
display: "flex",
|
|
164
|
+
flexWrap: "wrap",
|
|
165
|
+
gap: "0.625rem",
|
|
166
|
+
marginBlockStart: "0.25rem",
|
|
167
|
+
}),
|
|
168
|
+
], mix) }));
|
|
169
|
+
};
|
|
170
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Time arithmetic for a video's timeline: readings as a player prints them, WebVTT files
|
|
3
|
+
* written from timed lines, and which entry of a playing-order list a moment falls in. The
|
|
4
|
+
* server render and the island share it, so both mark the same chapter and line.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
/** How far, in seconds, a moment may run ahead of a start and still count as reaching it. */
|
|
10
|
+
export declare const SEEK_SLACK = 0.25;
|
|
11
|
+
/**
|
|
12
|
+
* Writes seconds as a player prints them: `m:ss` under an hour and `h:mm:ss` from one.
|
|
13
|
+
*
|
|
14
|
+
* @param seconds Whole or fractional seconds; fractions are dropped.
|
|
15
|
+
* @returns The reading, such as `6:58`.
|
|
16
|
+
* @example formatVideoTime(418.9); // "6:58"
|
|
17
|
+
*/
|
|
18
|
+
export declare function formatVideoTime(seconds: number): string;
|
|
19
|
+
/**
|
|
20
|
+
* The same moment as an ISO 8601 duration, for a `<time dateTime>` attribute.
|
|
21
|
+
*
|
|
22
|
+
* @param seconds Whole or fractional seconds; fractions are dropped.
|
|
23
|
+
* @returns The duration, such as `PT6M58S`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function isoDuration(seconds: number): string;
|
|
26
|
+
/**
|
|
27
|
+
* Writes timed lines as a WebVTT file in a `data:` URL, each line ending where the next
|
|
28
|
+
* starts and the last at `duration`, so a `<track>` needs no file of its own.
|
|
29
|
+
*
|
|
30
|
+
* @param lines Start times and texts, in playing order.
|
|
31
|
+
* @param duration Length of the video in seconds.
|
|
32
|
+
* @returns A `data:text/vtt` URL.
|
|
33
|
+
* @example <track kind="chapters" src={webVttUrl([{ start: 0, text: "Intro" }], 90)} />
|
|
34
|
+
*/
|
|
35
|
+
export declare function webVttUrl(lines: readonly {
|
|
36
|
+
start: number;
|
|
37
|
+
text: string;
|
|
38
|
+
}[], duration: number): string;
|
|
39
|
+
/**
|
|
40
|
+
* Index of the last start at or before `time`, or -1 before the first.
|
|
41
|
+
*
|
|
42
|
+
* @param starts Start times in playing order.
|
|
43
|
+
* @param time The moment asked about, in seconds; `undefined` matches nothing.
|
|
44
|
+
* @returns The index of the entry playing at `time`.
|
|
45
|
+
*/
|
|
46
|
+
export declare function playingIndex(starts: readonly number[], time: number | undefined): number;
|
|
47
|
+
/**
|
|
48
|
+
* Share of a chapter played at `time`, from 0 to 1.
|
|
49
|
+
*
|
|
50
|
+
* @param start The chapter's start in seconds.
|
|
51
|
+
* @param end The chapter's end in seconds.
|
|
52
|
+
* @param time The moment asked about, or `undefined` for none.
|
|
53
|
+
* @returns How much of the chapter lies before `time`.
|
|
54
|
+
*/
|
|
55
|
+
export declare function playedShare(start: number, end: number, time: number | undefined): number;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Time arithmetic for a video's timeline: readings as a player prints them, WebVTT files
|
|
3
|
+
* written from timed lines, and which entry of a playing-order list a moment falls in. The
|
|
4
|
+
* server render and the island share it, so both mark the same chapter and line.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
/** How far, in seconds, a moment may run ahead of a start and still count as reaching it. */
|
|
10
|
+
export const SEEK_SLACK = 0.25;
|
|
11
|
+
/**
|
|
12
|
+
* Writes seconds as a player prints them: `m:ss` under an hour and `h:mm:ss` from one.
|
|
13
|
+
*
|
|
14
|
+
* @param seconds Whole or fractional seconds; fractions are dropped.
|
|
15
|
+
* @returns The reading, such as `6:58`.
|
|
16
|
+
* @example formatVideoTime(418.9); // "6:58"
|
|
17
|
+
*/
|
|
18
|
+
export function formatVideoTime(seconds) {
|
|
19
|
+
let total = Number.isFinite(seconds) ? Math.max(0, Math.floor(seconds)) : 0;
|
|
20
|
+
let hours = Math.floor(total / 3600);
|
|
21
|
+
let minutes = Math.floor((total % 3600) / 60);
|
|
22
|
+
let rest = String(total % 60).padStart(2, "0");
|
|
23
|
+
if (hours > 0)
|
|
24
|
+
return `${hours}:${String(minutes).padStart(2, "0")}:${rest}`;
|
|
25
|
+
return `${minutes}:${rest}`;
|
|
26
|
+
}
|
|
27
|
+
/** Seconds as a WebVTT timestamp, `hh:mm:ss.mmm`. */
|
|
28
|
+
function vttTime(seconds) {
|
|
29
|
+
let millis = Math.round(Math.max(0, seconds) * 1000);
|
|
30
|
+
let hours = String(Math.floor(millis / 3_600_000)).padStart(2, "0");
|
|
31
|
+
let minutes = String(Math.floor((millis % 3_600_000) / 60_000)).padStart(2, "0");
|
|
32
|
+
let secs = String(Math.floor((millis % 60_000) / 1000)).padStart(2, "0");
|
|
33
|
+
return `${hours}:${minutes}:${secs}.${String(millis % 1000).padStart(3, "0")}`;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The same moment as an ISO 8601 duration, for a `<time dateTime>` attribute.
|
|
37
|
+
*
|
|
38
|
+
* @param seconds Whole or fractional seconds; fractions are dropped.
|
|
39
|
+
* @returns The duration, such as `PT6M58S`.
|
|
40
|
+
*/
|
|
41
|
+
export function isoDuration(seconds) {
|
|
42
|
+
let total = Math.max(0, Math.floor(seconds));
|
|
43
|
+
return `PT${Math.floor(total / 60)}M${total % 60}S`;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Writes timed lines as a WebVTT file in a `data:` URL, each line ending where the next
|
|
47
|
+
* starts and the last at `duration`, so a `<track>` needs no file of its own.
|
|
48
|
+
*
|
|
49
|
+
* @param lines Start times and texts, in playing order.
|
|
50
|
+
* @param duration Length of the video in seconds.
|
|
51
|
+
* @returns A `data:text/vtt` URL.
|
|
52
|
+
* @example <track kind="chapters" src={webVttUrl([{ start: 0, text: "Intro" }], 90)} />
|
|
53
|
+
*/
|
|
54
|
+
export function webVttUrl(lines, duration) {
|
|
55
|
+
let cues = lines.map((line, index) => {
|
|
56
|
+
let end = lines[index + 1]?.start ?? duration;
|
|
57
|
+
let text = line.text.replaceAll("-->", "→").replaceAll(/\n{2,}/g, "\n");
|
|
58
|
+
return `${index + 1}\n${vttTime(line.start)} --> ${vttTime(end)}\n${text}`;
|
|
59
|
+
});
|
|
60
|
+
return `data:text/vtt;charset=utf-8,${encodeURIComponent(`${["WEBVTT", ...cues].join("\n\n")}\n`)}`;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Index of the last start at or before `time`, or -1 before the first.
|
|
64
|
+
*
|
|
65
|
+
* @param starts Start times in playing order.
|
|
66
|
+
* @param time The moment asked about, in seconds; `undefined` matches nothing.
|
|
67
|
+
* @returns The index of the entry playing at `time`.
|
|
68
|
+
*/
|
|
69
|
+
export function playingIndex(starts, time) {
|
|
70
|
+
if (time === undefined)
|
|
71
|
+
return -1;
|
|
72
|
+
let found = -1;
|
|
73
|
+
for (let [index, start] of starts.entries())
|
|
74
|
+
if (start <= time + SEEK_SLACK)
|
|
75
|
+
found = index;
|
|
76
|
+
return found;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Share of a chapter played at `time`, from 0 to 1.
|
|
80
|
+
*
|
|
81
|
+
* @param start The chapter's start in seconds.
|
|
82
|
+
* @param end The chapter's end in seconds.
|
|
83
|
+
* @param time The moment asked about, or `undefined` for none.
|
|
84
|
+
* @returns How much of the chapter lies before `time`.
|
|
85
|
+
*/
|
|
86
|
+
export function playedShare(start, end, time) {
|
|
87
|
+
if (time === undefined || end <= start)
|
|
88
|
+
return 0;
|
|
89
|
+
return Math.min(1, Math.max(0, (time - start) / (end - start)));
|
|
90
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A title in a video catalogue as one link: its artwork in a landscape still or a portrait
|
|
3
|
+
* poster, a badge on the art, how much of it the viewer has watched, and its name and meta
|
|
4
|
+
* below. The card owns the hover lift and focus ring, so every row and grid reads alike.
|
|
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 VideoCard}. */
|
|
11
|
+
export declare namespace VideoCard {
|
|
12
|
+
/** `landscape` is a 16:9 still, `poster` a 2:3 key art. */
|
|
13
|
+
type Shape = "landscape" | "poster";
|
|
14
|
+
/** Every native `<a>` attribute but `children`, `title` and `role`, plus the card's own content. */
|
|
15
|
+
interface Props extends Omit<TagProps<"a">, "children" | "title" | "href" | "role"> {
|
|
16
|
+
/** The link's destination: the title's page, or straight into playback. */
|
|
17
|
+
href: string;
|
|
18
|
+
/** The title's name, the card's accessible name and its first line. */
|
|
19
|
+
title: string;
|
|
20
|
+
/** The artwork, drawn edge to edge in the frame: an `<img>`, an `<svg>` or a gradient. */
|
|
21
|
+
art: RemixNode;
|
|
22
|
+
/** Default: `"landscape"`. */
|
|
23
|
+
shape?: Shape;
|
|
24
|
+
/** A short second line, such as "S2 · E4 · 38 min" or "2026 · Drama". */
|
|
25
|
+
meta?: RemixNode;
|
|
26
|
+
/** A label on the art's top corner, such as "New episodes". */
|
|
27
|
+
badge?: RemixNode;
|
|
28
|
+
/** The share watched, from 0 to 1, drawn as a bar along the art's foot. */
|
|
29
|
+
progress?: number;
|
|
30
|
+
/** What a screen reader hears for the bar, such as "38% watched"; required with `progress`. */
|
|
31
|
+
progressLabel?: string;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Clamps a watched share into 0–1, so a bar never overflows its track or runs backwards.
|
|
36
|
+
*
|
|
37
|
+
* @param value The share a page passed.
|
|
38
|
+
* @returns The share the bar draws.
|
|
39
|
+
*/
|
|
40
|
+
export declare function clampProgress(value: number): number;
|
|
41
|
+
/**
|
|
42
|
+
* Renders the card. The whole card is one link whose name is the title, so a row of them
|
|
43
|
+
* reads as a list of titles; the art scales a little under the pointer and stays still under
|
|
44
|
+
* reduced motion.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* <VideoCard href="/title/tidewater" title="Tidewater" art={<img src={still} alt="" />} meta="S1 · E3" progress={0.4} progressLabel="40% watched" />
|
|
48
|
+
* @example
|
|
49
|
+
* <VideoCard shape="poster" href="/title/ember" title="Ember Line" art={<Poster />} badge="New" />
|
|
50
|
+
*/
|
|
51
|
+
export declare function VideoCard(handle: Handle<VideoCard.Props>): () => import("remix/component").RemixElement;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "remix/component/jsx-runtime";
|
|
2
|
+
import { visuallyHidden } from "@sdxc/u/a11y";
|
|
3
|
+
import { mergeMix, raw } from "@sdxc/u/general";
|
|
4
|
+
import { motionSafe } from "@sdxc/u/responsive";
|
|
5
|
+
import { when } from "@sdxc/u/state";
|
|
6
|
+
/** The art frame's proportions per shape. */
|
|
7
|
+
const RATIOS = { landscape: "16 / 9", poster: "2 / 3" };
|
|
8
|
+
/** The bar's fill, the brand's own unless a page names another. */
|
|
9
|
+
const PROGRESS_COLOR = "var(--ui-video-card-progress-color, var(--ui-brand-bg-solid))";
|
|
10
|
+
/**
|
|
11
|
+
* Clamps a watched share into 0–1, so a bar never overflows its track or runs backwards.
|
|
12
|
+
*
|
|
13
|
+
* @param value The share a page passed.
|
|
14
|
+
* @returns The share the bar draws.
|
|
15
|
+
*/
|
|
16
|
+
export function clampProgress(value) {
|
|
17
|
+
if (!Number.isFinite(value))
|
|
18
|
+
return 0;
|
|
19
|
+
return Math.min(1, Math.max(0, value));
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Renders the card. The whole card is one link whose name is the title, so a row of them
|
|
23
|
+
* reads as a list of titles; the art scales a little under the pointer and stays still under
|
|
24
|
+
* reduced motion.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* <VideoCard href="/title/tidewater" title="Tidewater" art={<img src={still} alt="" />} meta="S1 · E3" progress={0.4} progressLabel="40% watched" />
|
|
28
|
+
* @example
|
|
29
|
+
* <VideoCard shape="poster" href="/title/ember" title="Ember Line" art={<Poster />} badge="New" />
|
|
30
|
+
*/
|
|
31
|
+
export function VideoCard(handle) {
|
|
32
|
+
return () => {
|
|
33
|
+
let { art, badge, href, meta, mix, progress, progressLabel, shape = "landscape", title, ...rest } = handle.props;
|
|
34
|
+
let watched = progress === undefined ? null : clampProgress(progress);
|
|
35
|
+
return (_jsxs("a", { ...rest, href: href, "data-slot": "video-card", "data-shape": shape, mix: mergeMix([
|
|
36
|
+
raw({
|
|
37
|
+
position: "relative",
|
|
38
|
+
display: "grid",
|
|
39
|
+
alignContent: "start",
|
|
40
|
+
gap: "0.5rem",
|
|
41
|
+
minInlineSize: "0",
|
|
42
|
+
color: "inherit",
|
|
43
|
+
textDecoration: "none",
|
|
44
|
+
borderRadius: "var(--ui-video-card-radius, var(--ui-radius-lg, 0.5rem))",
|
|
45
|
+
outline: "none",
|
|
46
|
+
WebkitTapHighlightColor: "transparent",
|
|
47
|
+
}),
|
|
48
|
+
when("&:focus-visible [data-slot=video-card-art]", raw({ outline: "2px solid var(--ui-brand-ring)", outlineOffset: "3px" })),
|
|
49
|
+
when("&:hover [data-slot=video-card-art]", raw({
|
|
50
|
+
boxShadow: "0 0 0 1px var(--ui-video-card-ring-hover, rgb(255 255 255 / 0.28))",
|
|
51
|
+
})),
|
|
52
|
+
motionSafe(when("&:hover [data-slot=video-card-art] > :first-child", raw({ scale: "1.04" }))),
|
|
53
|
+
], mix), children: [_jsxs("span", { "data-slot": "video-card-art", mix: [
|
|
54
|
+
raw({
|
|
55
|
+
position: "relative",
|
|
56
|
+
display: "block",
|
|
57
|
+
aspectRatio: RATIOS[shape],
|
|
58
|
+
overflow: "clip",
|
|
59
|
+
borderRadius: "var(--ui-video-card-radius, var(--ui-radius-lg, 0.5rem))",
|
|
60
|
+
backgroundColor: "var(--ui-neutral-bg-tint-pressed)",
|
|
61
|
+
boxShadow: "0 0 0 1px var(--ui-image-outline, rgb(0 0 0 / 0.08))",
|
|
62
|
+
transition: "box-shadow 160ms ease",
|
|
63
|
+
"& > :first-child": {
|
|
64
|
+
position: "absolute",
|
|
65
|
+
inset: "0",
|
|
66
|
+
inlineSize: "100%",
|
|
67
|
+
blockSize: "100%",
|
|
68
|
+
objectFit: "cover",
|
|
69
|
+
transition: "scale 320ms cubic-bezier(0.2, 0.7, 0.2, 1)",
|
|
70
|
+
},
|
|
71
|
+
}),
|
|
72
|
+
], children: [art, badge === undefined ? null : _jsx(CardBadge, { children: badge }), watched === null ? null : _jsx(CardProgress, { value: watched })] }), _jsxs("span", { mix: [raw({ display: "grid", gap: "0.125rem", minInlineSize: "0" })], children: [_jsx("span", { "data-slot": "video-card-title", mix: [
|
|
73
|
+
raw({
|
|
74
|
+
overflow: "hidden",
|
|
75
|
+
textOverflow: "ellipsis",
|
|
76
|
+
whiteSpace: "nowrap",
|
|
77
|
+
fontSize: "0.9375rem",
|
|
78
|
+
lineHeight: "1.375rem",
|
|
79
|
+
fontWeight: "600",
|
|
80
|
+
color: "var(--ui-neutral-fg-emphasis)",
|
|
81
|
+
}),
|
|
82
|
+
], children: title }), meta === undefined ? null : (_jsx("span", { "data-slot": "video-card-meta", mix: [
|
|
83
|
+
raw({
|
|
84
|
+
overflow: "hidden",
|
|
85
|
+
textOverflow: "ellipsis",
|
|
86
|
+
whiteSpace: "nowrap",
|
|
87
|
+
fontSize: "0.8125rem",
|
|
88
|
+
lineHeight: "1.125rem",
|
|
89
|
+
color: "var(--ui-neutral-fg-muted)",
|
|
90
|
+
fontVariantNumeric: "tabular-nums",
|
|
91
|
+
}),
|
|
92
|
+
], children: meta })), watched === null || progressLabel === undefined ? null : (_jsx("span", { mix: [visuallyHidden()], children: progressLabel }))] })] }));
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/** The label on the art's top corner, on a dark glass so it reads over any artwork. */
|
|
96
|
+
function CardBadge(handle) {
|
|
97
|
+
return () => (_jsx("span", { "data-slot": "video-card-badge", mix: [
|
|
98
|
+
raw({
|
|
99
|
+
position: "absolute",
|
|
100
|
+
insetBlockStart: "0.5rem",
|
|
101
|
+
insetInlineStart: "0.5rem",
|
|
102
|
+
paddingInline: "0.4375rem",
|
|
103
|
+
paddingBlock: "0.125rem",
|
|
104
|
+
borderRadius: "var(--ui-radius-sm, 0.25rem)",
|
|
105
|
+
fontSize: "0.6875rem",
|
|
106
|
+
lineHeight: "1rem",
|
|
107
|
+
fontWeight: "700",
|
|
108
|
+
letterSpacing: "0.04em",
|
|
109
|
+
textTransform: "uppercase",
|
|
110
|
+
color: "oklch(0.98 0 0)",
|
|
111
|
+
backgroundColor: "var(--ui-video-card-badge-bg, rgb(10 10 14 / 0.72))",
|
|
112
|
+
"@media (prefers-reduced-transparency: no-preference)": {
|
|
113
|
+
backdropFilter: "blur(6px)",
|
|
114
|
+
},
|
|
115
|
+
}),
|
|
116
|
+
], children: handle.props.children }));
|
|
117
|
+
}
|
|
118
|
+
/** The watched bar along the art's foot: a pale track and the fill, both decorative. */
|
|
119
|
+
function CardProgress(handle) {
|
|
120
|
+
return () => (_jsx("span", { "data-slot": "video-card-progress", "aria-hidden": "true", mix: [
|
|
121
|
+
raw({
|
|
122
|
+
position: "absolute",
|
|
123
|
+
insetInline: "0",
|
|
124
|
+
insetBlockEnd: "0",
|
|
125
|
+
blockSize: "0.25rem",
|
|
126
|
+
backgroundColor: "rgb(255 255 255 / 0.28)",
|
|
127
|
+
}),
|
|
128
|
+
], children: _jsx("span", { mix: [
|
|
129
|
+
raw({
|
|
130
|
+
display: "block",
|
|
131
|
+
blockSize: "100%",
|
|
132
|
+
backgroundColor: PROGRESS_COLOR,
|
|
133
|
+
}),
|
|
134
|
+
], style: { inlineSize: `${(handle.props.value * 100).toFixed(1)}%` } }) }));
|
|
135
|
+
}
|