2021-05-16 23:08:25 +00:00
|
|
|
import { Fragment, h } from 'preact'
|
|
|
|
import { useEffect, useRef, useState } from 'preact/hooks'
|
|
|
|
|
|
|
|
import { string } from 'prop-types'
|
|
|
|
|
|
|
|
import { VideoWrapper, Iframe, StyledCrossSvg as CrossSvg } from './styles'
|
|
|
|
|
|
|
|
const Video = ({ url, onClose }) => {
|
|
|
|
const overlayTimeout = useRef(null)
|
|
|
|
const [overlayActive, setOverlayActiveState] = useState(false)
|
|
|
|
|
|
|
|
const activateOverlay = () => {
|
|
|
|
clearTimeout(overlayTimeout.current)
|
|
|
|
overlayTimeout.current = null
|
|
|
|
setOverlayActiveState(true)
|
|
|
|
|
|
|
|
console.log('overlayTimeout.current', overlayTimeout.current)
|
|
|
|
overlayTimeout.current = setTimeout(
|
|
|
|
() => setOverlayActiveState(false),
|
|
|
|
1500
|
|
|
|
)
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<Fragment>
|
2021-05-18 12:18:29 +00:00
|
|
|
<VideoWrapper $active={overlayActive}>
|
2021-05-16 23:08:25 +00:00
|
|
|
<CrossSvg $active={overlayActive} onClick={onClose} size="64" />
|
|
|
|
</VideoWrapper>
|
|
|
|
<Iframe
|
2021-05-18 12:18:29 +00:00
|
|
|
onMouseMove={activateOverlay}
|
2021-05-16 23:08:25 +00:00
|
|
|
width="560"
|
|
|
|
height="315"
|
2021-05-18 12:18:29 +00:00
|
|
|
src="https://www.youtube-nocookie.com/embed/b-JQ5Bo4JnI?autoplay=1&vq=hd1080"
|
2021-05-16 23:08:25 +00:00
|
|
|
frameborder="0"
|
|
|
|
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
|
|
|
allowfullscreen
|
|
|
|
/>
|
|
|
|
</Fragment>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
Video.propTypes = {
|
|
|
|
url: string,
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Video
|