import React from 'react'; import { Tooltip } from 'react-tippy'; import { Icon } from 'UI'; import cn from 'classnames'; import OutsideClickDetectingDiv from 'Shared/OutsideClickDetectingDiv'; import { ReduxTime } from '../Time'; // @ts-ignore import styles from '../controls.module.css'; interface Props { live: boolean; skip: boolean; speed: number; disabled: boolean; playButton: JSX.Element; skipIntervals: Record; currentInterval: number; setSkipInterval: (interval: number) => void; backTenSeconds: () => void; forthTenSeconds: () => void; toggleSpeed: () => void; toggleSkip: () => void; controlIcon: ( icon: string, size: number, action: () => void, isBackwards: boolean, additionalClasses: string ) => JSX.Element; } function PlayerControls(props: Props) { const { live, skip, speed, disabled, playButton, backTenSeconds, forthTenSeconds, toggleSpeed, toggleSkip, skipIntervals, setSkipInterval, currentInterval, controlIcon, } = props; const [showTooltip, setShowTooltip] = React.useState(false); const speedRef = React.useRef(null); const arrowBackRef = React.useRef(null); const arrowForwardRef = React.useRef(null); React.useEffect(() => { const handleKeyboard = (e: KeyboardEvent) => { if (e.key === 'ArrowRight') { arrowForwardRef.current.focus(); } if (e.key === 'ArrowLeft') { arrowBackRef.current.focus(); } if (e.key === 'ArrowDown') { speedRef.current.focus(); } if (e.key === 'ArrowUp') { speedRef.current.focus(); } }; document.addEventListener('keydown', handleKeyboard); return () => document.removeEventListener('keydown', handleKeyboard); }, [speedRef, arrowBackRef, arrowForwardRef]); const toggleTooltip = () => { setShowTooltip(!showTooltip); } return (
{playButton} {!live && (
{/* @ts-ignore */} / {/* @ts-ignore */}
)}
{/* @ts-ignore */}
Jump (Secs)
{Object.keys(skipIntervals).map((interval) => (
{ toggleTooltip(); setSkipInterval(parseInt(interval, 10)) }} className={cn( "py-2 px-4 cursor-pointer w-full text-left font-semibold", "hover:bg-active-blue border-t border-borderColor-gray-light-shade", )} > {interval} s
))}
} >
{currentInterval}s
{/* @ts-ignore */}
{!live && (
{/* @ts-ignore */}
)} ); } export default PlayerControls;