-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5ea21c6
commit 46a5507
Showing
5 changed files
with
311 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
|
||
import { GetServerSidePropsContext } from 'next'; | ||
import ReactGA from 'react-ga'; | ||
import Image from 'next/image'; | ||
import { useWindowHeight } from '@react-hook/window-size'; | ||
import { useRouter } from 'next/router'; | ||
import SDGNavModal from './SDGNavModal'; | ||
|
||
const TracksHeader = () => { | ||
const [modalVisibility, setModalVisibility] = useState(false); | ||
|
||
const [scrollPosition, setScrollPosition] = useState(0); | ||
|
||
const router = useRouter(); | ||
|
||
useEffect(() => { | ||
const handleScroll = () => { | ||
setScrollPosition(window.scrollY); | ||
}; | ||
|
||
window.addEventListener('scroll', handleScroll); | ||
|
||
return () => { | ||
window.removeEventListener('scroll', handleScroll); | ||
}; | ||
}, []); | ||
|
||
const handleMenuClick = (targetId: string) => { | ||
console.log(targetId); | ||
if ( | ||
router.asPath.startsWith('/sdg/team') && | ||
targetId !== 'about-section' | ||
) { | ||
const targetElement = document.getElementById(targetId); | ||
if (targetElement) { | ||
targetElement.scrollIntoView({ behavior: 'smooth' }); | ||
} | ||
router.push('/hack/#' + targetId); | ||
} else if (router.asPath.startsWith('/sdg')) { | ||
const targetElement = document.getElementById(targetId); | ||
if (targetElement) { | ||
targetElement.scrollIntoView({ behavior: 'smooth' }); | ||
} | ||
} | ||
if ( | ||
router.asPath.split('/')[1].startsWith('event') && | ||
targetId !== 'events-section' | ||
) | ||
router.push(`/#${targetId}`); | ||
|
||
if (router.asPath.split('/')[1].startsWith('team')) | ||
router.push(`/#${targetId}`); | ||
|
||
const targetElement = document.getElementById(targetId); | ||
if (targetElement) { | ||
const yOffset = 0; // Adjust the yOffset value as per your requirement | ||
const y = | ||
targetElement.getBoundingClientRect().top + | ||
window.pageYOffset + | ||
yOffset; | ||
window.scrollTo({ top: y, behavior: 'smooth' }); | ||
} | ||
}; | ||
|
||
const windowHeight = useWindowHeight(); | ||
|
||
const headerClass = | ||
scrollPosition === 0 | ||
? 'opacity-100' | ||
: scrollPosition > windowHeight - 100 | ||
? 'glassMorphism sticky top-0' | ||
: scrollPosition > 50 //navbar length | ||
? 'opacity-0' | ||
: 'opacity-100'; | ||
|
||
// add active tab opacity | ||
|
||
return ( | ||
<> | ||
<div | ||
className={`hidden lg:flex justify-between items-center w-full h-[4rem] px-16 text-white z-[100] transition-all duration-300 ease-in-out ${headerClass}`} | ||
> | ||
<div className="w-[20%] h-full flex justify-around items-center"> | ||
<Image | ||
src="/vitLogo2.png" | ||
alt="logo" | ||
height={10000} | ||
width={10000} | ||
className="w-[15vw] px-5 h-auto object-cover cursor-pointer" | ||
onClick={() => { | ||
router.push('/'); | ||
}} | ||
/> | ||
</div> | ||
<div className="w-[80%] h-full flex gap-10 items-center justify-end font-spaceGrotesk font-semibold text-lg"> | ||
<div | ||
className="cursor-pointer hover-underline-animation" | ||
onClick={() => router.push('/hack')} | ||
> | ||
YANTRA HACKATHON | ||
</div> | ||
<div | ||
className="cursor-pointer hover-underline-animation" | ||
onClick={() => router.push('/team')} | ||
> | ||
Team | ||
</div> | ||
<div | ||
className="cursor-pointer hover-underline-animation" | ||
onClick={() => handleMenuClick('contact-section')} | ||
> | ||
Contact Us | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div | ||
className={`z-30 flex lg:hidden static justify-around items-center w-full h-[7.5vh] text-white ${headerClass}`} | ||
> | ||
<div | ||
onClick={() => { | ||
router.push('/'); | ||
}} | ||
className="w-[20%] h-full flex justify-around items-center" | ||
> | ||
<Image | ||
src="/vitLogoCircle.png" | ||
alt="logo" | ||
height={10000} | ||
width={10000} | ||
className="w-16 p-3 object-cover cursor-pointer" | ||
onClick={() => { | ||
router.push('/'); | ||
}} | ||
/> | ||
</div> | ||
<div className="w-[60%] "></div> | ||
<div | ||
onClick={() => { | ||
setModalVisibility(true); | ||
}} | ||
className="w-[20%] h-full flex justify-around items-center" | ||
> | ||
<svg | ||
width="32" | ||
height="32" | ||
viewBox="0 0 32 32" | ||
fill="none" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path | ||
d="M28 13.3335H4" | ||
stroke="#FFFFFF" | ||
strokeWidth="2.66667" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
/> | ||
<path | ||
d="M28 8H4" | ||
stroke="#FFFFFF" | ||
strokeWidth="2.66667" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
/> | ||
<path | ||
d="M28 18.6665H4" | ||
stroke="#FFFFFF" | ||
strokeWidth="2.66667" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
/> | ||
<path | ||
d="M28 24H4" | ||
stroke="#FFFFFF" | ||
strokeWidth="2.66667" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
/> | ||
</svg> | ||
</div> | ||
</div> | ||
{modalVisibility !== false && ( | ||
<SDGNavModal | ||
modalVisibility={setModalVisibility} | ||
visible={true} | ||
// setModalDataFunc={() => { | ||
// setModalData(); | ||
// }} | ||
/> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default TracksHeader; |
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
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