Skip to content

Commit 55a627a

Browse files
committed
chore: use global component on the presenter and prompter screens
1 parent 306a1f4 commit 55a627a

8 files changed

Lines changed: 61 additions & 71 deletions

File tree

packages/webui/src/client/lib/Components/OverUnderChip.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@import '../../styles/colorScheme';
22

33
.over-under-chip {
4+
font-family: Roboto Flex;
45
display: inline-block;
56
border-radius: 999px;
67
white-space: nowrap;
@@ -12,7 +13,6 @@
1213
margin-left: var(--overUnderChipMarginLeft, 0em);
1314
margin-top: var(--overUnderChipMarginTop, 0em);
1415
line-height: var(--overUnderChipLineHeight, 1);
15-
font-size: 1em;
1616

1717
font-variation-settings:
1818
'wdth' var(--overUnderChipWdth, 25),
@@ -39,4 +39,3 @@
3939
background-color: #ff0; // Should probably be changed to $general-fast-color;
4040
}
4141
}
42-

packages/webui/src/client/lib/Components/OverUnderChip.tsx

Lines changed: 53 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,66 @@ import React, { type CSSProperties } from 'react'
22
import classNames from 'classnames'
33
import { RundownUtils } from '../rundown.js'
44
import './OverUnderChip.scss'
5+
import { useTiming } from '../../ui/RundownView/RundownTiming/withTiming.js'
6+
import { getPlaylistTimingDiff } from '../rundownTiming.js'
7+
import { DBRundownPlaylist } from '@sofie-automation/corelib/src/dataModel/RundownPlaylist/RundownPlaylist.js'
58

6-
export type OverUnderChipFormat = 'playlistDiff' | 'timerPostfix'
9+
export type OverUnderChipFormat = 'playlistDiff' | 'timerPostfix' | 'screenOverlay'
710

