@@ -2,17 +2,18 @@ import * as React from 'react'
22import { PieceGeneric } from '@sofie-automation/corelib/dist/dataModel/Piece'
33import { SplitsContent , SourceLayerType } from '@sofie-automation/blueprints-integration'
44import { RundownUtils } from '../../../../lib/rundown'
5- import classNames from 'classnames'
65import { ReadonlyDeep } from 'type-fest'
76
87type SplitIconPieceType = ReadonlyDeep < Omit < PieceGeneric , 'timelineObjectsString' > >
98
10- export default class SplitInputIcon extends React . Component < {
9+ interface SplitInputIconProps {
1110 abbreviation : string | undefined
1211 piece : SplitIconPieceType | undefined
1312 hideLabel ?: boolean
14- } > {
15- private getCameraLabel ( piece : SplitIconPieceType | undefined ) {
13+ }
14+
15+ export default function SplitInputIcon ( { abbreviation, piece, hideLabel } : Readonly < SplitInputIconProps > ) : JSX . Element {
16+ function getCameraLabel ( ) {
1617 if ( piece && piece . content ) {
1718 const c = piece . content as SplitsContent
1819 const camera = c . boxSourceConfiguration . find ( ( i ) => i . type === SourceLayerType . CAMERA )
@@ -21,18 +22,15 @@ export default class SplitInputIcon extends React.Component<{
2122 return (
2223 < React . Fragment >
2324 { label && label [ 1 ] ? label [ 1 ] . substr ( 0 , 1 ) . toUpperCase ( ) + ' ' : '' }
24- < span className = "camera" > { label ? label [ 2 ] : '' } </ span >
25+ < span > { label ? label [ 2 ] : '' } </ span >
2526 </ React . Fragment >
2627 )
27- } else {
28- return this . props . abbreviation !== undefined ? this . props . abbreviation : 'Spl'
2928 }
30- } else {
31- return this . props . abbreviation !== undefined ? this . props . abbreviation : 'Spl'
3229 }
30+ return abbreviation !== undefined ? abbreviation : 'Spl'
3331 }
3432
35- private getLeftSourceType ( piece : SplitIconPieceType | undefined ) : string {
33+ function getLeftSourceType ( ) : string {
3634 if ( piece && piece . content ) {
3735 const c = piece . content as SplitsContent
3836 const left = ( c . boxSourceConfiguration && c . boxSourceConfiguration [ 0 ] ) ?. type || SourceLayerType . CAMERA
@@ -41,28 +39,23 @@ export default class SplitInputIcon extends React.Component<{
4139 return 'camera'
4240 }
4341
44- private getRightSourceType ( piece : SplitIconPieceType | undefined ) : string {
42+ function getRightSourceType ( ) : string {
4543 if ( piece && piece . content ) {
4644 const c = piece . content as SplitsContent
4745 const right = ( c . boxSourceConfiguration && c . boxSourceConfiguration [ 1 ] ) ?. type || SourceLayerType . REMOTE
4846 const sourceType = RundownUtils . getSourceLayerClassName ( right )
49- return sourceType + ( this . getLeftSourceType ( piece ) === sourceType ? ' second' : '' )
47+ return sourceType + ( getLeftSourceType ( ) === sourceType ? ' second' : '' )
5048 }
5149 return 'remote'
5250 }
5351
54- render ( ) : JSX . Element {
55- return (
56- < div className = "clock-view-piece-icon" >
57- < rect width = "126.5" height = "44.5" className = { classNames ( 'upper' , this . getLeftSourceType ( this . props . piece ) ) } />
58- < rect
59- width = "126.5"
60- height = "44.5"
61- y = "44.5"
62- className = { classNames ( 'lower' , this . getRightSourceType ( this . props . piece ) ) }
63- />
64- { ! this . props . hideLabel && < span className = "piece-icon-text" > { this . getCameraLabel ( this . props . piece ) } </ span > }
52+ return (
53+ < div className = "clock-view-piece-icon" >
54+ < div className = "split-view" >
55+ < div className = { getLeftSourceType ( ) } > </ div >
56+ < div className = { getRightSourceType ( ) } > </ div >
6557 </ div >
66- )
67- }
58+ { ! hideLabel && < span className = "piece-icon-text" > { getCameraLabel ( ) } </ span > }
59+ </ div >
60+ )
6861}
0 commit comments