// tslint:disable:react-a11y-anchors import React from 'react'; import classNames from 'classnames'; import is from '@sindresorhus/is'; import * as GoogleChrome from '../util/GoogleChrome'; import * as MIME from '../types/MIME'; import { formatDuration } from '../util/formatDuration'; import { LocalizerType } from '../types/Util'; const Colors = { ICON_SECONDARY: '#b9b9b9', }; const colorSVG = (url: string, color: string) => { return { WebkitMask: `url(${url}) no-repeat center`, WebkitMaskSize: '100%', backgroundColor: color, }; }; export interface Props { close: () => void; contentType: MIME.MIMEType | undefined; i18n: LocalizerType; objectURL: string; caption?: string; isViewOnce: boolean; onNext?: () => void; onPrevious?: () => void; onSave?: () => void; } interface State { videoTime?: number; } const CONTROLS_WIDTH = 50; const CONTROLS_SPACING = 10; const styles = { container: { display: 'flex', flexDirection: 'column', position: 'absolute', left: 0, right: 0, top: 0, bottom: 0, backgroundColor: 'rgba(0, 0, 0, 0.9)', } as React.CSSProperties, mainContainer: { display: 'flex', flexDirection: 'row', flexGrow: 1, paddingTop: 40, paddingLeft: 40, paddingRight: 40, paddingBottom: 0, // To ensure that a large image doesn't overflow the flex layout minHeight: '50px', outline: 'none', } as React.CSSProperties, objectContainer: { position: 'relative', flexGrow: 1, display: 'inline-flex', justifyContent: 'center', } as React.CSSProperties, object: { flexGrow: 1, flexShrink: 0, maxWidth: '100%', maxHeight: '100%', objectFit: 'contain', outline: 'none', } as React.CSSProperties, caption: { position: 'absolute', bottom: 0, left: 0, right: 0, textAlign: 'center', color: 'white', padding: '1em', paddingLeft: '3em', paddingRight: '3em', backgroundColor: 'rgba(192, 192, 192, .20)', } as React.CSSProperties, controlsOffsetPlaceholder: { width: CONTROLS_WIDTH, marginRight: CONTROLS_SPACING, flexShrink: 0, }, controls: { width: CONTROLS_WIDTH, flexShrink: 0, display: 'flex', flexDirection: 'column', marginLeft: CONTROLS_SPACING, } as React.CSSProperties, navigationContainer: { flexShrink: 0, display: 'flex', flexDirection: 'row', justifyContent: 'center', padding: 10, } as React.CSSProperties, saveButton: { marginTop: 10, }, countdownContainer: { padding: 8, }, iconButtonPlaceholder: { // Dimensions match `.iconButton`: display: 'inline-block', width: 50, height: 50, }, timestampPill: { borderRadius: '15px', backgroundColor: '#000000', color: '#eeefef', fontSize: '16px', letterSpacing: '0px', lineHeight: '18px', // This cast is necessary or typescript chokes textAlign: 'center' as 'center', padding: '6px', paddingLeft: '18px', paddingRight: '18px', }, }; interface IconButtonProps { onClick?: () => void; style?: React.CSSProperties; type: 'save' | 'close' | 'previous' | 'next'; } const IconButton = ({ onClick, style, type }: IconButtonProps) => { const clickHandler = (event: React.MouseEvent): void => { event.preventDefault(); if (!onClick) { return; } onClick(); }; return (