@soffits/dsh-media-hub 0.12.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +2 -1
- package/dist/danmaku.mjs +561 -0
- package/dist/index.js +304 -78
- package/locale/en.json +28 -3
- package/locale/fr.json +28 -3
- package/locale/zh.json +28 -3
- package/package.json +2 -1
- package/web/comments-view.js +55 -0
- package/web/danmaku-layer.js +83 -0
- package/web/feed-view.js +32 -24
- package/web/page.js +3 -1
- package/web/panel.css +32 -15
- package/web/player-bar.js +57 -0
- package/web/player.js +2 -0
- package/web/presence-view.js +6 -33
- package/web/result-card.js +1 -3
- package/web/room-view.js +105 -38
- package/web/ui.js +31 -9
- package/web/watching-view.js +1 -1
package/web/presence-view.js
CHANGED
|
@@ -4,9 +4,8 @@
|
|
|
4
4
|
* shows finished or removed lately (one tap writes a rating to the watch
|
|
5
5
|
* log), and picks from the recommender extension with the reason for each.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { Btn, Changes, Icon, K, P, React, asPerson, asPersonPaying, displayName, fillNodes, h, query } from './ui.js'
|
|
7
|
+
import { PickedWork } from './feed-view.js'
|
|
8
|
+
import { Btn, Changes, K, P, React, asPerson, fillNodes, h, query } from './ui.js'
|
|
10
9
|
|
|
11
10
|
/** The answers, in order, with the icon each one shows (DSH's own where it has one). */
|
|
12
11
|
const ANSWERS = [
|
|
@@ -61,37 +60,11 @@ export function RatingsSection({ t, on, version }) {
|
|
|
61
60
|
h('ul', { className: 'vsync-cards' }, pending.map(ask => h(RatingRow, { key: ask.show, t, ask, onAnswered: show => setPending(pending.filter(other => other.show !== show)) }))))
|
|
62
61
|
}
|
|
63
62
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const [busy, setBusy] = React.useState(false)
|
|
67
|
-
const [error, setError] = React.useState(null)
|
|
68
|
-
const meta = [work.kind && t(`kind.${work.kind}`) !== `kind.${work.kind}` ? t(`kind.${work.kind}`) : null, work.year, Number.isFinite(work.score) ? [work.scoreLabel, work.score].filter(Boolean).join(' ') : null].filter(Boolean)
|
|
69
|
-
const together = async () => {
|
|
70
|
-
setBusy(true)
|
|
71
|
-
setError(null)
|
|
72
|
-
const answer = await asPersonPaying('fetch', { source: work.source, id: work.id, watch: true, together: true, language: t.language, by: await displayName(t('guest')) })
|
|
73
|
-
setBusy(false)
|
|
74
|
-
if (answer.error) return setError(answer.error)
|
|
75
|
-
if (answer.declined) return undefined
|
|
76
|
-
return onOpen(answer.room.id)
|
|
77
|
-
}
|
|
78
|
-
return h(K.Surface, { as: 'li', className: 'vsync-pickCard' },
|
|
79
|
-
h('button', { type: 'button', className: 'vsync-pickOpen', tabIndex: -1, 'aria-hidden': true, onClick: () => onOpenWork(work.source, work) },
|
|
80
|
-
h(Picture, { pictures: [work.cover], className: 'vsync-pickCover', emptyClassName: 'vsync-pickCover vsync-ccPosterEmpty', icon: h(Icon.Film, { size: 22 }) })),
|
|
81
|
-
h('div', { className: 'vsync-pickBody' },
|
|
82
|
-
h('button', { type: 'button', className: 'vsync-pickTitle', onClick: () => onOpenWork(work.source, work) }, work.title),
|
|
83
|
-
meta.length > 0 && h('p', { className: 'vsync-rowMeta' }, meta.join(' · ')),
|
|
84
|
-
h('p', { className: 'vsync-pickWhy' }, h(K.Icon, { name: 'sparkles', size: 14, tone: 'violet' }), h('span', null, why)),
|
|
85
|
-
h('div', { className: 'vsync-pickActions' },
|
|
86
|
-
h(Btn, { disabled: busy, onClick: together, icon: h(P.IconUsersOutlineRegular, { size: 16 }) }, t('room.watchTogether')),
|
|
87
|
-
h(FollowButton, { t, source: work.source, work, compact: true })),
|
|
88
|
-
error && h('p', { className: 'vsync-error', role: 'alert' }, error)))
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export function PicksSection({ t, on, onOpen, onOpenWork }) {
|
|
63
|
+
/** The picks, each the card of its kind (watch it, or download the book) under the reason it was picked. */
|
|
64
|
+
export function PicksSection({ t, on, sources, onOpen, onSaved, onOpenWork }) {
|
|
92
65
|
const { discover } = React.useContext(Changes)
|
|
93
66
|
const [picks] = usePersonList(on, `picks?${query({ language: t.language })}`, 'picks', discover)
|
|
94
|
-
if (!picks || picks.length === 0) return null
|
|
67
|
+
if (!picks || picks.length === 0 || !sources) return null
|
|
95
68
|
return h(Section, { id: 'vsync-picks', title: t('picks.heading'), hint: t('picks.hint') },
|
|
96
|
-
h('ul', { className: 'vsync-
|
|
69
|
+
h('ul', { className: 'vsync-rows vsync-results' }, picks.map(({ work, why }) => h(PickedWork, { key: `${work.source}:${work.id}`, t, source: sources.find(one => one.id === work.source), work, why, onOpen, onSaved, onFocus: other => onOpenWork(other.source ?? work.source, other) }))))
|
|
97
70
|
}
|
package/web/result-card.js
CHANGED
|
@@ -9,13 +9,11 @@ import { Cover, WorkDetails, glance, infoOf } from './details.js'
|
|
|
9
9
|
import { FollowButton } from './follow.js'
|
|
10
10
|
import { hasEpisodes, resumeLabel } from './format.js'
|
|
11
11
|
import { useKnownWork } from './known.js'
|
|
12
|
-
import { Confirm, EPISODE_BYTES, Icon, React, Spinner, asPersonPaying, bytes, chatAbout, clock, displayName, fill, h } from './ui.js'
|
|
12
|
+
import { Confirm, EPISODE_BYTES, Icon, React, Spinner, asPersonPaying, bytes, chatAbout, clock, displayName, fill, h, qualityLabel } from './ui.js'
|
|
13
13
|
|
|
14
14
|
/** Episodes fetched ahead of the one being watched; the Host's `cacheAhead` default, for the size hint. */
|
|
15
15
|
const WINDOW_EPISODES = 6
|
|
16
16
|
|
|
17
|
-
/** The words for a quality a source offers: auto, audio, or a height. */
|
|
18
|
-
const qualityLabel = (t, quality) => (/^\d+$/.test(quality) ? fill(t('quality.height'), { n: quality }) : t(`quality.${quality}`))
|
|
19
17
|
|
|
20
18
|
/** How the episodes are fetched, for a source that offers a choice (Link); its first choice (auto) is the default. */
|
|
21
19
|
function QualityPicker({ t, qualities, value, onChange }) {
|
package/web/room-view.js
CHANGED
|
@@ -4,9 +4,12 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { About, nextSeason } from './about-view.js'
|
|
6
6
|
import { AvatarStack } from './avatars.js'
|
|
7
|
+
import { Comments } from './comments-view.js'
|
|
8
|
+
import { DanmakuLayer, useDanmakuSettings } from './danmaku-layer.js'
|
|
7
9
|
import { Cover } from './details.js'
|
|
8
10
|
import { useKnownWork } from './known.js'
|
|
9
|
-
import {
|
|
11
|
+
import { PlayerBar } from './player-bar.js'
|
|
12
|
+
import { Changes, Confirm, Icon, ProgressBar, React, api, asPersonPaying, base, captionText, clock, copyText, displayName, fill, h, post, progressFraction, progressText, roomLink, watchMark } from './ui.js'
|
|
10
13
|
|
|
11
14
|
const TOAST_MS = 4000
|
|
12
15
|
/** A wait shorter than this (a seek into what is already loaded) shows nothing. */
|
|
@@ -43,8 +46,38 @@ function WaitPanel({ t, view, item, onSkip, onContinue }) {
|
|
|
43
46
|
view.wait.canSkip && others.length > 0 && view.wait.held && h('button', { type: 'button', className: 'vsync-btn', onClick: onSkip }, fill(t('room.startWithout'), { names })))
|
|
44
47
|
}
|
|
45
48
|
|
|
49
|
+
/** No danmaku yet: the same empty list each time, so the layer is not rebuilt. */
|
|
50
|
+
const NO_DANMAKU = Object.freeze([])
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The player filling the screen with the danmaku and the bar on top: the browser's full screen for the player's box
|
|
54
|
+
* where it has one, else (iPhone, which only lets a bare <video> go full screen) the box covering the page.
|
|
55
|
+
*/
|
|
56
|
+
function useFullScreen(box) {
|
|
57
|
+
const [covering, setCovering] = React.useState(false)
|
|
58
|
+
const [native, setNative] = React.useState(false)
|
|
59
|
+
React.useEffect(() => {
|
|
60
|
+
const changed = () => setNative(document.fullscreenElement === box.current && box.current !== null)
|
|
61
|
+
document.addEventListener('fullscreenchange', changed)
|
|
62
|
+
return () => document.removeEventListener('fullscreenchange', changed)
|
|
63
|
+
}, [])
|
|
64
|
+
const toggle = () => {
|
|
65
|
+
if (native) return void document.exitFullscreen()
|
|
66
|
+
if (covering) return setCovering(false)
|
|
67
|
+
if (typeof box.current?.requestFullscreen === 'function' && document.fullscreenEnabled) return void box.current.requestFullscreen().catch(() => setCovering(true))
|
|
68
|
+
return setCovering(true)
|
|
69
|
+
}
|
|
70
|
+
return { full: native || covering, covering, toggle }
|
|
71
|
+
}
|
|
72
|
+
|
|
46
73
|
export function RoomView({ t, roomId, onLeave, onOpen }) {
|
|
47
74
|
const stage = React.useRef(null)
|
|
75
|
+
const playerBox = React.useRef(null)
|
|
76
|
+
const { shows } = React.useContext(Changes)
|
|
77
|
+
const [danmakuSettings, setDanmakuSettings] = useDanmakuSettings()
|
|
78
|
+
const [danmaku, setDanmaku] = React.useState({ index: null, items: NO_DANMAKU })
|
|
79
|
+
const [qualityBusy, setQualityBusy] = React.useState(false)
|
|
80
|
+
const screen = useFullScreen(playerBox)
|
|
48
81
|
const session = React.useRef(null)
|
|
49
82
|
const [view, setView] = React.useState({ connection: 'connecting', room: null, members: [], needsGesture: false })
|
|
50
83
|
const [toasts, setToasts] = React.useState([])
|
|
@@ -84,14 +117,34 @@ export function RoomView({ t, roomId, onLeave, onOpen }) {
|
|
|
84
117
|
}
|
|
85
118
|
}, [roomId])
|
|
86
119
|
|
|
120
|
+
// The show's notes change (another viewer picked a quality, the work was read again): read them again.
|
|
87
121
|
React.useEffect(() => {
|
|
88
122
|
let live = true
|
|
89
123
|
api(`rooms/${encodeURIComponent(roomId)}/work`).then((answer) => { if (live && answer.work) setAbout(answer) })
|
|
90
124
|
return () => { live = false }
|
|
91
|
-
}, [roomId])
|
|
125
|
+
}, [roomId, shows])
|
|
92
126
|
|
|
93
127
|
const room = view.room
|
|
94
128
|
const item = room?.items[room.index]
|
|
129
|
+
const index = room?.index ?? null
|
|
130
|
+
const wantsDanmaku = about?.danmaku === true && danmakuSettings.on
|
|
131
|
+
React.useEffect(() => {
|
|
132
|
+
if (!wantsDanmaku || index === null) return undefined
|
|
133
|
+
let live = true
|
|
134
|
+
setDanmaku({ index, items: NO_DANMAKU })
|
|
135
|
+
api(`rooms/${encodeURIComponent(roomId)}/danmaku/${index}`).then((answer) => {
|
|
136
|
+
if (live && Array.isArray(answer.items)) setDanmaku({ index, items: answer.items })
|
|
137
|
+
})
|
|
138
|
+
return () => { live = false }
|
|
139
|
+
}, [roomId, index, wantsDanmaku])
|
|
140
|
+
const choices = about?.work?.qualities ?? []
|
|
141
|
+
const pickQuality = async (quality) => {
|
|
142
|
+
setQualityBusy(true)
|
|
143
|
+
const answer = await post(`rooms/${encodeURIComponent(roomId)}/quality`, { quality })
|
|
144
|
+
setQualityBusy(false)
|
|
145
|
+
if (answer.error) toast(answer.error)
|
|
146
|
+
else setAbout(current => ({ ...current, quality: answer.quality }))
|
|
147
|
+
}
|
|
95
148
|
const copy = async () => {
|
|
96
149
|
if (await copyText(roomLink(roomId), t('room.copy'))) {
|
|
97
150
|
setCopied(true)
|
|
@@ -111,6 +164,8 @@ export function RoomView({ t, roomId, onLeave, onOpen }) {
|
|
|
111
164
|
onLeave()
|
|
112
165
|
}
|
|
113
166
|
|
|
167
|
+
const tabs = [room && room.items.length > 1 && 'episodes', about && 'about', about?.comments && 'comments'].filter(Boolean)
|
|
168
|
+
const shownSide = tabs.includes(side) ? side : tabs[0]
|
|
114
169
|
const season = about ? nextSeason(about.work) : null
|
|
115
170
|
const seasonKnown = useKnownWork(about?.source, season?.id)
|
|
116
171
|
const watchSeason = async () => {
|
|
@@ -150,40 +205,52 @@ export function RoomView({ t, roomId, onLeave, onOpen }) {
|
|
|
150
205
|
room?.together && h('button', { type: 'button', className: 'vsync-icon', 'aria-label': copied ? t('room.copied') : t('room.copy'), title: copied ? t('room.copied') : t('room.copy'), onClick: copy }, h(Icon.Link)),
|
|
151
206
|
h('button', { type: 'button', className: 'vsync-icon', 'aria-label': t('room.close'), title: t('room.close'), onClick: () => setClosing(true) }, h(Icon.Close)))),
|
|
152
207
|
h('div', { className: 'vsync-body' },
|
|
153
|
-
h('div', { className: 'vsync-
|
|
154
|
-
h('div', { className: 'vsync-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
:
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
208
|
+
h('div', { className: 'vsync-player', ref: playerBox, 'data-covering': String(screen.covering) },
|
|
209
|
+
h('div', { className: 'vsync-stageWrap' },
|
|
210
|
+
h('div', { className: 'vsync-stage', ref: stage }),
|
|
211
|
+
wantsDanmaku && danmaku.index === index && h(DanmakuLayer, { media: session.current?.media ?? null, items: danmaku.items, settings: danmakuSettings }),
|
|
212
|
+
overlay && h('div', { className: 'vsync-overlay' }, overlay),
|
|
213
|
+
h('div', { className: 'vsync-toasts', role: 'status', 'aria-live': 'polite' }, toasts.map(item => h('span', { key: item.id, className: 'vsync-toast' }, item.text)))),
|
|
214
|
+
room && h(PlayerBar, {
|
|
215
|
+
t,
|
|
216
|
+
settings: danmakuSettings,
|
|
217
|
+
onSettings: setDanmakuSettings,
|
|
218
|
+
danmaku: about?.danmaku === true,
|
|
219
|
+
count: danmaku.index === index && danmaku.items !== NO_DANMAKU ? danmaku.items.length : null,
|
|
220
|
+
quality: choices.length > 1 ? { value: choices.includes(about.quality) ? about.quality : choices[0], choices, onChange: pickQuality, busy: qualityBusy } : null,
|
|
221
|
+
full: screen.full,
|
|
222
|
+
onFull: screen.toggle,
|
|
223
|
+
})),
|
|
224
|
+
tabs.length > 0 && h('aside', { className: 'vsync-episodes', 'aria-label': t('room.episodes') },
|
|
225
|
+
tabs.length > 1 && h('div', { className: 'vsync-sideTabs', role: 'tablist' },
|
|
226
|
+
tabs.map(tab => h('button', { key: tab, type: 'button', role: 'tab', className: 'vsync-chip', 'aria-selected': String(shownSide === tab), onClick: () => setSide(tab) }, t(`room.tab.${tab}`)))),
|
|
227
|
+
shownSide === 'about' && h(About, { t, work: about.work, source: about.source, workId: about.id }),
|
|
228
|
+
shownSide === 'comments' && h(Comments, { t, roomId }),
|
|
229
|
+
shownSide === 'episodes' && h(React.Fragment, null,
|
|
230
|
+
!about && h('h2', null, t('room.episodes')),
|
|
231
|
+
h('ol', { className: 'vsync-episodeList' }, room.items.map((episode, index) => {
|
|
232
|
+
const mark = watchMark(t, episode.watch, index === room.index)
|
|
233
|
+
const title = episode.title ?? fill(t('room.episodeN'), { n: index + 1 })
|
|
234
|
+
return h('li', { key: index },
|
|
235
|
+
h('button', {
|
|
236
|
+
type: 'button',
|
|
237
|
+
className: 'vsync-episode',
|
|
238
|
+
'aria-current': String(index === room.index),
|
|
239
|
+
'data-watch': mark.state,
|
|
240
|
+
'data-cached': String(episode.cached),
|
|
241
|
+
title: episode.cached ? undefined : t('room.notCached'),
|
|
242
|
+
disabled: episode.status === 'failed' && episode.cached,
|
|
243
|
+
onClick: () => session.current?.select(index),
|
|
244
|
+
},
|
|
245
|
+
h('span', { className: 'vsync-episodeNo' }, index + 1),
|
|
246
|
+
h('span', { className: 'vsync-episodeMain' },
|
|
247
|
+
h('span', { className: 'vsync-episodeTitle' }, title),
|
|
248
|
+
mark.bar),
|
|
249
|
+
episode.status === 'preparing'
|
|
250
|
+
? h('span', { className: 'vsync-episodeState' }, progressFraction(episode.progress) === null ? '…' : `${Math.floor(progressFraction(episode.progress) * 100)}%`)
|
|
251
|
+
: mark.note))
|
|
252
|
+
})),
|
|
253
|
+
season && h('div', { className: 'vsync-nextSeason', 'data-last': String(room.index === room.items.length - 1) },
|
|
254
|
+
h('span', { className: 'vsync-nextSeasonText' }, fill(t('room.nextSeason'), { title: season.title })),
|
|
255
|
+
h('button', { type: 'button', className: 'vsync-btn vsync-primary', disabled: seasonBusy, onClick: watchSeason }, seasonBusy ? t('search.opening') : seasonKnown.room !== null ? t('search.joinRoom') : seasonKnown.show !== null ? t(seasonKnown.show.resume ? 'search.continue' : 'search.open') : t('search.watch')))))))
|
|
189
256
|
}
|
package/web/ui.js
CHANGED
|
@@ -239,6 +239,10 @@ export const Icon = {
|
|
|
239
239
|
Download: ({ size = 16 }) => svg(size, h('path', { d: 'M8 2.5v8M4.75 7.5 8 10.75l3.25-3.25M3 13.5h10', ...stroke })),
|
|
240
240
|
Book: ({ size = 16 }) => svg(size, h('path', { d: 'M3 3.5A1.5 1.5 0 0 1 4.5 2H13v10H4.5A1.5 1.5 0 0 0 3 13.5Zm0 10A1.5 1.5 0 0 0 4.5 15H13v-3', ...stroke })),
|
|
241
241
|
Check: ({ size = 16 }) => svg(size, h('path', { d: 'M3.5 8.5 6.5 11.5 12.5 4.5', ...stroke })),
|
|
242
|
+
Danmaku: ({ size = 16 }) => svg(size, h('rect', { x: 1.75, y: 3, width: 12.5, height: 10, rx: 2, ...stroke }), h('path', { d: 'M4.5 6.5h4M7 9.5h4.5', ...stroke })),
|
|
243
|
+
Settings: ({ size = 16 }) => svg(size, h('path', { d: 'M2.5 4.5h6M11.5 4.5h2M2.5 11.5h2M7.5 11.5h6', ...stroke }), h('circle', { cx: 10, cy: 4.5, r: 1.5, ...stroke }), h('circle', { cx: 6, cy: 11.5, r: 1.5, ...stroke })),
|
|
244
|
+
Expand: ({ size = 16 }) => svg(size, h('path', { d: 'M2.5 6V2.5H6M10 2.5h3.5V6M13.5 10v3.5H10M6 13.5H2.5V10', ...stroke })),
|
|
245
|
+
Shrink: ({ size = 16 }) => svg(size, h('path', { d: 'M6 2.5V6H2.5M13.5 6H10V2.5M10 13.5V10h3.5M2.5 10H6v3.5', ...stroke })),
|
|
242
246
|
Chevron: ({ size = 16, open = false }) => svg(size, h('path', { d: open ? 'M4 6l4 4 4-4' : 'M6 4l4 4-4 4', ...stroke })),
|
|
243
247
|
}
|
|
244
248
|
|
|
@@ -288,17 +292,12 @@ export function Confirm({ t, question, confirmLabel, onConfirm, onCancel, danger
|
|
|
288
292
|
}, confirmLabel))
|
|
289
293
|
}
|
|
290
294
|
|
|
291
|
-
/**
|
|
292
|
-
|
|
293
|
-
* Without children it is the "more" icon; with children, a quiet text button.
|
|
294
|
-
*/
|
|
295
|
-
export function Menu({ label, items, children, title }) {
|
|
296
|
-
const [open, setOpen] = React.useState(false)
|
|
297
|
-
const root = React.useRef(null)
|
|
295
|
+
/** Close something open on a press outside `root` or on Escape. */
|
|
296
|
+
function useDismiss(open, close, root) {
|
|
298
297
|
React.useEffect(() => {
|
|
299
298
|
if (!open) return undefined
|
|
300
|
-
const away = (event) => { if (!root.current?.contains(event.target))
|
|
301
|
-
const key = (event) => { if (event.key === 'Escape')
|
|
299
|
+
const away = (event) => { if (!root.current?.contains(event.target)) close() }
|
|
300
|
+
const key = (event) => { if (event.key === 'Escape') close() }
|
|
302
301
|
document.addEventListener('pointerdown', away)
|
|
303
302
|
document.addEventListener('keydown', key)
|
|
304
303
|
return () => {
|
|
@@ -306,6 +305,16 @@ export function Menu({ label, items, children, title }) {
|
|
|
306
305
|
document.removeEventListener('keydown', key)
|
|
307
306
|
}
|
|
308
307
|
}, [open])
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* A button with a small menu of actions; closes on outside click or Escape.
|
|
312
|
+
* Without children it is the "more" icon; with children, a quiet text button.
|
|
313
|
+
*/
|
|
314
|
+
export function Menu({ label, items, children, title }) {
|
|
315
|
+
const [open, setOpen] = React.useState(false)
|
|
316
|
+
const root = React.useRef(null)
|
|
317
|
+
useDismiss(open, () => setOpen(false), root)
|
|
309
318
|
return h('span', { className: 'vsync-menuWrap', ref: root },
|
|
310
319
|
h('button', { type: 'button', className: children ? 'vsync-metaButton' : 'vsync-icon', 'aria-label': label, title: title ?? label, 'aria-haspopup': 'menu', 'aria-expanded': String(open), onClick: () => setOpen(!open) }, children ?? h(Icon.More)),
|
|
311
320
|
open && h('div', { className: 'vsync-menu', role: 'menu' }, items.filter(Boolean).map(item => h('button', {
|
|
@@ -319,3 +328,16 @@ export function Menu({ label, items, children, title }) {
|
|
|
319
328
|
},
|
|
320
329
|
}, item.label))))
|
|
321
330
|
}
|
|
331
|
+
|
|
332
|
+
/** An icon button that opens a small panel of settings above it; closes on outside click or Escape. */
|
|
333
|
+
export function Popover({ label, icon, children }) {
|
|
334
|
+
const [open, setOpen] = React.useState(false)
|
|
335
|
+
const root = React.useRef(null)
|
|
336
|
+
useDismiss(open, () => setOpen(false), root)
|
|
337
|
+
return h('span', { className: 'vsync-menuWrap', ref: root },
|
|
338
|
+
h('button', { type: 'button', className: 'vsync-icon', 'aria-label': label, title: label, 'aria-haspopup': 'dialog', 'aria-expanded': String(open), onClick: () => setOpen(!open) }, icon),
|
|
339
|
+
open && h('div', { className: 'vsync-popover', role: 'dialog', 'aria-label': label }, children))
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/** The words for a quality a source offers (src/quality.js): auto, audio, or a height. */
|
|
343
|
+
export const qualityLabel = (t, quality) => (/^\d+$/.test(quality) ? fill(t('quality.height'), { n: quality }) : t(`quality.${quality}`))
|
package/web/watching-view.js
CHANGED
|
@@ -81,7 +81,7 @@ export function WatchingTab({ t, rooms, library, onOpen, onChanged, onGo, onOpen
|
|
|
81
81
|
h('h2', { id: 'vsync-news' }, t('follow.news')),
|
|
82
82
|
h('ul', { className: 'vsync-cards' }, news.map(show => h(NewsRow, { key: show.path, t, show, onOpen, onChanged })))),
|
|
83
83
|
h(RatingsSection, { t, on: presence.ratings === true, version: watchedVersion }),
|
|
84
|
-
h(PicksSection, { t, on: presence.picks === true, onOpen, onOpenWork }),
|
|
84
|
+
h(PicksSection, { t, on: presence.picks === true, sources, onOpen, onSaved: onChanged, onOpenWork }),
|
|
85
85
|
h(RoomsSection, { t, rooms, onOpen, onChanged }),
|
|
86
86
|
others.length > 0 && h('section', { className: 'vsync-section', 'aria-labelledby': 'vsync-continue' },
|
|
87
87
|
h('h2', { id: 'vsync-continue' }, t('watching.continue')),
|