8-
export interface IOverUnderChipProps {
9-
valueMs: number
10-
format?: OverUnderChipFormat
11+
type OverUnderChipBaseProps = {
1112
className?: string
1213
style?: CSSProperties
14+
format?: OverUnderChipFormat
1315
}
1416

15-
export function OverUnderChip({
16-
valueMs,
17-
format = 'playlistDiff',
18-
className,
19-
style,
20-
}: Readonly<IOverUnderChipProps>): JSX.Element {
17+
type OverUnderChipValueProps =
18+
| {
19+
valueMs: number | undefined
20+
rundownPlaylist?: never
21+
}
22+
| {
23+
valueMs?: never
24+
rundownPlaylist: DBRundownPlaylist
25+
}
26+
27+
type OverUnderChipInnerProps = OverUnderChipBaseProps & { valueMs: number | undefined }
28+
29+
/**
30+
* Over/under "chip" display.
31+
* Can either take a direct `valueMs` or a `rundownPlaylist` (requires RundownTiming context).
32+
*/
33+
export function OverUnderChip(props: Readonly<OverUnderChipBaseProps & OverUnderChipValueProps>): JSX.Element | null {
34+
if ('valueMs' in props) {
35+
return <OverUnderChipInner {...props} valueMs={props.valueMs} />
36+
} else {
37+
return <OverUnderChipFromPlaylist {...props} rundownPlaylist={props.rundownPlaylist} />
38+
}
39+
}
40+
41+
function OverUnderChipFromPlaylist(
42+
props: Readonly<OverUnderChipBaseProps & { rundownPlaylist: DBRundownPlaylist }>
43+
): JSX.Element | null {
44+
const timingDurations = useTiming()
45+
const valueMs = getPlaylistTimingDiff(props.rundownPlaylist, timingDurations) ?? 0
46+
return <OverUnderChipInner {...props} valueMs={valueMs} />
47+
}
48+
49+
function OverUnderChipInner({ valueMs, format = 'playlistDiff', className, style }: Readonly<OverUnderChipInnerProps>) {
50+
if (valueMs === undefined) return null
51+
2152
const isUnder = valueMs <= 0
22-
const timeStr =
23-
format === 'timerPostfix'
24-
? RundownUtils.formatDiffToTimecode(Math.abs(valueMs), false, false, true, false, true)
25-
: RundownUtils.formatDiffToTimecode(Math.abs(valueMs), false, false, true, true, true)
53+
const timeStr = (() => {
54+
switch (format) {
55+
case 'timerPostfix':
56+
return RundownUtils.formatDiffToTimecode(Math.abs(valueMs), false, false, true, false, true)
57+
case 'screenOverlay':
58+
// Match legacy `OverUnderTimer` formatting used by prompter/presenter/director overlays
59+
return RundownUtils.formatDiffToTimecode(Math.abs(valueMs), false, true, true, false, true)
60+
case 'playlistDiff':
61+
default:
62+
return RundownUtils.formatDiffToTimecode(Math.abs(valueMs), false, false, true, true, true)
63+
}
64+
})()
2665

2766
return (
2867
<span

packages/webui/src/client/styles/countdown/director.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ $hold-status-color: $liveline-timecode-color;
2121
// Ensure it layers above the fixed top bar.
2222
.screen-timing-clock {
2323
z-index: 2000;
24-
font-size: 9.8vmin;
24+
font-size: 9vmin;
2525
--overUnderChipPaddingY: 0em;
2626
--overUnderChipPaddingX: 0.2em;
2727
}

packages/webui/src/client/styles/countdown/presenter.scss

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,11 @@ $hold-status-color: $liveline-timecode-color;
3030
.screen-timing-clock {
3131
position: fixed;
3232
left: auto;
33-
font-size: 9.8vmin;
33+
font-size: 9vmin;
3434

3535
z-index: 2000;
3636

37-
padding: 0 0.3em;
38-
border-radius: 1em;
3937
box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.5);
40-
41-
margin: 0;
4238
}
4339

4440
.presenter-screen__part {

packages/webui/src/client/styles/prompter.scss

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -288,37 +288,11 @@ body.prompter-scrollbar {
288288
}
289289

290290
.screen-timing-clock {
291-
font-family: Roboto Flex;
292291
position: fixed;
293292
display: block;
294293
top: 0;
295294
right: 0;
296-
left: auto;
297-
font-size: 9.8vmin;
298-
padding: 0.05em 0.3em;
299-
border-radius: 1em;
300-
box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.5);
301-
line-height: 1;
302-
margin: 0;
303-
304-
&.heavy-light {
305-
font-weight: 600;
306-
307-
&.light {
308-
// color: $general-late-color;
309-
background-color: #ffe900;
310-
color: #000;
311-
}
312-
313-
&.heavy {
314-
color: black;
315-
text-shadow:
316-
0.02em 1px 0px #000,
317-
0.02em -1px 0px #000,
318-
-0.02em -1px 0px #000,
319-
-0.02em 1px 0px #000;
320-
}
321-
}
295+
font-size: 9vmin;
322296
}
323297

324298
.prompter-rundown-status-bar {

packages/webui/src/client/ui/ClockView/DirectorScreen/DirectorScreenTop.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { getCurrentTime } from '../../../lib/systemTime.js'
1010
import { useTranslation } from 'react-i18next'
1111
import { PlaylistTiming } from '@sofie-automation/corelib/dist/playout/rundownTiming'
1212
import { PartInstance } from '@sofie-automation/corelib/src/dataModel/PartInstance'
13-
import { OverUnderTimer } from '../../Prompter/OverUnderTimer.js'
1413
import { OverUnderChip } from '../../../lib/Components/OverUnderChip.js'
1514

1615
export interface DirectorScreenTopProps {

packages/webui/src/client/ui/ClockView/PresenterScreen.tsx

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ import { RundownStatusBar } from './RundownStatusBar.js'
5555
import { UIShowStyleBase } from '@sofie-automation/corelib/src/dataModel/ShowStyleBase.js'
5656
import { UIStudio } from '@sofie-automation/corelib/src/dataModel/Studio.js'
5757
import { PartInstance } from '@sofie-automation/corelib/src/dataModel/PartInstance.js'
58-
import { OverUnderTimer } from '../Prompter/OverUnderTimer.js'
58+
import { OverUnderChip } from '../../lib/Components/OverUnderChip.js'
5959

6060
// TODO: We have another definition of this in the Director screen, and there is also another SegmentUI type. We should look into clearing this up.
6161
interface SegmentUi extends DBSegment {
@@ -509,18 +509,8 @@ function PresenterScreenContentDefaultLayout({
509509
nextPartInstance,
510510
nextSegment,
511511
rundownIds,
512-
margin,
513-
fontSize,
514512
}: Readonly<PresenterScreenProps & PresenterScreenTrackedProps & { timingDurations: RundownTimingContext }>) {
515513
if (playlist && playlistId && segments) {
516-
const overUnderStyle: CSSProperties = {
517-
marginTop: margin ? `${margin}vh` : undefined,
518-
marginBottom: margin ? `${margin}vh` : undefined,
519-
marginRight: margin ? `${margin}vw` : undefined,
520-
marginLeft: margin ? `${margin}vw` : undefined,
521-
fontSize: (fontSize ?? 0) > 12 ? `12vmin` : undefined,
522-
}
523-
524514
const currentPartOrSegmentCountdown =
525515
timingDurations.remainingBudgetOnCurrentSegment ?? timingDurations.remainingTimeOnCurrentPart ?? 0
526516

@@ -529,11 +519,7 @@ function PresenterScreenContentDefaultLayout({
529519
return (
530520
<div className="presenter-screen">
531521
<div className="presenter-screen__part presenter-screen__part--current-part">
532-
<OverUnderTimer
533-
rundownPlaylist={playlist}
534-
className="screen-timing-clock heavy-light heavy"
535-
style={overUnderStyle}
536-
/>
522+
<OverUnderChip className="screen-timing-clock" rundownPlaylist={playlist} />
537523
<div
538524
className={ClassNames('presenter-screen__segment-name', {
539525
live: currentSegment !== undefined,

packages/webui/src/client/ui/Prompter/PrompterView.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import { MeteorCall } from '../../lib/meteorApi.js'
3838
import { MdDisplay } from './Formatted/MdDisplay.js'
3939
import { UIStudio } from '@sofie-automation/corelib/src/dataModel/Studio.js'
4040
import { OverUnderTimer } from './OverUnderTimer.js'
41+
import { OverUnderChip } from '../../lib/Components/OverUnderChip.js'
4142

4243
const DEFAULT_UPDATE_THROTTLE = 250 //ms
4344
const PIECE_MISSING_UPDATE_THROTTLE = 2000 //ms
@@ -613,11 +614,7 @@ export class PrompterViewContent extends React.Component<Translated<IProps & ITr
613614
allowTestingAdlibsToPersist={this.props.studio?.settings.allowTestingAdlibsToPersist ?? false}
614615
>
615616
{this.configOptions.showOverUnder && (
616-
<OverUnderTimer
617-
rundownPlaylist={this.props.rundownPlaylist}
618-
className="screen-timing-clock heavy-light heavy"
619-
style={overUnderStyle}
620-
/>
617+
<OverUnderChip className="screen-timing-clock" rundownPlaylist={this.props.rundownPlaylist} />
621618
)}
622619
</Prompter>
623620
<RundownStatusBar

0 commit comments

Comments
 (0)