Skip to content

Commit

Permalink
new update
Browse files Browse the repository at this point in the history
  • Loading branch information
sanchayan721 committed Aug 25, 2023
1 parent e39071b commit 74aa9ab
Show file tree
Hide file tree
Showing 15 changed files with 63 additions and 19 deletions.
Binary file added public/videos/navmenu/collaborators.webm
Binary file not shown.
Binary file added public/videos/navmenu/commercial.webm
Binary file not shown.
Binary file added public/videos/navmenu/contact-us.webm
Binary file not shown.
Binary file not shown.
Binary file added public/videos/navmenu/media-network.webm
Binary file not shown.
Binary file added public/videos/navmenu/partners.webm
Binary file not shown.
Binary file added public/videos/navmenu/translate.webm
Binary file not shown.
Binary file added public/videos/white_noise.webm
Binary file not shown.
10 changes: 8 additions & 2 deletions src/components/navigation/NavMenu/Display/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { useNavHoverContext } from '@helpers/NavHoverContext';
import { styled } from '@mui/material'
import { on } from 'events';
import Image from 'next/image';
import React from 'react'

Expand Down Expand Up @@ -29,6 +31,9 @@ const StyledVideo = styled('video')(({ theme }) => ({


const Display = () => {

const { currentUrl, setCurrentUrl } = useNavHoverContext();

return (
<DisplayWrapper>
<StyledImage
Expand All @@ -44,10 +49,11 @@ const Display = () => {
}}
/>
<StyledVideo
src='/videos/sample.mp4'
src={currentUrl}
autoPlay
loop
muted
loop
onError={() => setCurrentUrl('/videos/white_noise.webm')}
/>
</DisplayWrapper>
)
Expand Down
11 changes: 9 additions & 2 deletions src/components/navigation/NavMenu/Megamenu/NavGroups/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { UtilityIconProps } from '@interfaces/SVGProps';
import svgCommonProps from '@utils/svgCommonProps';
import Title from './Title';
import { navbar } from '@theme/constants';
import { useNavHoverContext } from '@helpers/NavHoverContext';

const Navgroup = styled('ul')(({ theme }) => ({
position: 'relative',
Expand Down Expand Up @@ -101,9 +102,15 @@ const Dot = styled(({ ...props }: UtilityIconProps) => {
}
}));

const NavGroups = ({ title, items }: NavGroupsProps) => {
const NavGroups = ({ title, videoUrl, items }: NavGroupsProps) => {

const { setCurrentUrl } = useNavHoverContext();

return (
<Navgroup >
<Navgroup
onMouseEnter={setCurrentUrl.bind(null, videoUrl)}
onMouseLeave={setCurrentUrl.bind(null, '/videos/white_noise.webm')}
>
<GroupCard
className='group__card'
elevation={navbar.elevationHigh}
Expand Down
6 changes: 5 additions & 1 deletion src/components/navigation/NavMenu/Megamenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ const Megamenu = () => {
<MegamenuSection>
{menuItems.map((item, index) => (
<React.Fragment key={index}>
<NavGropus title={item.title} items={item.items} />
<NavGropus
title={item.title}
videoUrl={item.videoUrl}
items={item.items}
/>
</React.Fragment>
))}
</MegamenuSection>
Expand Down
12 changes: 6 additions & 6 deletions src/components/navigation/NavMenu/Megamenu/menuItems.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const menuItems = [
{
title: 'Business',
videoUrl: '/media/videos/navMenu/business.webm',
videoUrl: '/videos/navmenu/business.webm',
items: [
{
title: 'About Us',
Expand All @@ -23,7 +23,7 @@ const menuItems = [
},
{
title: 'Media Network',
videoUrl: '/media/videos/navMenu/media-network.webm',
videoUrl: '/videos/navmenu/media-network.webm',
items: [
{
title: 'Business and Brands',
Expand All @@ -45,7 +45,7 @@ const menuItems = [
},
{
title: 'Education & Teaching',
videoUrl: '/media/videos/navMenu/education-and-teaching.webm',
videoUrl: '/videos/navmenu/education-and-teaching.webm',
items: [
{
title: 'Resources',
Expand All @@ -63,7 +63,7 @@ const menuItems = [
},
{
title: 'Collaborators',
videoUrl: '/media/videos/navMenu/collaborators.webm',
videoUrl: '/videos/navmenu/collaborators.webm',
items: [
{
title: 'Explorers',
Expand All @@ -77,7 +77,7 @@ const menuItems = [
},
{
title: 'Partners',
videoUrl: '/media/videos/navMenu/partners.webm',
videoUrl: '/videos/navmenu/partners.webm',
items: [
{
title: 'Corporate & Foundations',
Expand All @@ -91,7 +91,7 @@ const menuItems = [
},
{
title: 'Commercial',
videoUrl: '/media/videos/navMenu/commercial.webm',
videoUrl: '/videos/navmenu/commercial.webm',
items: [
{
title: 'Advertise with Us',
Expand Down
19 changes: 11 additions & 8 deletions src/components/navigation/NavMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Copyright from './Copyright';
import Settings from './Settings';
import Legal from './Legal';
import Megamenu from './Megamenu';
import { NavHoverProvider } from '@helpers/NavHoverContext';

const NavigationWrapper = styled(Card)<NavigationCardProps>(({ theme, open }) => ({
...theme.PageWrapperProps as any,
Expand Down Expand Up @@ -52,14 +53,16 @@ const NavMenu = () => {
open={useNavigationMenuState().isOpen}
elevation={navbar.elevationHigh}
>
<NavigationContent>
<Display />
<Megamenu />
<Contact />
<Copyright />
<Settings />
<Legal />
</NavigationContent>
<NavHoverProvider>
<NavigationContent>
<Display />
<Megamenu />
<Contact />
<Copyright />
<Settings />
<Legal />
</NavigationContent>
</NavHoverProvider>
</NavigationWrapper>
)
};
Expand Down
23 changes: 23 additions & 0 deletions src/helpers/NavHoverContext.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React, { createContext, useContext } from "react";

export type NavHoverContextType = {
currentUrl: string;
setCurrentUrl: React.Dispatch<React.SetStateAction<string>>;
};

const NavHoverContext = createContext<NavHoverContextType>(
null as unknown as NavHoverContextType
);

export const useNavHoverContext = () => useContext(NavHoverContext);

export const NavHoverProvider = (
{
children
}: {
children: React.ReactNode
}
) => {
const [currentUrl, setCurrentUrl] = React.useState('');
return <NavHoverContext.Provider value={{ currentUrl, setCurrentUrl }}>{children}</NavHoverContext.Provider>
};
1 change: 1 addition & 0 deletions src/interfaces/NavGropusProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
export interface NavGroupsProps {
title: string;
items: any[];
videoUrl: string;
};

0 comments on commit 74aa9ab

Please sign in to comment.