Repository URL to install this package:
|
Version:
2.1.0 ▾
|
import React from 'react'
import { observer } from 'xmobx/mobx-react'
import { EMPTY_OBJ, fromIshToString } from 'exotic'
import { Empty } from '@skava/ui/dist/components/atoms/Empty'
import { styledMaterialIcon } from '@skava/ui/dist/components/atoms/MaterialIcon'
import { wording } from '@skava/ui/dist/words'
import { VideoPresetControlProps } from './typings'
import {
VideoTitle,
VideoSlogan,
VideoWidgetLogo,
VideoShareWrap,
VideoShareText,
VideoTimerWrap,
VideoTimerText,
PlayButton,
VideoLogoPanel,
} from './styled'
const LargeWhiteIcon = styledMaterialIcon(48, 'white')
const LargeLiteIcon = styledMaterialIcon(48, 'white', 0.7)
const SmallLiteIcon = styledMaterialIcon(24, 'white', 0.7)
/**
* @todo !!! NEEDS A PAUSE ICON, OR MORPH THE PLAY ICON INTO PAUSE
* @todo later - this is the actual controls, the other is VideoFlare
*/
class ActualVideoControls extends React.PureComponent<VideoPresetControlProps> {
render() {
const { state } = this.props
const handleClick = state.toggleIsPlaying
const icon = <LargeLiteIcon type="play" />
return <PlayButton children={icon} onClick={handleClick} aria-label={wording.playButton} />
}
}
@observer
class VideoControls extends React.Component<VideoPresetControlProps> {
static defaultProps = {
state: EMPTY_OBJ,
}
render() {
const { state, title, slogan, shareTitle, videoLength } = this.props
const validTitle = fromIshToString(title)
const validSlogan = fromIshToString(slogan)
const validShareTitle = fromIshToString(shareTitle)
const validVideoLength = fromIshToString(videoLength)
const videoInfoView = () => {
return state.shouldShowVideoInformation ? (
<React.Fragment>
<VideoLogoPanel>
<VideoWidgetLogo />
<VideoTitle>{validTitle}</VideoTitle>
<VideoSlogan>{validSlogan}</VideoSlogan>
</VideoLogoPanel>
<VideoShareWrap>
<VideoShareText>{validShareTitle}</VideoShareText>
<LargeWhiteIcon type="share" />
</VideoShareWrap>
<VideoTimerWrap>
<SmallLiteIcon type="play" />
<VideoTimerText>{validVideoLength}</VideoTimerText>
</VideoTimerWrap>
{/* @todo these have some actions... */}
{/* <QuestionButtonIcon /> */}
</React.Fragment>
) : <Empty />
}
const playButtonView = () => {
return state.hasPlayButton ?
(<ActualVideoControls state={state} />)
: <Empty />
}
if (state.isPlaying) {
return <Empty />
}
return (
<React.Fragment>
{playButtonView()}
{videoInfoView()}
</React.Fragment>
)
}
}
export { ActualVideoControls, VideoControls }
export default VideoControls