Skip to content

Commit 39dcb81

Browse files
committed
chore: cleanup previews data structure
1 parent 45f9dac commit 39dcb81

File tree

14 files changed

+208
-129
lines changed

14 files changed

+208
-129
lines changed

packages/blueprints-integration/src/content.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { JSONBlob } from '@sofie-automation/shared-lib/dist/lib/JSONBlob'
22
import { Time } from './common'
33
import { TSR, TimelineObjectCoreExt } from './timeline'
44
import { SourceLayerType } from '@sofie-automation/shared-lib/dist/core/model/ShowStyle'
5-
import { Previews } from './previews'
5+
import { PopupPreview } from './previews'
66

77
export type WithTimeline<T extends BaseContent> = T & {
88
timelineObjects: TimelineObjectCoreExt<TSR.TSRTimelineContent>[]
@@ -21,9 +21,10 @@ export interface BaseContent {
2121
ignoreFreezeFrame?: boolean
2222
ignoreAudioFormat?: boolean
2323

24-
popUpPreview?: Previews
25-
// note - should we allow multiple previews?
26-
// note - what properties can be removed from the main content object now?
24+
/**
25+
* Overwrite any default hover previews in Sofie
26+
*/
27+
popUpPreview?: PopupPreview
2728
}
2829

2930
// eslint-disable-next-line @typescript-eslint/no-empty-interface
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
import { SplitsContentBoxContent, SplitsContentBoxProperties } from './content'
12
import { NoteSeverity } from './lib'
3+
import { ITranslatableMessage } from './translations'
24

3-
export type Previews =
4-
| InvalidPreview
5-
| TablePreview
6-
| ScriptPreview
7-
| HTMLPreview
8-
| SplitPreview
9-
| VTPreview
10-
| BlueprintImagePreview
5+
export interface PopupPreview<P extends Previews = Previews> {
6+
name?: string
7+
preview?: P
8+
warnings?: InvalidPreview[]
9+
}
10+
export type Previews = TablePreview | ScriptPreview | HTMLPreview | SplitPreview | VTPreview | BlueprintImagePreview
1111

1212
export enum PreviewType {
1313
Invalid = 'invalid',
@@ -24,18 +24,14 @@ interface PreviewBase {
2424
}
2525

2626
export interface InvalidPreview extends PreviewBase {
27-
// todo - is this required or would we just pull this from the piece warning anyway
2827
type: PreviewType.Invalid
2928

3029
severity: NoteSeverity
31-
reason: string // todo - translate
30+
reason: ITranslatableMessage
3231
}
3332
export interface TablePreview extends PreviewBase {
34-
// todo - translations
3533
type: PreviewType.Table
3634

37-
heading: string
38-
subheading?: string
3935
entries: { key: string; value: string }[]
4036
}
4137
export interface ScriptPreview extends PreviewBase {
@@ -47,31 +43,35 @@ export interface ScriptPreview extends PreviewBase {
4743
lastModified?: number
4844
}
4945
export interface HTMLPreview extends PreviewBase {
50-
// todo - steps and how to control them
46+
// todo - expose if and how steps can be controlled
5147
type: PreviewType.HTML
5248

53-
previewUrl: string
49+
name?: string
5450

51+
previewUrl: string
5552
previewDimension?: { width: number; height: number }
56-
hasSteps?: boolean
5753

5854
postMessageOnLoad?: any
55+
56+
steps?: { current: number; total: number }
5957
}
6058
export interface SplitPreview extends PreviewBase {
6159
type: PreviewType.Split
6260

6361
background?: string // file asset upload?
64-
boxes: any // todo
62+
boxes: (SplitsContentBoxContent & SplitsContentBoxProperties)[]
6563
}
6664
export interface VTPreview extends PreviewBase {
6765
type: PreviewType.VT
6866

6967
// note: the info required for the preview follows from package manager so there's nothing for blueprins here
7068
// note: if we want to allow a preview for different media than saved on the piece (because perhaps the media is in a non-primary piece) should we allow to specifiy the package to preview?
71-
// todo - turn this into a "PackagePreview"?
69+
70+
inWords?: string // note - only displayed if outWords are present
71+
outWords?: string
7272
}
7373
export interface BlueprintImagePreview extends PreviewBase {
7474
type: PreviewType.BlueprintImage
7575

76-
image?: string // to be put in as asset
76+
image: string // to be put in as asset
7777
}

packages/webui/src/client/lib/VideoPreviewPlayer.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function setVideoElementPosition(
1414
if (loop && vEl.duration > 0) {
1515
targetTime =
1616
targetTime % ((itemDuration > 0 ? Math.min(vEl.duration * 1000, itemDuration) : vEl.duration * 1000) * 1000)
17-
} else {
17+
} else if (itemDuration > 0) {
1818
targetTime = Math.min(timePosition, itemDuration)
1919
}
2020
vEl.currentTime = targetTime / 1000
@@ -55,7 +55,7 @@ export function VideoPreviewPlayer({
5555
<div
5656
className={classNames('video-preview-player__frame-marker', {
5757
'video-preview-player__frame-marker--first-frame': offsetTimePosition === 0,
58-
'video-preview-player__frame-marker--last-frame': offsetTimePosition >= itemDuration,
58+
'video-preview-player__frame-marker--last-frame': itemDuration > 0 && offsetTimePosition >= itemDuration,
5959
})}
6060
>
6161
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">

packages/webui/src/client/ui/PreviewPopUp/PreviewPopUp.scss

-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@
158158
font-weight: 200;
159159
font-size: 0.8em;
160160
letter-spacing: 0em;
161-
line-height: 80%;
162161
max-width: 60vw;
163162
overflow: hidden;
164163
text-overflow: ellipsis;

packages/webui/src/client/ui/PreviewPopUp/PreviewPopUpContent.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ export function PreviewPopUpContent({ content, time }: PreviewPopUpContentProps)
4444
<div className="preview-popUp__table">
4545
<table>
4646
<tbody>
47-
{Object.entries(content.content).map(([key, entry]) => (
47+
{content.content.map(({ key, value }) => (
4848
<tr>
4949
<td className="preview-popup__label">{key}</td>
50-
<td className="preview-popup__value">{entry}</td>
50+
<td className="preview-popup__value">{value}</td>
5151
</tr>
5252
))}
5353
</tbody>

0 commit comments

Comments
 (0)