Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: learning hub page #2403

Merged
merged 12 commits into from
Mar 20, 2024
50 changes: 49 additions & 1 deletion src/components/globals/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -6144,8 +6144,47 @@ export const flyoutNavigation = [
column_2_items: {
type: 'relationship',
model: 'sub_nav2022',
totalItems: 4,
totalItems: 5,
data: [
{
nav_item_name: 'Learning Hub Videos',
page_link: {
type: 'relationship',
model: 'for_industry_pages',
totalItems: 1,
data: [[]],
},
external_link_if_needed: '/learning-hub/',
parent_nav_item: {
type: 'relationship',
model: 'sub_nav2022',
totalItems: 1,
data: [
{
nav_item_name: 'Industry learning',
page_link: null,
external_link_if_needed: null,
parent_nav_item: null,
icon_image: null,
sort_order: '2',
main_or_blue_secondary_item: '0',
},
],
},
icon_image: {
type: 'images',
totalItems: 1,
data: [
{
type: 'image',
zuid: '3-11555e5b-gtgn5t',
url: 'https://kfg6bckb.media.zestyio.com/Learning-Hub.png',
},
],
},
sort_order: '1',
main_or_blue_secondary_item: '1',
},
{
nav_item_name: 'Blog',
page_link: {
Expand Down Expand Up @@ -11357,6 +11396,15 @@ export const navigationCustom = [
zuid: '7-8ed2b6a189-w85cqt',
children: [],
},
{
external: false,
parentZUID: null,
sort: '1',
url: '/learning-hub/',
title: 'Learning Hub Videos',
zuid: '7-cc809dacb1-hxjshj',
children: [],
},
{
external: false,
parentZUID: '7-bca0ada1df-1k1b7g',
Expand Down
86 changes: 86 additions & 0 deletions src/components/marketing/LearningHub/FeaturedCard.js
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;
67 changes: 67 additions & 0 deletions src/components/marketing/LearningHub/FeaturedVideos.js
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;
Loading
Loading