rvlib-shipkit 2.9.0 → 2.10.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 +10 -0
- package/package.json +1 -1
- package/src/cli/cmd_Review.ts +2 -1
- package/src/review/cells.ts +548 -0
- package/src/review/format.ts +1 -1
- package/src/review/model.ts +29 -4
- package/src/review/previews.ts +124 -0
- package/src/review/routes.ts +82 -45
- package/src/review/store.ts +6 -5
- package/src/serve/hub-app/review/kind-view.tsx +21 -22
- package/src/serve/hub-app/review/kit.tsx +11 -12
- package/src/serve/hub-app/review/review-board.tsx +15 -13
- package/src/serve/hub-app/review/review-cells.tsx +241 -0
- package/src/serve/hub-app/review/review-kit.ts +79 -0
- package/src/serve/hub-app/review/review-list.tsx +87 -122
- package/src/serve/hub-app/review/review-page.tsx +22 -79
- package/src/serve/hub-app/review/review-st.ts +268 -698
- package/src/serve/hub-app/review/review-thread.tsx +301 -0
- package/src/serve/hub-app/review/review-views.tsx +322 -253
- package/src/serve/hub-app/review/thread-st.ts +770 -0
- package/src/serve/hub-app/review.css +234 -90
- package/src/serve/hub-app/review/review-answer.tsx +0 -249
|
@@ -1,147 +1,263 @@
|
|
|
1
|
-
// the
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
1
|
+
// the views of one version, each its own numbered sub cell (`3.2`): a big title and its kind, drawn by kind (an image,
|
|
2
|
+
// a pair side by side, as a curtain, an onion skin or the after alone, a clip on its own clock, a sound, a gallery), then
|
|
3
|
+
// what was said on it right under it. Images come at the column's size (a 1600 px preview), the full file only on zoom.
|
|
4
|
+
// The newest version takes his marks: a drag on an image draws a rectangle whose note box opens beside it, a clip pauses
|
|
5
|
+
// and keeps the frame's time. A choice, or views that each play alone, read as option rows, each image and clip full
|
|
6
|
+
// under its row
|
|
6
7
|
import { observer } from 'mobx-react-lite'
|
|
7
8
|
import { useEffect, useRef, useState, type ReactNode } from 'react'
|
|
8
|
-
import
|
|
9
|
+
import type { VersionCell } from '../../../review/cells.ts'
|
|
10
|
+
import { isChoice, isGallery, isPair, onFrame, STARS, STATUS_LABEL, thumbFileOf, viewFilesOf, viewName, viewTag, type GalleryView, type Item, type MediaView, type Rect, type ReviewClip, type ReviewMark, type ReviewView, type Side } from '../../../review/model.ts'
|
|
9
11
|
import { AutoText } from '../auto-text.tsx'
|
|
10
|
-
import { blurOnEscape, Empty, FIT_ROOM, keepFocus, PAIR_NAMES, REACTIONS, secs } from './kit.tsx'
|
|
11
|
-
import { CardHead } from './review-answer.tsx'
|
|
12
12
|
import type { ClipSt } from './clip-st.ts'
|
|
13
|
-
import {
|
|
13
|
+
import { blurOnEscape, FIT_ROOM, keepFocus, PAIR_NAMES, REACTIONS, secs, SIDE_LABEL } from './kit.tsx'
|
|
14
|
+
import { ZOOMS, type Zoom } from './review-kit.ts'
|
|
15
|
+
import { COMPARE_MODES, drawnSide, type CompareMode, type CompareSt, type PairSide, type ReviewSt } from './review-st.ts'
|
|
16
|
+
import { viewDom, viewKind, viewKey, type ThreadSt } from './thread-st.ts'
|
|
14
17
|
|
|
15
18
|
const ZOOM_LABEL: Record<Zoom, string> = { fit: 'Fit', '1': '100 %', '1.5': '150 %', '2': '200 %' }
|
|
16
19
|
const toneClass = (s: string | undefined): string => (s ? ` re-${s}` : '')
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
/** one version as its views draw it: `live` when it takes his marks (the newest version of an agent's card, no draft) */
|
|
22
|
+
export interface Ver {
|
|
23
|
+
rv: ReviewSt
|
|
24
|
+
card: ThreadSt
|
|
25
|
+
cell: VersionCell
|
|
26
|
+
live: boolean
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const itemOf = (ver: Ver): Item => ver.cell.item
|
|
30
|
+
|
|
31
|
+
/** a version's views: its bar (rows or full, « Circle » on a phone, the zoom), then each view as a sub cell or a row */
|
|
32
|
+
export const VersionViews = observer(({ ver }: { ver: Ver }) => {
|
|
33
|
+
const { rv, card } = ver
|
|
34
|
+
const item = itemOf(ver)
|
|
35
|
+
const views = item.views
|
|
36
|
+
const rows = card.rows(item)
|
|
37
|
+
const drawable = ver.live && views.some((v) => !isGallery(v) && !v.clip && !v.audio)
|
|
25
38
|
// a draft card's history is no view of its own: its frames cycle in place over the live one
|
|
26
|
-
const history =
|
|
39
|
+
const history = item.wip ? views.find(isGallery) : undefined
|
|
40
|
+
const options = rows || (card.full[item.id] === true)
|
|
27
41
|
return (
|
|
28
42
|
<div className="rv-views">
|
|
29
|
-
{rv.headInViews ? <CardHead rv={rv} x={x} /> : null}
|
|
30
43
|
<div className="rv-viewsbar">
|
|
31
|
-
{
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
<
|
|
35
|
-
<button className={rows ? 'on' : ''} onMouseDown={keepFocus} onClick={() => rv.setFull(false)}>rows</button>
|
|
36
|
-
<button className={rows ? '' : 'on'} onMouseDown={keepFocus} onClick={() => rv.setFull(true)}>full</button>
|
|
37
|
-
</span>
|
|
38
|
-
) : null}
|
|
39
|
-
{rv.phone.on && drawable ? (
|
|
40
|
-
<button className={rv.phone.draw ? 'primary' : ''} onClick={() => rv.phone.toggleDraw()}>Circle</button>
|
|
41
|
-
) : null}
|
|
42
|
-
{rv.phone.on ? null : (
|
|
43
|
-
<span className="seg" title="the card against its answer: on top of it, left of it, or auto (on top when the page is narrow)">
|
|
44
|
-
{CARD_PLACES.map((p) => <button key={p} className={rv.place === p ? 'on' : ''} onMouseDown={keepFocus} onClick={() => rv.setPlace(p)}>{p}</button>)}
|
|
45
|
-
</span>
|
|
46
|
-
)}
|
|
47
|
-
<span className="seg" title="the zoom every view starts at">
|
|
48
|
-
{ZOOMS.map((z) => <button key={z} className={rv.zoom === z ? 'on' : ''} onMouseDown={keepFocus} onClick={() => rv.setZoom(z)}>{ZOOM_LABEL[z]}</button>)}
|
|
44
|
+
{options ? (
|
|
45
|
+
<span className="seg" title="the options as thin rows, one below the other, or every view full">
|
|
46
|
+
<button className={rows ? 'on' : ''} onMouseDown={keepFocus} onClick={() => card.setFull(item.id, false)}>rows</button>
|
|
47
|
+
<button className={rows ? '' : 'on'} onMouseDown={keepFocus} onClick={() => card.setFull(item.id, true)}>full</button>
|
|
49
48
|
</span>
|
|
49
|
+
) : null}
|
|
50
|
+
{rv.phone.on && drawable ? <button className={rv.phone.draw ? 'primary' : ''} onClick={() => rv.phone.toggleDraw()}>Circle</button> : null}
|
|
51
|
+
<span className="sp" />
|
|
52
|
+
<span className="seg" title="the zoom every view starts at">
|
|
53
|
+
{ZOOMS.map((z) => <button key={z} className={rv.zoom === z ? 'on' : ''} onMouseDown={keepFocus} onClick={() => rv.setZoom(z)}>{ZOOM_LABEL[z]}</button>)}
|
|
50
54
|
</span>
|
|
51
55
|
</div>
|
|
52
|
-
{rv.answered.map((y) => <Raised key={y.item.id} rv={rv} x={y} />)}
|
|
53
56
|
{rows ? (
|
|
54
|
-
<div className="rv-opts">{views.map((v, i) => <OptionRow key={
|
|
57
|
+
<div className="rv-opts">{views.map((v, i) => <OptionRow key={i} ver={ver} v={v} i={i} />)}</div>
|
|
55
58
|
) : (
|
|
56
|
-
views.map((v, i) => (v === history ? null : (
|
|
57
|
-
<ViewBlock key={`${r.id}#${i}`} rv={rv} id={r.id} v={v} i={i} many={views.length > (history ? 2 : 1)} {...(i === 0 && history && isGallery(history) ? { frames: history } : {})} />
|
|
58
|
-
)))
|
|
59
|
+
views.map((v, i) => (v === history ? null : <ViewCell key={i} ver={ver} v={v} i={i} {...(i === 0 && history && isGallery(history) ? { frames: history } : {})} />))
|
|
59
60
|
)}
|
|
60
|
-
{views.length === 0 ? <TextOnly x={x} /> : null}
|
|
61
61
|
</div>
|
|
62
62
|
)
|
|
63
63
|
})
|
|
64
64
|
|
|
65
|
-
/**
|
|
66
|
-
const
|
|
65
|
+
/** one view as a sub cell: its number and title, its kind, the owner's reaction, its tools, the view, then what was said on it */
|
|
66
|
+
const ViewCell = observer(({ ver, v: live, i, frames }: { ver: Ver; v: ReviewView; i: number; frames?: GalleryView }) => {
|
|
67
|
+
const { rv, card, cell } = ver
|
|
68
|
+
const past = frames && card.frame !== null ? frames.gallery[card.frame] : undefined
|
|
69
|
+
const v: ReviewView = past && !isGallery(live) ? { ...live, files: { image: past.file }, size: past.size } : live
|
|
70
|
+
const media = isGallery(v) ? null : v
|
|
71
|
+
const open = card.viewOpen(cell.id, i)
|
|
72
|
+
const zoom = card.zoomOf(cell.id, i)
|
|
73
|
+
const shown = card.reactionShown(cell, i)
|
|
74
|
+
const active = ver.live && card.view === i
|
|
75
|
+
const gone = goneOf(ver, v)
|
|
76
|
+
return (
|
|
77
|
+
<section id={viewDom(cell.id, i)} className={`rv-view${toneClass(shown?.status)}${active ? ' active' : ''}${open ? '' : ' folded'}`}>
|
|
78
|
+
<header className="rv-viewhead">
|
|
79
|
+
<button className="rv-foldbtn" aria-label={open ? 'fold this view' : 'unfold this view'} aria-expanded={open} onMouseDown={keepFocus} onClick={() => card.toggleView(cell.id, i)}>{open ? '▾' : '▸'}</button>
|
|
80
|
+
<span className="rv-viewn">{viewTag(cell.n, i)}</span>
|
|
81
|
+
<h4 className="rv-viewname" onClick={() => card.toggleView(cell.id, i)}>{v.label || <span className="rv-dim">{viewName(v, i)}</span>}</h4>
|
|
82
|
+
<span className="rv-kind">{viewKind(v, false)}</span>
|
|
83
|
+
{ver.live ? <ReactionToggles card={card} view={i} /> : shown?.status ? <SentReaction status={shown.status} /> : null}
|
|
84
|
+
<span className="sp" />
|
|
85
|
+
{open && media?.marks && media.marks.length > 0 ? <button className={rv.marksOn ? 'primary' : ''} onMouseDown={keepFocus} onClick={() => rv.toggleMarks()}>marks · M</button> : null}
|
|
86
|
+
{open && media && isPair(media.files) && !media.audio && !rv.phone.on ? <CompareModes c={rv.compare} /> : null}
|
|
87
|
+
{open && media && !media.audio ? (
|
|
88
|
+
<button title={zoom === 'fit' ? 'see this image at its own size, the full file' : 'fit this image to the column'} onMouseDown={keepFocus}
|
|
89
|
+
onClick={() => card.setViewZoom(cell.id, i, zoom === 'fit' ? '1' : 'fit')}>{zoom === 'fit' ? '100 %' : 'Fit'}</button>
|
|
90
|
+
) : null}
|
|
91
|
+
</header>
|
|
92
|
+
{open ? (
|
|
93
|
+
<div className="rv-viewbody">
|
|
94
|
+
{frames ? <FrameSlider card={card} frames={frames} /> : null}
|
|
95
|
+
{gone.length > 0 ? <Gone files={gone} /> : isGallery(v) ? <Gallery ver={ver} v={v} view={i} /> : <MediaBody ver={ver} v={v} i={i} zoom={zoom} />}
|
|
96
|
+
{media?.note ? <div className="rv-viewnote">{media.note}</div> : null}
|
|
97
|
+
</div>
|
|
98
|
+
) : null}
|
|
99
|
+
<ViewNotes ver={ver} i={i} gallery={isGallery(v)} />
|
|
100
|
+
</section>
|
|
101
|
+
)
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
/** what was said on one view, under it: each answer's rectangles and reactions (a click shows the rectangle), then on
|
|
105
|
+
* the newest version his draft: each rectangle's word, his word on the view */
|
|
106
|
+
const ViewNotes = observer(({ ver, i, gallery, word = true }: { ver: Ver; i: number; gallery: boolean; word?: boolean }) => {
|
|
107
|
+
const { card, cell } = ver
|
|
108
|
+
const said = card.saidOn(cell.id, i)
|
|
109
|
+
const views = itemOf(ver).views
|
|
110
|
+
const draft = ver.live ? card.draft.rects.map((r, k) => [r, k] as const).filter(([r]) => (r.view ?? 0) === i) : []
|
|
111
|
+
const reaction = ver.live ? card.reactionOf(i) : null
|
|
112
|
+
if (said.length === 0 && draft.length === 0 && !(ver.live && word)) return null
|
|
113
|
+
return (
|
|
114
|
+
<div className="rv-viewnotes">
|
|
115
|
+
{said.map((s, k) => {
|
|
116
|
+
const tile = s.reaction?.tile
|
|
117
|
+
const where = tile !== undefined && isGalleryView(views[i]) ? (views[i] as GalleryView).gallery[tile]?.label ?? `tile ${tile + 1}` : null
|
|
118
|
+
return (
|
|
119
|
+
<div key={k} className={`rv-said${s.reaction?.status ? ` re-${s.reaction.status}` : s.rect ? ' rect' : ''}`}>
|
|
120
|
+
<span className="rv-saidmark">
|
|
121
|
+
{s.rect ? `⬚ ${s.rect.n}${s.rect.r.side ? ` ${SIDE_LABEL[s.rect.r.side]}` : ''}${s.rect.r.t !== undefined ? ` · ${secs(s.rect.r.t)}` : ''}` : `${REACTIONS.find((o) => o.status === s.reaction?.status)?.glyph ?? ''}${s.reaction?.stars ? ` ★${s.reaction.stars}` : ''}${where ? ` ${where}` : ''}`}
|
|
122
|
+
</span>
|
|
123
|
+
<span className="rv-saidtext">{(s.rect ? s.rect.r.comment : s.reaction?.comment) || <i className="rv-dim">{s.reaction?.status ? REACTIONS.find((o) => o.status === s.reaction?.status)?.tip : 'no word'}</i>}</span>
|
|
124
|
+
<span className="rv-saidwho rv-dim">you · {STATUS_LABEL[s.verdict.verdict]} · v{cell.n}</span>
|
|
125
|
+
</div>
|
|
126
|
+
)
|
|
127
|
+
})}
|
|
128
|
+
{draft.length > 0 ? (
|
|
129
|
+
<div className="rv-drafthead">
|
|
130
|
+
<b>your notes</b>
|
|
131
|
+
<span className="rv-dim">a draft: your verdict sends them</span>
|
|
132
|
+
</div>
|
|
133
|
+
) : null}
|
|
134
|
+
{draft.map(([r, k]) => (
|
|
135
|
+
<div key={`d${k}`} className={`rv-outrow${card.rect === k ? ' on' : ''}`}>
|
|
136
|
+
<button className={`rv-outbadge rect${card.rect === k ? ' on' : ''}`} title={r.t !== undefined ? 'go to this moment and open the note' : 'open the note on the image'} onMouseDown={keepFocus} onClick={() => card.pickRect(k, true)}>
|
|
137
|
+
{k + 1}{r.side ? ` ${SIDE_LABEL[r.side]}` : ''}{r.t !== undefined ? ` · ${secs(r.t)}` : ''}
|
|
138
|
+
</button>
|
|
139
|
+
<button className="rv-outtext ghost" title="open the note on the image" onMouseDown={keepFocus} onClick={() => card.pickRect(k, true)}>
|
|
140
|
+
{r.comment.trim() ? r.comment : <i className="rv-dim">no word yet</i>}
|
|
141
|
+
</button>
|
|
142
|
+
<button className="ghost rv-x" title="delete this note" aria-label="delete this note" onClick={() => card.removeRect(k)}>✕</button>
|
|
143
|
+
</div>
|
|
144
|
+
))}
|
|
145
|
+
{ver.live && word ? (
|
|
146
|
+
<AutoText className="rv-word" placeholder={gallery ? 'a word on these images' : 'a word on this view'} value={reaction?.comment ?? ''}
|
|
147
|
+
onKeyDown={blurOnEscape} onText={(t) => card.setReactionComment(i, undefined, t)} />
|
|
148
|
+
) : null}
|
|
149
|
+
</div>
|
|
150
|
+
)
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
const isGalleryView = (v: ReviewView | undefined): v is GalleryView => v !== undefined && isGallery(v)
|
|
154
|
+
|
|
155
|
+
/** a reaction an older answer gave, as a still pill */
|
|
156
|
+
const SentReaction = ({ status }: { status: string }) => {
|
|
157
|
+
const o = REACTIONS.find((r) => r.status === status)
|
|
158
|
+
return o ? <span className={`rv-react on re-${status}`}>{o.glyph} {o.label}</span> : null
|
|
159
|
+
}
|
|
67
160
|
|
|
68
161
|
/** one option of a choice, or one view of a group, as a row: its number, ▶ and the clock, its label, a strip that
|
|
69
162
|
* scrubs it, its stars and « pick » (a choice) or OK, fix, no (a group), ✎ his word, ⤢ folds or unfolds the full view
|
|
70
|
-
* under it (an image or a clip shows it from the start) */
|
|
71
|
-
const OptionRow = observer(({
|
|
163
|
+
* under it (an image or a clip shows it from the start). An older version's rows show what he gave them */
|
|
164
|
+
const OptionRow = observer(({ ver, v, i }: { ver: Ver; v: ReviewView; i: number }) => {
|
|
165
|
+
const { rv, card, cell } = ver
|
|
72
166
|
const [word, setWord] = useState(false)
|
|
73
|
-
const
|
|
167
|
+
const item = itemOf(ver)
|
|
168
|
+
const id = item.id
|
|
74
169
|
const media = isGallery(v) ? null : v
|
|
75
170
|
const playable = media !== null && !isPair(media.files) && (media.clip !== undefined || media.audio !== undefined) ? media : null
|
|
76
|
-
const c = playable ?
|
|
77
|
-
const reaction =
|
|
78
|
-
const choice =
|
|
79
|
-
const picked =
|
|
80
|
-
const
|
|
81
|
-
const unfolded = rv.rowOpen(i)
|
|
171
|
+
const c = playable ? card.clipOf(id, i) : null
|
|
172
|
+
const reaction = card.reactionShown(cell, i)
|
|
173
|
+
const choice = isChoice(item)
|
|
174
|
+
const picked = card.pickShown(cell) === i
|
|
175
|
+
const unfolded = card.rowOpen(item, i)
|
|
82
176
|
const file = playable ? ('video' in playable.files ? playable.files.video : 'audio' in playable.files ? playable.files.audio : '') : ''
|
|
83
177
|
const duration = playable?.clip?.duration ?? playable?.audio?.duration ?? 0
|
|
84
|
-
const showWord = word || (reaction?.comment ?? '') !== ''
|
|
178
|
+
const showWord = ver.live && (word || (reaction?.comment ?? '') !== '')
|
|
179
|
+
const active = ver.live && card.view === i
|
|
180
|
+
// an unfolded clip plays under its own bar: the row keeps no second clock
|
|
181
|
+
const clock2 = c !== null && !(unfolded && playable?.clip)
|
|
182
|
+
const gone = goneOf(ver, v)
|
|
85
183
|
return (
|
|
86
|
-
<div id={
|
|
184
|
+
<div id={viewDom(cell.id, i)} className={`rv-opt${active ? ' active' : ''}${picked ? ' picked' : ''}${unfolded ? ' unfolded' : ''}${toneClass(reaction?.status)}`} onMouseDownCapture={() => ver.live && card.view !== i && card.setView(i)}>
|
|
87
185
|
<div className="rv-optrow">
|
|
88
|
-
<span className="rv-optn">{i
|
|
89
|
-
{c ? (
|
|
90
|
-
<button className={`rv-optplay${c.paused ? '' : ' on'}`} title={`${c.paused ? 'play' : 'pause'} (${i + 1})`} onMouseDown={keepFocus} onClick={() =>
|
|
186
|
+
<span className="rv-optn">{viewTag(cell.n, i)}</span>
|
|
187
|
+
{c && clock2 ? (
|
|
188
|
+
<button className={`rv-optplay${c.paused ? '' : ' on'}`} title={`${c.paused ? 'play' : 'pause'}${ver.live ? ` (${i + 1})` : ''}`} onMouseDown={keepFocus} onClick={() => card.listen(id, i)}>
|
|
91
189
|
{c.paused ? '▶' : '❚❚'}
|
|
92
190
|
</button>
|
|
93
191
|
) : null}
|
|
94
192
|
<b className="rv-optlabel" title={viewName(v, i)}>{viewName(v, i)}</b>
|
|
95
193
|
{c && playable?.clip && !unfolded ? (
|
|
96
|
-
<span className="rv-optthumb" style={{ aspectRatio: `${playable.size.w} / ${playable.size.h}` }} onClick={() =>
|
|
97
|
-
<ClipVideo clip={c} src={rv.fileUrl(id, file)} poster={rv.
|
|
194
|
+
<span className="rv-optthumb" style={{ aspectRatio: `${playable.size.w} / ${playable.size.h}` }} onClick={() => card.toggleRow(item, i)} title="the full view">
|
|
195
|
+
<ClipVideo clip={c} src={rv.fileUrl(id, file, item.wip)} poster={rv.thumbUrl(id, playable.clip.poster)} loop={false} />
|
|
98
196
|
</span>
|
|
99
197
|
) : null}
|
|
100
|
-
{c && playable ? (
|
|
198
|
+
{c && playable && clock2 ? (
|
|
101
199
|
<Strip clip={c} duration={duration} wave={playable.audio ? rv.fileUrl(id, playable.audio.wave) : undefined} />
|
|
102
|
-
) : unfolded ?
|
|
103
|
-
<span className="rv-optthumb img" onClick={() =>
|
|
200
|
+
) : unfolded || c ? <span className="sp" /> : (
|
|
201
|
+
<span className="rv-optthumb img" onClick={() => card.toggleRow(item, i)} title="the full view"><img src={rv.thumbUrl(id, thumbFileOf(v))} alt="" draggable={false} loading="lazy" /></span>
|
|
104
202
|
)}
|
|
105
|
-
{c ? <span className="rv-mono rv-opttime">{clock(c.time)} / {clock(duration)}</span> : null}
|
|
203
|
+
{c && clock2 ? <span className="rv-mono rv-opttime">{clock(c.time)} / {clock(duration)}</span> : null}
|
|
106
204
|
<span className="rv-optacts">
|
|
107
|
-
{choice ? <Stars
|
|
108
|
-
<button className={`rv-optword${showWord ? ' on' : ''}`} title="a word on this one" onMouseDown={keepFocus} onClick={() => setWord(!word)}
|
|
205
|
+
{choice ? <Stars card={card} view={i} live={ver.live} given={reaction?.stars} /> : ver.live ? <ReactionToggles card={card} view={i} /> : reaction?.status ? <SentReaction status={reaction.status} /> : null}
|
|
206
|
+
{ver.live ? <button className={`rv-optword${showWord ? ' on' : ''}`} title="a word on this one" onMouseDown={keepFocus} onClick={() => setWord(!word)}>✎ word</button> : null}
|
|
109
207
|
{playable?.clip || !playable ? (
|
|
110
|
-
<button className={unfolded ? 'on' : ''} title={unfolded ? 'fold it back to its row' : '
|
|
208
|
+
<button className={unfolded ? 'on' : ''} title={unfolded ? 'fold it back to its row' : 'show it full under its row'} onMouseDown={keepFocus} onClick={() => card.toggleRow(item, i)}>{unfolded ? '▴ fold' : '▾ show'}</button>
|
|
111
209
|
) : null}
|
|
112
210
|
{playable?.audio ? <a className="rv-dl" href={rv.fileUrl(id, file)} download={`${id}-${file}`} title="download the sound">⤓</a> : null}
|
|
113
|
-
{choice ? (
|
|
114
|
-
<button className={`rv-pick${picked ? ' on' : ''}`} title=
|
|
211
|
+
{choice && ver.live ? (
|
|
212
|
+
<button className={`rv-pick${picked ? ' on' : ''}`} title="pick this one: it is your answer (P)" disabled={card.busy} onClick={() => void card.choose(i)}>
|
|
115
213
|
{picked ? '✓ picked' : 'pick'}
|
|
116
214
|
</button>
|
|
117
|
-
) : null}
|
|
215
|
+
) : choice && picked ? <span className="rv-pick on">✓ picked</span> : null}
|
|
118
216
|
</span>
|
|
119
217
|
</div>
|
|
120
218
|
{media?.note ? <div className="rv-optnote">{media.note}</div> : null}
|
|
219
|
+
{!ver.live && reaction?.comment ? <div className="rv-optnote rv-saidtext">« {reaction.comment} »</div> : null}
|
|
121
220
|
{showWord ? (
|
|
122
221
|
<AutoText className="rv-word" placeholder="a word on this one" value={reaction?.comment ?? ''} autoFocus={word && !reaction?.comment}
|
|
123
|
-
onKeyDown={blurOnEscape} onText={(t) =>
|
|
222
|
+
onKeyDown={blurOnEscape} onText={(t) => card.setReactionComment(i, undefined, t)} />
|
|
124
223
|
) : null}
|
|
125
224
|
{c && playable?.audio ? <SoundEl clip={c} src={rv.fileUrl(id, file)} /> : null}
|
|
126
225
|
{unfolded ? (
|
|
127
226
|
<div className="rv-optbody">
|
|
128
|
-
{isGallery(v) ? <Gallery
|
|
227
|
+
{gone.length > 0 ? <Gone files={gone} /> : isGallery(v) ? <Gallery ver={ver} v={v} view={i} /> : <MediaBody ver={ver} v={v} i={i} zoom={card.zoomOf(id, i)} />}
|
|
129
228
|
</div>
|
|
130
229
|
) : null}
|
|
230
|
+
<ViewNotes ver={ver} i={i} gallery={isGallery(v)} word={false} />
|
|
131
231
|
</div>
|
|
132
232
|
)
|
|
133
233
|
})
|
|
134
234
|
|
|
235
|
+
/** the files of a view the store no longer holds */
|
|
236
|
+
const goneOf = (ver: Ver, v: ReviewView): string[] => {
|
|
237
|
+
const missing = ver.card.data?.missing ?? []
|
|
238
|
+
if (missing.length === 0) return []
|
|
239
|
+
const id = itemOf(ver).id
|
|
240
|
+
return viewFilesOf({ ...itemOf(ver), views: [v] }).filter((n) => missing.includes(`${id}/${n}`))
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/** a view whose media the store no longer holds: said in place of a player that would stay black */
|
|
244
|
+
const Gone = ({ files }: { files: readonly string[] }) => (
|
|
245
|
+
<div className="rv-gone">
|
|
246
|
+
<b>the media is gone from the store</b>
|
|
247
|
+
<span className="rv-dim">{files.join(', ')}: deleted after the card was sent; its words and answers stay</span>
|
|
248
|
+
</div>
|
|
249
|
+
)
|
|
250
|
+
|
|
135
251
|
/** `1:05`: a time on a row, short */
|
|
136
252
|
const clock = (t: number): string => `${Math.floor(t / 60)}:${String(Math.floor(t % 60)).padStart(2, '0')}`
|
|
137
253
|
|
|
138
|
-
/** an option's score: STARS stars, a click on the one given clears it */
|
|
139
|
-
const Stars = observer(({
|
|
140
|
-
const n =
|
|
254
|
+
/** an option's score: STARS stars, a click on the one given clears it; an older version's stars as he gave them */
|
|
255
|
+
const Stars = observer(({ card, view, live, given }: { card: ThreadSt; view: number; live: boolean; given: number | undefined }) => {
|
|
256
|
+
const n = given ?? 0
|
|
141
257
|
return (
|
|
142
|
-
<span className="rv-stars" title={`your score (⇧1 to ⇧${STARS} on the row playing)`}>
|
|
258
|
+
<span className="rv-stars" title={live ? `your score (⇧1 to ⇧${STARS} on the row playing)` : 'your score'}>
|
|
143
259
|
{Array.from({ length: STARS }, (_, k) => (
|
|
144
|
-
<button key={k} className={k < n ? 'on' : ''} aria-label={`${k + 1} of ${STARS}`} onMouseDown={keepFocus} onClick={() =>
|
|
260
|
+
<button key={k} className={k < n ? 'on' : ''} disabled={!live} aria-label={`${k + 1} of ${STARS}`} onMouseDown={keepFocus} onClick={() => card.setStars(view, k + 1)}>{k < n ? '★' : '☆'}</button>
|
|
145
261
|
))}
|
|
146
262
|
</span>
|
|
147
263
|
)
|
|
@@ -188,84 +304,14 @@ const SoundEl = ({ clip, src }: { clip: ClipSt; src: string }) => {
|
|
|
188
304
|
if (!el) return
|
|
189
305
|
return clip.attach(el)
|
|
190
306
|
}, [clip, src])
|
|
191
|
-
return <audio ref={ref} src={src} preload="
|
|
307
|
+
return <audio ref={ref} src={src} preload="none" onEnded={() => clip.seek(0)} />
|
|
192
308
|
}
|
|
193
309
|
|
|
194
|
-
/** a raised item the open card answers, nested above its views: the owner's words, his still */
|
|
195
|
-
const Raised = observer(({ rv, x }: { rv: ReviewSt; x: ReviewItem }) => {
|
|
196
|
-
const opening = x.thread.find((m) => m.op === undefined && m.text !== undefined)
|
|
197
|
-
const first = x.item.views[0]
|
|
198
|
-
return (
|
|
199
|
-
<div className="rv-raised">
|
|
200
|
-
<div className="rv-dim">answers {x.item.origin.by === 'owner' ? 'your note' : 'a report'} · {x.item.title}</div>
|
|
201
|
-
{opening?.text ? <div className="rv-pre">{opening.text}</div> : null}
|
|
202
|
-
{first && !isGallery(first) && 'image' in first.files ? <img className="rv-raisedimg" src={rv.fileUrl(x.item.id, first.files.image)} alt="" /> : null}
|
|
203
|
-
</div>
|
|
204
|
-
)
|
|
205
|
-
})
|
|
206
|
-
|
|
207
|
-
/** an item with no view: its words, full width */
|
|
208
|
-
const TextOnly = ({ x }: { x: ReviewItem }) => {
|
|
209
|
-
const text = x.item.what ?? x.thread.find((m) => m.text !== undefined)?.text
|
|
210
|
-
return text ? <div className="rv-pre">{text}</div> : <Empty text="This item has no image and no text." />
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/** the views' labels on top of a card of several: a click scrolls to that view; a dot says the owner's reaction to it */
|
|
214
|
-
const JumpList = observer(({ rv }: { rv: ReviewSt }) => {
|
|
215
|
-
const x = rv.open
|
|
216
|
-
if (!x) return null
|
|
217
|
-
return (
|
|
218
|
-
<span className="rv-jumps">
|
|
219
|
-
{x.item.views.map((v, i) => (
|
|
220
|
-
<button key={i} className={`rv-jump${rv.view === i ? ' on' : ''}${toneClass(rv.reactionOf(i)?.status)}`} onMouseDown={keepFocus}
|
|
221
|
-
onClick={() => {
|
|
222
|
-
rv.setView(i)
|
|
223
|
-
document.getElementById(`review-view-${i}`)?.scrollIntoView({ behavior: 'smooth', block: 'start' })
|
|
224
|
-
}}>
|
|
225
|
-
{rv.reactionOf(i)?.status ? <span className="rv-jdot" /> : null}
|
|
226
|
-
{i + 1}. {viewName(v, i)}
|
|
227
|
-
</button>
|
|
228
|
-
))}
|
|
229
|
-
</span>
|
|
230
|
-
)
|
|
231
|
-
})
|
|
232
|
-
|
|
233
|
-
/** one view: its label, its reaction and zoom, its image, pair, clip or gallery, then his word on it; a draft card's
|
|
234
|
-
* live view carries its history's frames, one shown in its place */
|
|
235
|
-
const ViewBlock = observer(({ rv, id, v: live, i, many, frames }: { rv: ReviewSt; id: string; v: ReviewView; i: number; many: boolean; frames?: GalleryView }) => {
|
|
236
|
-
const past = frames && rv.frame !== null ? frames.gallery[rv.frame] : undefined
|
|
237
|
-
const v: ReviewView = past && !isGallery(live) ? { ...live, files: { image: past.file }, size: past.size } : live
|
|
238
|
-
const reaction = rv.reactionOf(i)
|
|
239
|
-
const media = isGallery(v) ? null : v
|
|
240
|
-
const zoom = rv.zoomOf(i)
|
|
241
|
-
return (
|
|
242
|
-
<div id={`review-view-${i}`} className={`rv-view${toneClass(reaction?.status)}${rv.view === i && many ? ' active' : ''}`}>
|
|
243
|
-
<div className="rv-viewhead">
|
|
244
|
-
<b className="rv-viewname">{many ? `${i + 1}. ` : ''}{viewName(v, i)}</b>
|
|
245
|
-
<ReactionToggles rv={rv} view={i} />
|
|
246
|
-
<span className="sp" />
|
|
247
|
-
{media?.marks && media.marks.length > 0 ? (
|
|
248
|
-
<button className={rv.marksOn ? 'primary' : ''} onMouseDown={keepFocus} onClick={() => rv.toggleMarks()}>marks · M</button>
|
|
249
|
-
) : null}
|
|
250
|
-
{media && isPair(media.files) && !media.audio && !rv.phone.on ? <CompareModes c={rv.compare} /> : null}
|
|
251
|
-
{media ? (
|
|
252
|
-
<button title={zoom === 'fit' ? 'see this image at its own size' : 'fit this image to the column'} onMouseDown={keepFocus}
|
|
253
|
-
onClick={() => rv.setViewZoom(i, zoom === 'fit' ? '1' : 'fit')}>{zoom === 'fit' ? '100 %' : 'Fit'}</button>
|
|
254
|
-
) : null}
|
|
255
|
-
</div>
|
|
256
|
-
{frames ? <FrameSlider rv={rv} frames={frames} /> : null}
|
|
257
|
-
{isGallery(v) ? <Gallery rv={rv} id={id} v={v} view={i} /> : <MediaBody rv={rv} id={id} v={v} i={i} zoom={zoom} />}
|
|
258
|
-
<AutoText className="rv-word" placeholder={isGallery(v) ? 'a word on these images' : 'a word on this image'} value={reaction?.comment ?? ''}
|
|
259
|
-
onKeyDown={blurOnEscape} onText={(t) => rv.setReactionComment(i, undefined, t)} />
|
|
260
|
-
</div>
|
|
261
|
-
)
|
|
262
|
-
})
|
|
263
|
-
|
|
264
310
|
/** a draft card's frames over its live view: a slider and two arrows cycle them in place, the live one at the right end */
|
|
265
|
-
const FrameSlider = observer(({
|
|
311
|
+
const FrameSlider = observer(({ card, frames }: { card: ThreadSt; frames: GalleryView }) => {
|
|
266
312
|
const last = frames.gallery.length
|
|
267
|
-
const at =
|
|
268
|
-
const go = (f: number): void =>
|
|
313
|
+
const at = card.frame ?? last
|
|
314
|
+
const go = (f: number): void => card.setFrame(f >= last ? null : Math.max(0, f))
|
|
269
315
|
return (
|
|
270
316
|
<div className="rv-frames">
|
|
271
317
|
<button title="the frame before" disabled={at === 0} onMouseDown={keepFocus} onClick={() => go(at - 1)}>‹</button>
|
|
@@ -276,15 +322,15 @@ const FrameSlider = observer(({ rv, frames }: { rv: ReviewSt; frames: GalleryVie
|
|
|
276
322
|
)
|
|
277
323
|
})
|
|
278
324
|
|
|
279
|
-
/** the owner's reaction to one view or tile: OK, fix or no; a click on the chosen one clears it */
|
|
280
|
-
const ReactionToggles = observer(({
|
|
281
|
-
const cur =
|
|
325
|
+
/** the owner's reaction to one view or tile of the newest version: OK, fix or no; a click on the chosen one clears it */
|
|
326
|
+
const ReactionToggles = observer(({ card, view, tile, small }: { card: ThreadSt; view: number; tile?: number; small?: boolean }) => {
|
|
327
|
+
const cur = card.reactionOf(view, tile)?.status
|
|
282
328
|
return (
|
|
283
329
|
<span className="rv-reacts">
|
|
284
330
|
{REACTIONS.map((o) => (
|
|
285
|
-
<button key={o.status} title={o.tip} className={`rv-react re-${o.status}${cur === o.status ? ' on' : ''}${cur && cur !== o.status ? ' off' : ''}`}
|
|
286
|
-
onMouseDown={keepFocus} onClick={() =>
|
|
287
|
-
{o.glyph}
|
|
331
|
+
<button key={o.status} title={o.tip} className={`rv-react re-${o.status}${small ? '' : ' big'}${cur === o.status ? ' on' : ''}${cur && cur !== o.status ? ' off' : ''}`}
|
|
332
|
+
onMouseDown={keepFocus} onClick={() => card.react(view, tile, o.status)}>
|
|
333
|
+
{o.glyph} {o.label}
|
|
288
334
|
</button>
|
|
289
335
|
))}
|
|
290
336
|
</span>
|
|
@@ -294,62 +340,73 @@ const ReactionToggles = observer(({ rv, view, tile, small }: { rv: ReviewSt; vie
|
|
|
294
340
|
/** a gallery tile's image height */
|
|
295
341
|
const TILE_H = 170
|
|
296
342
|
|
|
297
|
-
/** a gallery view: its images as a wrapping grid of small tiles, each with its label and its
|
|
298
|
-
* shows it large */
|
|
299
|
-
const Gallery = observer(({
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
343
|
+
/** a gallery view: its images as a wrapping grid of small tiles at the list's size, each with its label and its
|
|
344
|
+
* reaction; a click shows it large at the column's size */
|
|
345
|
+
const Gallery = observer(({ ver, v, view }: { ver: Ver; v: GalleryView; view: number }) => {
|
|
346
|
+
const { rv, card, cell } = ver
|
|
347
|
+
const id = itemOf(ver).id
|
|
348
|
+
return (
|
|
349
|
+
<div className="rv-gallery">
|
|
350
|
+
{v.gallery.map((t, k) => {
|
|
351
|
+
const big = card.bigTile === `${viewKey(id, view)}/${k}`
|
|
352
|
+
const r = card.reactionShown(cell, view, k)
|
|
353
|
+
const ratio = t.size.w / t.size.h
|
|
354
|
+
const w = big ? undefined : Math.round(Math.max(110, Math.min(260, TILE_H * ratio)))
|
|
355
|
+
return (
|
|
356
|
+
<div key={k} className={`rv-tile${big ? ' big' : ''}${toneClass(r?.status)}`} style={big ? undefined : { width: w }}>
|
|
357
|
+
<div className="rv-tileimg" onClick={() => card.toggleTile(id, view, k)} title={big ? 'click to shrink' : 'click to enlarge'}
|
|
358
|
+
style={big ? { width: `min(100%, calc((100vh - ${FIT_ROOM}px) * ${ratio}))`, aspectRatio: `${t.size.w} / ${t.size.h}` } : { height: TILE_H }}>
|
|
359
|
+
<img src={big ? rv.fitUrl(id, t.file) : rv.thumbUrl(id, t.file)} alt={t.label} draggable={false} loading="lazy" />
|
|
360
|
+
</div>
|
|
361
|
+
<div className="rv-tilelabel" title={t.label}>{t.label}</div>
|
|
362
|
+
{ver.live ? (
|
|
363
|
+
<>
|
|
364
|
+
<ReactionToggles card={card} view={view} tile={k} small />
|
|
365
|
+
<AutoText className="rv-word" placeholder="a word" value={r?.comment ?? ''} onKeyDown={blurOnEscape} onText={(t) => card.setReactionComment(view, k, t)} />
|
|
366
|
+
</>
|
|
367
|
+
) : r?.status ? <SentReaction status={r.status} /> : null}
|
|
311
368
|
</div>
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
)
|
|
318
|
-
})}
|
|
319
|
-
</div>
|
|
320
|
-
))
|
|
369
|
+
)
|
|
370
|
+
})}
|
|
371
|
+
</div>
|
|
372
|
+
)
|
|
373
|
+
})
|
|
321
374
|
|
|
322
375
|
/** one media view: a single image or clip, or the pair in the compare component; fitted to the column on its own, or
|
|
323
|
-
* zoomed with its own scroll */
|
|
324
|
-
const MediaBody = observer(({
|
|
325
|
-
|
|
376
|
+
* zoomed (the full file) with its own scroll */
|
|
377
|
+
const MediaBody = observer(({ ver, v, i, zoom }: { ver: Ver; v: MediaView; i: number; zoom: Zoom }) => {
|
|
378
|
+
const { rv, card } = ver
|
|
379
|
+
const item = itemOf(ver)
|
|
380
|
+
const id = item.id
|
|
381
|
+
if (v.audio) return <SoundBody ver={ver} v={v} />
|
|
326
382
|
const f = v.files
|
|
327
383
|
const ratio = v.size.w / v.size.h
|
|
328
384
|
const aspect = `${v.size.w} / ${v.size.h}`
|
|
329
385
|
const scale = zoom === 'fit' ? null : Number(zoom)
|
|
330
386
|
const room = FIT_ROOM + (v.clip ? 40 : 0)
|
|
331
|
-
const
|
|
387
|
+
const src = (name: string): string => (v.clip ? rv.fileUrl(id, name, item.wip) : scale ? rv.fileUrl(id, name, item.wip) : rv.fitUrl(id, name, item.wip))
|
|
388
|
+
const bar = v.clip ? <ClipBar clip={card.clipOf(id, i)} info={v.clip} use={() => ver.live && card.setView(i)} /> : null
|
|
332
389
|
const scroll = scale ? { overflow: 'auto', maxHeight: `calc(100vh - ${room}px)` } : undefined
|
|
333
390
|
if (!isPair(f)) {
|
|
334
391
|
const name = 'image' in f ? f.image : 'video' in f ? f.video : f.audio
|
|
335
392
|
return (
|
|
336
393
|
<div style={scroll}>
|
|
337
394
|
<div style={{ width: scale ? `${v.size.w * scale}px` : `min(100%, calc((100vh - ${room}px) * ${ratio}))`, margin: '0 auto' }}>
|
|
338
|
-
<Compare c={rv.compare} base={
|
|
339
|
-
over={() => <RectNote
|
|
395
|
+
<Compare c={rv.compare} base={src(name)} mod={undefined} aspect={aspect} draw={(s) => <Marks ver={ver} src={s} side={undefined} view={i} />}
|
|
396
|
+
over={() => (ver.live ? <RectNote card={card} view={i} sides={[undefined]} /> : null)} />
|
|
340
397
|
{bar}
|
|
341
|
-
<Downloads rv={rv}
|
|
398
|
+
<Downloads rv={rv} item={item} files={[{ file: name }]} />
|
|
342
399
|
</div>
|
|
343
400
|
</div>
|
|
344
401
|
)
|
|
345
402
|
}
|
|
346
|
-
const before =
|
|
347
|
-
const after =
|
|
348
|
-
const saves = <Downloads rv={rv}
|
|
403
|
+
const before = src(f.before)
|
|
404
|
+
const after = src(f.after)
|
|
405
|
+
const saves = <Downloads rv={rv} item={item} files={[{ file: f.before, label: 'before' }, { file: f.after, label: 'after' }]} />
|
|
349
406
|
if (rv.phone.on)
|
|
350
407
|
return (
|
|
351
408
|
<>
|
|
352
|
-
<PhonePair
|
|
409
|
+
<PhonePair ver={ver} view={i} bar={bar} before={before} after={after} aspect={aspect} size={v.size} scale={scale} />
|
|
353
410
|
{saves}
|
|
354
411
|
</>
|
|
355
412
|
)
|
|
@@ -361,8 +418,8 @@ const MediaBody = observer(({ rv, id, v, i, zoom }: { rv: ReviewSt; id: string;
|
|
|
361
418
|
<div style={scroll}>
|
|
362
419
|
<div className="rv-pairgrid" style={{ width: scale ? `${v.size.w * scale * cols + 8 * (cols - 1)}px` : fitW, gridTemplateColumns: `repeat(${cols}, 1fr)` }}>
|
|
363
420
|
<Compare c={c} base={before} mod={after} names={PAIR_NAMES} aspect={aspect}
|
|
364
|
-
draw={(s) => <Marks
|
|
365
|
-
over={(srcs) => <RectNote
|
|
421
|
+
draw={(s) => <Marks ver={ver} src={s} side={drawnSide(c.mode, s === before ? 'before' : 'after')} view={i} />}
|
|
422
|
+
over={(srcs) => (ver.live ? <RectNote card={card} view={i} sides={srcs.map((s) => drawnSide(c.mode, s === before ? 'before' : 'after'))} /> : null)} />
|
|
366
423
|
</div>
|
|
367
424
|
</div>
|
|
368
425
|
{bar ? <div style={{ width: fitW, margin: '0 auto' }}>{bar}</div> : null}
|
|
@@ -373,7 +430,9 @@ const MediaBody = observer(({ rv, id, v, i, zoom }: { rv: ReviewSt; id: string;
|
|
|
373
430
|
})
|
|
374
431
|
|
|
375
432
|
/** a sound view: its waveform over the browser's player, one row a side on a pair, each to download */
|
|
376
|
-
const SoundBody = ({
|
|
433
|
+
const SoundBody = ({ ver, v }: { ver: Ver; v: MediaView }) => {
|
|
434
|
+
const { rv } = ver
|
|
435
|
+
const item = itemOf(ver)
|
|
377
436
|
const f = v.files
|
|
378
437
|
const a = v.audio
|
|
379
438
|
if (!a) return null
|
|
@@ -384,28 +443,27 @@ const SoundBody = ({ rv, id, v }: { rv: ReviewSt; id: string; v: MediaView }) =>
|
|
|
384
443
|
<div key={r.file} className="rv-soundrow">
|
|
385
444
|
{r.label ? <div className="rv-dim">{r.label}</div> : null}
|
|
386
445
|
<div role="img" aria-label={`the waveform of ${r.file}`} className="rv-wavebox" style={{ aspectRatio: `${v.size.w} / ${v.size.h}` }}>
|
|
387
|
-
<Wave src={rv.fileUrl(id, r.wave)} className="rv-stripwave full" />
|
|
446
|
+
<Wave src={rv.fileUrl(item.id, r.wave)} className="rv-stripwave full" />
|
|
388
447
|
</div>
|
|
389
|
-
<audio controls preload="
|
|
448
|
+
<audio controls preload="none" src={rv.fileUrl(item.id, r.file)} style={{ width: '100%' }} />
|
|
390
449
|
</div>
|
|
391
450
|
))}
|
|
392
451
|
<div className="rv-dim">{secs(a.duration)}</div>
|
|
393
|
-
<Downloads rv={rv}
|
|
452
|
+
<Downloads rv={rv} item={item} files={rows.map((r) => ({ file: r.file, ...(r.label ? { label: r.label } : {}) }))} />
|
|
394
453
|
</div>
|
|
395
454
|
)
|
|
396
455
|
}
|
|
397
456
|
|
|
398
|
-
/** a view's files to save, each under the card's id and its own name */
|
|
399
|
-
const Downloads = observer(({ rv,
|
|
457
|
+
/** a view's files to save at full size, each under the card's id and its own name */
|
|
458
|
+
const Downloads = observer(({ rv, item, files }: { rv: ReviewSt; item: Item; files: readonly { file: string; label?: string }[] }) => (
|
|
400
459
|
<div className="rv-downloads">
|
|
401
|
-
{/* the Finder is on the desktop only: a phone has none */}
|
|
402
|
-
{rv.phone.on ? null : <button className="rv-dl ghost" title="show the card's folder in the Finder" onClick={() => void rv.reveal(id)}>📁</button>}
|
|
403
460
|
{files.map(({ file, label }) => (
|
|
404
|
-
<
|
|
405
|
-
<a className="rv-dl" href={rv.fileUrl(id, file)} download={`${id}-${file}`} title="download the file">⤓ {label ?? 'download'}</a>
|
|
406
|
-
{rv.phone.on ? null : <button className="rv-dl ghost" title={`show ${file} in the Finder`} onClick={() => void rv.reveal(id, file)}>📂</button>}
|
|
407
|
-
</span>
|
|
461
|
+
<a key={file} className="rv-dl" href={rv.fileUrl(item.id, file, item.wip)} download={`${item.id}-${file}`} title={`download ${file} at full size`}>⤓ save {label ?? (file.split('.').pop() ?? 'file')}</a>
|
|
408
462
|
))}
|
|
463
|
+
{/* the Finder is on the desktop only: a phone has none */}
|
|
464
|
+
{rv.phone.on || files[0] === undefined ? null : (
|
|
465
|
+
<button className="rv-dl ghost" title={`open the card's folder in the Finder, ${files[0].file} selected`} onClick={() => void rv.reveal(item.id, files[0]!.file)}>show in Finder</button>
|
|
466
|
+
)}
|
|
409
467
|
</div>
|
|
410
468
|
))
|
|
411
469
|
|
|
@@ -416,8 +474,8 @@ const PAIR_SIDES: { value: PairSide; label: string }[] = [
|
|
|
416
474
|
]
|
|
417
475
|
|
|
418
476
|
/** a pair on a phone: one side at a time full width, or the curtain; the zoom scrolls */
|
|
419
|
-
const PhonePair = observer(({
|
|
420
|
-
|
|
477
|
+
const PhonePair = observer(({ ver, view, bar, before, after, aspect, size, scale }: {
|
|
478
|
+
ver: Ver
|
|
421
479
|
view: number
|
|
422
480
|
bar: ReactNode
|
|
423
481
|
before: string
|
|
@@ -426,6 +484,7 @@ const PhonePair = observer(({ rv, view, bar, before, after, aspect, size, scale
|
|
|
426
484
|
size: { w: number; h: number }
|
|
427
485
|
scale: number | null
|
|
428
486
|
}) => {
|
|
487
|
+
const { rv, card } = ver
|
|
429
488
|
const ph = rv.phone
|
|
430
489
|
const c = rv.compare
|
|
431
490
|
const side = ph.pair === 'swipe' && c.mode !== 'swipe' ? 'after' : ph.pair
|
|
@@ -440,11 +499,11 @@ const PhonePair = observer(({ rv, view, bar, before, after, aspect, size, scale
|
|
|
440
499
|
<div style={scale ? { overflow: 'auto', maxHeight: '70vh' } : undefined}>
|
|
441
500
|
<div style={{ width: scale ? `${size.w * scale}px` : '100%' }}>
|
|
442
501
|
{side === 'swipe' ? (
|
|
443
|
-
<Compare c={c} base={before} mod={after} names={PAIR_NAMES} aspect={aspect} draw={(s) => <Marks
|
|
444
|
-
over={(srcs) => <RectNote
|
|
502
|
+
<Compare c={c} base={before} mod={after} names={PAIR_NAMES} aspect={aspect} draw={(s) => <Marks ver={ver} src={s} side={s === before ? 'before' : 'after'} view={view} />}
|
|
503
|
+
over={(srcs) => (ver.live ? <RectNote card={card} view={view} sides={srcs.map((s) => (s === before ? 'before' : 'after'))} /> : null)} />
|
|
445
504
|
) : (
|
|
446
|
-
<Compare key={side} c={c} base={one} mod={undefined} aspect={aspect} draw={(s) => <Marks
|
|
447
|
-
over={() => <RectNote
|
|
505
|
+
<Compare key={side} c={c} base={one} mod={undefined} aspect={aspect} draw={(s) => <Marks ver={ver} src={s} side={side} view={view} />}
|
|
506
|
+
over={() => (ver.live ? <RectNote card={card} view={view} sides={[side]} /> : null)} />
|
|
448
507
|
)}
|
|
449
508
|
{bar}
|
|
450
509
|
</div>
|
|
@@ -492,33 +551,33 @@ function track(move: (e: PointerEvent) => void): void {
|
|
|
492
551
|
* sits over a frame unclipped (the picked rectangle's note box), given the images that frame shows */
|
|
493
552
|
const Compare = observer(({ c, base, mod, names, aspect, draw, over }: { c: CompareSt; base: string; mod: string | undefined; names?: { base: string; mod: string }; aspect: string; draw: (src: string) => ReactNode; over?: (srcs: string[]) => ReactNode }) => {
|
|
494
553
|
const [peek, setPeek] = useState(false)
|
|
495
|
-
if (mod === undefined) return <
|
|
554
|
+
if (mod === undefined) return <Frame aspect={aspect} caption={null} over={over?.([base])}><div className="rv-fill">{draw(base)}</div></Frame>
|
|
496
555
|
const n = names ?? PAIR_NAMES
|
|
497
556
|
if (c.mode === 'side')
|
|
498
557
|
return (
|
|
499
558
|
<>
|
|
500
|
-
<
|
|
501
|
-
<
|
|
559
|
+
<Frame aspect={aspect} caption={n.base} over={over?.([base])}><div className="rv-fill">{draw(base)}</div></Frame>
|
|
560
|
+
<Frame aspect={aspect} caption={n.mod} modCap over={over?.([mod])}><div className="rv-fill">{draw(mod)}</div></Frame>
|
|
502
561
|
</>
|
|
503
562
|
)
|
|
504
563
|
if (c.mode === 'mod')
|
|
505
564
|
return (
|
|
506
|
-
<
|
|
565
|
+
<Frame aspect={aspect} caption={peek ? n.base : n.mod} modCap={!peek} onPeek={setPeek} over={over?.([peek ? base : mod])}>
|
|
507
566
|
<div className="rv-fill">{draw(peek ? base : mod)}</div>
|
|
508
|
-
</
|
|
567
|
+
</Frame>
|
|
509
568
|
)
|
|
510
569
|
const pct = Math.round(c.split * 100)
|
|
511
570
|
return (
|
|
512
|
-
<
|
|
571
|
+
<Frame aspect={aspect} caption={<>{n.base} {c.mode === 'swipe' ? '◀ ▶' : '+'} <span className="rv-modcap">{n.mod}</span></>} swipe={c.mode === 'swipe' ? c : undefined} over={over?.([base, mod])}>
|
|
513
572
|
<div className="rv-fill" style={c.mode === 'swipe' ? { clipPath: `inset(0 ${100 - pct}% 0 0)` } : undefined}>{draw(base)}</div>
|
|
514
573
|
<div className="rv-fill" style={c.mode === 'swipe' ? { clipPath: `inset(0 0 0 ${pct}%)` } : { opacity: c.opacity }}>{draw(mod)}</div>
|
|
515
574
|
{c.mode === 'swipe' ? <div className="rv-curtain" style={{ left: `${pct}%` }} /> : null}
|
|
516
|
-
</
|
|
575
|
+
</Frame>
|
|
517
576
|
)
|
|
518
577
|
})
|
|
519
578
|
|
|
520
579
|
/** one frame and its caption; the curtain's line follows the pointer; `over` sits on the frame, free of its clip */
|
|
521
|
-
const
|
|
580
|
+
const Frame = ({ aspect, caption, modCap, swipe, onPeek, over, children }: { aspect: string; caption: ReactNode; modCap?: boolean; swipe?: CompareSt | undefined; onPeek?: (on: boolean) => void; over?: ReactNode; children: ReactNode }) => {
|
|
522
581
|
const frame = useRef<HTMLDivElement>(null)
|
|
523
582
|
const down = (e: React.PointerEvent): void => {
|
|
524
583
|
const el = frame.current
|
|
@@ -553,18 +612,20 @@ const clamp01 = (v: number): number => Math.max(0, Math.min(1, v))
|
|
|
553
612
|
/** a drag shorter than this, on either axis, is a click: it picks nothing */
|
|
554
613
|
const MIN_DRAG = 0.01
|
|
555
614
|
|
|
556
|
-
/** one image of view `view` and its rectangles
|
|
557
|
-
*
|
|
558
|
-
|
|
615
|
+
/** one image of view `view` and its rectangles: the ones his answers sent (still), and on the newest version his
|
|
616
|
+
* draft's, a drag drawing one (never in the curtain, whose drag moves the line). A clip view of the newest version that
|
|
617
|
+
* is not the active one loops on its own: a click makes it active */
|
|
618
|
+
const Marks = observer(({ ver, src, side, view }: { ver: Ver; src: string; side: Side | undefined; view: number }) => {
|
|
619
|
+
const { rv, card, cell } = ver
|
|
559
620
|
const el = useRef<HTMLDivElement>(null)
|
|
560
621
|
const [drag, setDrag] = useState<{ x0: number; y0: number; x1: number; y1: number } | null>(null)
|
|
561
622
|
const phone = rv.phone
|
|
562
|
-
const any =
|
|
623
|
+
const any = itemOf(ver).views[view]
|
|
563
624
|
const shown = any && !isGallery(any) ? any : undefined
|
|
564
625
|
const clip = shown?.clip
|
|
565
|
-
const active =
|
|
566
|
-
const drawing = phone.on ? phone.draw && (side === undefined || phone.pair !== 'swipe' || rv.compare.mode !== 'swipe') : side === undefined || rv.compare.mode !== 'swipe'
|
|
567
|
-
const c =
|
|
626
|
+
const active = card.view === view
|
|
627
|
+
const drawing = ver.live && (phone.on ? phone.draw && (side === undefined || phone.pair !== 'swipe' || rv.compare.mode !== 'swipe') : side === undefined || rv.compare.mode !== 'swipe')
|
|
628
|
+
const c = clip ? card.clipOf(cell.id, view) : null
|
|
568
629
|
const at = (e: { clientX: number; clientY: number }): { x: number; y: number } => {
|
|
569
630
|
const b = el.current?.getBoundingClientRect()
|
|
570
631
|
if (!b) return { x: 0, y: 0 }
|
|
@@ -572,16 +633,16 @@ const Marks = observer(({ rv, src, side, view }: { rv: ReviewSt; src: string; si
|
|
|
572
633
|
}
|
|
573
634
|
const down = (e: React.PointerEvent): void => {
|
|
574
635
|
if (e.button !== 0) return
|
|
575
|
-
if (clip && !active) {
|
|
636
|
+
if (clip && ver.live && !active) {
|
|
576
637
|
e.preventDefault()
|
|
577
|
-
|
|
638
|
+
card.setView(view)
|
|
578
639
|
return
|
|
579
640
|
}
|
|
580
641
|
if (!drawing) return
|
|
581
642
|
e.preventDefault()
|
|
582
643
|
e.stopPropagation()
|
|
583
644
|
// he draws on the paused frame: the rectangle keeps its time
|
|
584
|
-
if (
|
|
645
|
+
if (c && !c.paused) c.pause()
|
|
585
646
|
const a = at(e)
|
|
586
647
|
let cur = { x0: a.x, y0: a.y, x1: a.x, y1: a.y }
|
|
587
648
|
setDrag(cur)
|
|
@@ -596,23 +657,25 @@ const Marks = observer(({ rv, src, side, view }: { rv: ReviewSt; src: string; si
|
|
|
596
657
|
window.removeEventListener('pointercancel', up)
|
|
597
658
|
setDrag(null)
|
|
598
659
|
const r = box(cur)
|
|
599
|
-
if (r.w > MIN_DRAG && r.h > MIN_DRAG)
|
|
600
|
-
else
|
|
660
|
+
if (r.w > MIN_DRAG && r.h > MIN_DRAG) card.addRect(r, side, view)
|
|
661
|
+
else card.pickRect(null)
|
|
601
662
|
}
|
|
602
663
|
window.addEventListener('pointermove', move)
|
|
603
664
|
window.addEventListener('pointerup', up)
|
|
604
665
|
window.addEventListener('pointercancel', up)
|
|
605
666
|
}
|
|
606
|
-
const rects =
|
|
607
|
-
const
|
|
667
|
+
const rects = ver.live ? card.draft.rects.map((r, i) => [r, i] as const).filter(([r]) => r.side === side && (r.view ?? 0) === view) : []
|
|
668
|
+
const sent = card.sentRects(cell.id, view, side)
|
|
669
|
+
const onIts = (r: Rect): boolean => !clip || !c || r.t === undefined || (c.paused && onFrame(r.t, c.time, clip.fps))
|
|
608
670
|
const rings = rv.marksOn ? (shown?.marks ?? []).filter((m) => m.side === side) : []
|
|
609
|
-
const live = drawing || (clip !== undefined && !active)
|
|
671
|
+
const live = drawing || (clip !== undefined && ver.live && !active)
|
|
610
672
|
return (
|
|
611
|
-
<div ref={el} className={`rv-marks${clip && !active ? ' pick' : drawing ? ' draw' : ''}`} onPointerDown={down} style={{ pointerEvents: live ? 'auto' : 'none', touchAction: drawing ? 'none' : undefined }}>
|
|
612
|
-
{
|
|
673
|
+
<div ref={el} className={`rv-marks${clip && ver.live && !active ? ' pick' : drawing ? ' draw' : ''}`} onPointerDown={down} style={{ pointerEvents: live ? 'auto' : 'none', touchAction: drawing ? 'none' : undefined }}>
|
|
674
|
+
{c ? <ClipVideo key={src} clip={c} src={src} poster={shown?.clip ? rv.fitUrl(cell.id, shown.clip.poster) : undefined} preload={ver.live ? 'auto' : 'none'} /> : <img src={src} alt="" draggable={false} className="rv-markimg" loading="lazy" decoding="async" />}
|
|
613
675
|
{shown && rings.length > 0 ? <Rings marks={rings} w={shown.size.w} h={shown.size.h} /> : null}
|
|
676
|
+
{sent.map(({ r, n }, k) => <div key={`s${k}`} className={`rv-rect sent${onIts(r) ? '' : ' faint'}`} style={pct(r)} title={r.comment || `rectangle ${n}`}><span className="rv-rectn">{n}</span></div>)}
|
|
614
677
|
{rects.map(([r, i]) => (
|
|
615
|
-
<RectMark key={i} r={r} n={i + 1} on={
|
|
678
|
+
<RectMark key={i} r={r} n={i + 1} on={card.rect === i} faint={!onIts(r)} at={clip && r.t !== undefined ? secs(r.t) : undefined} pick={() => card.pickRect(i, true)} />
|
|
616
679
|
))}
|
|
617
680
|
{drag ? <div className="rv-drag" style={pct(box(drag))} /> : null}
|
|
618
681
|
</div>
|
|
@@ -631,28 +694,34 @@ const Rings = ({ marks, w, h }: { marks: readonly ReviewMark[]; w: number; h: nu
|
|
|
631
694
|
</svg>
|
|
632
695
|
)
|
|
633
696
|
|
|
634
|
-
/** a rectangle of his; on a clip, faint and dashed away from its frame, its time on its number */
|
|
697
|
+
/** a rectangle of his draft; on a clip, faint and dashed away from its frame, its time on its number */
|
|
635
698
|
const RectMark = ({ r, n, on, faint, at, pick }: { r: Rect; n: number; on: boolean; faint: boolean; at: string | undefined; pick: () => void }) => (
|
|
636
|
-
<div className={`rv-rect${on ? ' on' : ''}${faint ? ' faint' : ''}`} style={pct(r)} title={r.comment || `rectangle ${n}`}
|
|
699
|
+
<div className={`rv-rect${on ? ' on' : ''}${faint ? ' faint' : ''}`} style={{ ...pct(r), pointerEvents: 'auto' }} title={r.comment || `rectangle ${n}`}
|
|
637
700
|
onPointerDown={(e) => { e.stopPropagation(); pick() }} onMouseDown={keepFocus}>
|
|
638
|
-
<span className="rv-rectn">{n}{at ? ` · ${at}` : ''}</span>
|
|
701
|
+
<span className="rv-rectn">{n}{at ? ` · ${at}` : ''}{!on && r.comment.trim() ? <span className="rv-rectword">{firstWords(r.comment)}</span> : null}</span>
|
|
639
702
|
</div>
|
|
640
703
|
)
|
|
641
704
|
|
|
705
|
+
/** the first words of a note, on its rectangle when its box is shut */
|
|
706
|
+
const firstWords = (s: string): string => {
|
|
707
|
+
const w = s.trim().split(/\s+/)
|
|
708
|
+
return w.length > 5 ? `${w.slice(0, 5).join(' ')}…` : w.join(' ')
|
|
709
|
+
}
|
|
710
|
+
|
|
642
711
|
/** the picked rectangle's note box, beside it on the image: under it, or over it when it sits low, focused once drawn
|
|
643
712
|
* or clicked. Enter or Escape closes it (the rectangle stays), Shift Enter is a new line; `sides` are the sides the
|
|
644
713
|
* frame shows */
|
|
645
|
-
const RectNote = observer(({
|
|
714
|
+
const RectNote = observer(({ card, view, sides }: { card: ThreadSt; view: number; sides: readonly (Side | undefined)[] }) => {
|
|
646
715
|
const box = useRef<HTMLTextAreaElement | null>(null)
|
|
647
|
-
const i =
|
|
648
|
-
const r = i === null ? undefined :
|
|
716
|
+
const i = card.rect
|
|
717
|
+
const r = i === null ? undefined : card.draft.rects[i]
|
|
649
718
|
const here = i !== null && r !== undefined && (r.view ?? 0) === view && sides.includes(r.side)
|
|
650
|
-
const focus = here &&
|
|
719
|
+
const focus = here && card.noteFocus === i
|
|
651
720
|
useEffect(() => {
|
|
652
721
|
if (!focus || box.current === null) return
|
|
653
722
|
box.current.focus()
|
|
654
|
-
|
|
655
|
-
}, [focus,
|
|
723
|
+
card.noteFocused()
|
|
724
|
+
}, [focus, card])
|
|
656
725
|
if (!here) return null
|
|
657
726
|
const below = r.y + r.h <= NOTE_LOW || r.y < 1 - NOTE_LOW
|
|
658
727
|
const place = below ? { top: `${(r.y + r.h) * 100}%` } : { bottom: `${(1 - r.y) * 100}%` }
|
|
@@ -660,14 +729,14 @@ const RectNote = observer(({ rv, view, sides }: { rv: ReviewSt; view: number; si
|
|
|
660
729
|
<div className={`rv-note${below ? ' below' : ' above'}`} style={{ ...place, ['--nx' as string]: `${r.x * 100}%` }} onPointerDown={(e) => e.stopPropagation()}>
|
|
661
730
|
<span className="rv-noten">{i + 1}{r.t !== undefined ? ` · ${secs(r.t)}` : ''}</span>
|
|
662
731
|
<AutoText el={(t) => (box.current = t)} placeholder="what is wrong here · Enter closes" value={r.comment}
|
|
663
|
-
onText={(t) =>
|
|
732
|
+
onText={(t) => card.setRectComment(i, t)}
|
|
664
733
|
onKeyDown={(e) => {
|
|
665
734
|
if ((e.key === 'Enter' && !e.shiftKey && !e.nativeEvent.isComposing) || e.key === 'Escape') {
|
|
666
735
|
e.preventDefault()
|
|
667
|
-
|
|
736
|
+
card.pickRect(null)
|
|
668
737
|
}
|
|
669
738
|
}} />
|
|
670
|
-
<button className="ghost rv-x" title="delete this rectangle" aria-label="delete this rectangle" onMouseDown={keepFocus} onClick={() =>
|
|
739
|
+
<button className="ghost rv-x" title="delete this rectangle" aria-label="delete this rectangle" onMouseDown={keepFocus} onClick={() => card.removeRect(i)}>✕</button>
|
|
671
740
|
</div>
|
|
672
741
|
)
|
|
673
742
|
})
|
|
@@ -676,16 +745,16 @@ const NOTE_LOW = 0.78
|
|
|
676
745
|
|
|
677
746
|
// ── a clip ──
|
|
678
747
|
|
|
679
|
-
/** one video of
|
|
680
|
-
*
|
|
681
|
-
const ClipVideo = ({ clip, src, poster, loop = true }: { clip: ClipSt; src: string; poster?: string; loop?: boolean }) => {
|
|
748
|
+
/** one video of a view, driven by the view's one clock; muted until the sound button, inline; looping, or at its end
|
|
749
|
+
* waiting at the start. An older version's clip loads nothing until it plays */
|
|
750
|
+
const ClipVideo = ({ clip, src, poster, loop = true, preload = 'auto' }: { clip: ClipSt; src: string; poster?: string | undefined; loop?: boolean; preload?: 'auto' | 'none' }) => {
|
|
682
751
|
const ref = useRef<HTMLVideoElement>(null)
|
|
683
752
|
useEffect(() => {
|
|
684
753
|
const el = ref.current
|
|
685
754
|
if (!el) return
|
|
686
755
|
return clip.attach(el)
|
|
687
756
|
}, [clip, src])
|
|
688
|
-
return <video ref={ref} className="rv-video" src={src} poster={poster} muted loop={loop} playsInline preload=
|
|
757
|
+
return <video ref={ref} className="rv-video" src={src} poster={poster} muted loop={loop} playsInline preload={preload} onEnded={loop ? undefined : () => clip.seek(0)} />
|
|
689
758
|
}
|
|
690
759
|
|
|
691
760
|
/** the sound button and the volume: a volume moved turns the sound on */
|