-
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.
# Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change. Fixes #2396 ## Type of change Please delete options that are not relevant. - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update # 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 - [ ] Unit Test - [ ] E2E Test # Screenshots / Screen recording Please add screenshots or recording if applicable ![image](https://github.com/zesty-io/website/assets/70579069/e5f4f452-deb5-4497-987a-b69407facb9e) ![image](https://github.com/zesty-io/website/assets/70579069/e19518a2-76fc-4db6-946c-2aba5e81a756) ![image](https://github.com/zesty-io/website/assets/70579069/0c84a57f-906a-469d-a986-19a2f7990632) ![Uploading image.png…]()
- Loading branch information
Showing
14 changed files
with
840 additions
and
6 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
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,86 @@ | ||
/** | ||
* MUI Imports | ||
*/ | ||
import { Box, Card, Typography } from '@mui/material'; | ||
import { useTheme } from '@mui/material/styles'; | ||
|
||
const VideoCard = ({ title, youtube_link, 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); | ||
}; | ||
|
||
function convertToNoCookie(url) { | ||
if (!url) return; | ||
// Replace "www.youtube.com" with "www.youtube-nocookie.com" | ||
// Also remove the "/embed/" part | ||
return url.replace( | ||
'www.youtube.com/embed/', | ||
'www.youtube-nocookie.com/embed/', | ||
); | ||
} | ||
|
||
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={{ | ||
width: '100%', | ||
height: '100%', | ||
position: 'relative', | ||
overflow: 'hidden', | ||
paddingTop: '56.25%', | ||
}} | ||
> | ||
<iframe | ||
title="YouTube video player" | ||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" | ||
allowfullscreen | ||
src={convertToNoCookie(youtube_link)} | ||
style={{ | ||
position: 'absolute', | ||
top: 0, | ||
left: 0, | ||
height: '100%', | ||
width: '100%', | ||
border: 'none', | ||
}} | ||
></iframe> | ||
</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 VideoCard; |
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,67 @@ | ||
/** | ||
* MUI Imports | ||
*/ | ||
import { Box, Grid, Typography } from '@mui/material'; | ||
import { useTheme } from '@mui/material/styles'; | ||
import useMediaQuery from '@mui/material/useMediaQuery'; | ||
/** | ||
* Components Imports | ||
*/ | ||
import VideoCard from './FeaturedCard'; | ||
|
||
/** | ||
* React Imports | ||
*/ | ||
import { useContext } from 'react'; | ||
import { LearningHubVideosContext } from './context/LearningHubVideosContext'; | ||
|
||
const FeaturedVideos = ({ featuredVideos = [] }) => { | ||
const { searchKey, selectedTags } = useContext(LearningHubVideosContext); | ||
|
||
/************************************************ | ||
* Theme Settings | ||
*/ | ||
|
||
const theme = useTheme(); | ||
const isExtraSmall = useMediaQuery(theme.breakpoints.between('xs', 600)); | ||
|
||
return ( | ||
<> | ||
<Box | ||
hidden={searchKey !== '' || selectedTags !== '' ? true : false} | ||
sx={{ | ||
pt: 10, | ||
px: 4, | ||
}} | ||
component="section" | ||
> | ||
<Box sx={{ width: '100%', maxWidth: 1600, margin: 'auto' }}> | ||
<Typography | ||
variant="h6" | ||
component="p" | ||
sx={{ | ||
color: theme.palette.zesty.zestyLightText, | ||
mb: 2, | ||
textAlign: isExtraSmall ? 'center' : 'text-left', | ||
}} | ||
> | ||
Featured Videos | ||
</Typography> | ||
<Grid container spacing={2}> | ||
{featuredVideos?.map((item, idx) => { | ||
return ( | ||
<Grid key={idx} item xs={12} md={6} lg={4}> | ||
<Box sx={{ textDecoration: 'none' }}> | ||
<VideoCard {...item} /> | ||
</Box> | ||
</Grid> | ||
); | ||
})} | ||
</Grid> | ||
</Box> | ||
</Box> | ||
</> | ||
); | ||
}; | ||
|
||
export default FeaturedVideos; |
Oops, something went wrong.