-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: integrate Wistia analytics in Video Learning Hub page (#2435)
# Description Integrate Wistia analytics in Video Learning Hub page Fixes #2432 ## Type of change Please delete options that are not relevant. - [x] New feature (non-breaking change which adds functionality) # How Has This Been Tested? Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. - [x] Manual Test # Screenshots / Screen recording  
- Loading branch information
Showing
4 changed files
with
120 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
src/components/marketing/LearningHub/FeaturedWistiaCard.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/** | ||
* MUI Imports | ||
*/ | ||
import { Box, Card, Typography } from '@mui/material'; | ||
import { useTheme } from '@mui/material/styles'; | ||
import { useEffect } from 'react'; | ||
|
||
const WistiaVideoCard = ({ | ||
title, | ||
wistia_video_id, | ||
published_date, | ||
video_length, | ||
}) => { | ||
const theme = useTheme(); | ||
|
||
const formatDate = (date) => { | ||
date = new Date(date); | ||
const options = { year: 'numeric', month: 'long', day: 'numeric' }; | ||
return date.toLocaleDateString('en-US', options); | ||
}; | ||
|
||
useEffect(() => { | ||
const script1 = document.createElement('script'); | ||
script1.src = `https://fast.wistia.com/embed/medias/${wistia_video_id}.jsonp`; | ||
script1.async = true; | ||
|
||
const script2 = document.createElement('script'); | ||
script2.src = 'https://fast.wistia.com/assets/external/E-v1.js'; | ||
script2.async = true; | ||
|
||
document.body.appendChild(script1); | ||
document.body.appendChild(script2); | ||
|
||
return () => { | ||
document.body.removeChild(script1); | ||
document.body.removeChild(script2); | ||
}; | ||
}, [wistia_video_id]); | ||
|
||
return ( | ||
<Box sx={{ textDecoration: 'none' }}> | ||
<Card | ||
sx={{ | ||
'&:hover': { | ||
border: `1px solid ${theme.palette.zesty.zestyOrange}`, | ||
}, | ||
margin: 'auto', | ||
width: '100%', | ||
minHeight: 280, | ||
background: '#000', | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
border: | ||
theme.palette.mode === 'light' && | ||
`1px solid ${theme.palette.common.grey}`, | ||
}} | ||
> | ||
<Box | ||
sx={{ | ||
position: 'relative', | ||
overflow: 'hidden', | ||
paddingTop: '56.25%', | ||
height: '100%', | ||
width: '100%', | ||
}} | ||
> | ||
<Box | ||
className={`wistia_embed wistia_async_${wistia_video_id} popover=true videoFoam=true`} | ||
sx={{ | ||
position: 'absolute', | ||
top: 0, | ||
left: 0, | ||
width: '100%', | ||
height: '100%', | ||
}} | ||
/> | ||
</Box> | ||
</Card> | ||
|
||
<Typography component="h4" variant="body1" sx={{ fontWeight: 'bold' }}> | ||
{title} | ||
</Typography> | ||
{video_length && ( | ||
<Typography component="p" variant="subtitle2"> | ||
{video_length} | ||
</Typography> | ||
)} | ||
<Typography component="p" variant="subtitle2"> | ||
{formatDate(published_date)} | ||
</Typography> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default WistiaVideoCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters