diff options
Diffstat (limited to 'src/media-timeline.js')
| -rw-r--r-- | src/media-timeline.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/media-timeline.js b/src/media-timeline.js index d8ae008..a70a46c 100644 --- a/src/media-timeline.js +++ b/src/media-timeline.js @@ -20,6 +20,18 @@ export function readMoment(event, depth = 0) { const tag = event?.tags?.find(t => t[0] === 'media'); return tag && /^\d+$/.test(tag[2] || '') ? mediaMoment(tag[1], Number(tag[2])) : null; } +// "didn't intend to tie it to the video timestamp but i guess it did by +// default" (Adam, 2026-11-14, a zap with a comment on a clip he'd played). +// A reply, zap or reaction made while a clip has played is ABOUT that +// moment only when asked: this toggle, off until tapped. +export function momentToggle(h, moment, on, onToggle, label) { + if (!moment) return null; + return h('button', { + type: 'button', class: 'moment-toggle' + (on ? ' on' : ''), 'aria-pressed': on ? 'true' : 'false', + onClick: (e) => { e.stopPropagation(); onToggle(!on); }, + }, h('span', { 'aria-hidden': 'true' }, on ? '\u2713' : '\u23f1'), ' ', label); +} + export function mediaClock(seconds) { const s = Math.max(0, Math.floor(seconds || 0)); return Math.floor(s / 60) + ':' + String(s % 60).padStart(2, '0'); |
