-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvideo-ask-experiment.js
More file actions
81 lines (70 loc) · 2.05 KB
/
video-ask-experiment.js
File metadata and controls
81 lines (70 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import { useEffect, useState } from 'react'
import styled from 'styled-components'
import { SiteHeader } from 'components'
import { ContentRoot } from 'components/layout'
import { MOBILE_SIZE, TABLET_LARGE_SIZE } from 'styles/constants'
const HeroSection = styled.section`
display: flex;
flex-direction: column;
color: #ffffff;
background: #000000;
background: linear-gradient(248.66deg, #010242 0%, #0f1011 100%);
overflow: hidden;
flex-grow: 1;
`
const Content = styled.div`
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
flex-grow: 1;
margin: 0 5rem;
@media only screen and (max-width: ${TABLET_LARGE_SIZE}) {
margin: 0 3rem;
}
@media only screen and (max-width: ${MOBILE_SIZE}) {
margin: 0 1rem;
}
`
const VideoAskExperiment = () => {
const [isVideoaskSubmitted, setVideoaskSubmitted] = useState(false)
useEffect(() => {
if (process.browser) {
const isVideoaskMessage = (message) =>
message.origin === 'https://www.videoask.com' &&
message.data &&
message.data.type &&
message.data.type.startsWith('videoask_')
window.addEventListener('message', (message) => {
if (!isVideoaskMessage(message)) {
return
}
console.log('got videoask message', message.data)
const { type } = message.data
if (type === 'videoask_submitted') {
setVideoaskSubmitted(true)
}
})
}
}, [])
return (
<ContentRoot>
<HeroSection>
<SiteHeader />
<Content>
{!isVideoaskSubmitted && (
<iframe
title="Videoask form"
src="https://www.videoask.com/fygcqej3f"
allow="camera *; microphone *; autoplay *; encrypted-media *; fullscreen *; display-capture *;"
width="100%"
height="600px"
/>
)}
{isVideoaskSubmitted && <span>Videoask Submitted! 🎉🎉🎉</span>}
</Content>
</HeroSection>
</ContentRoot>
)
}
export default VideoAskExperiment