2024-06-20 13:59:27 +05:30
|
|
|
import { Box, Button, Container, Image } from "@chakra-ui/react";
|
2024-06-20 20:14:37 +05:30
|
|
|
import React, { useEffect, useState } from "react";
|
2024-06-20 13:59:27 +05:30
|
|
|
import logo from "../assets/logo.png";
|
|
|
|
|
import earth from "../assets/earth.png";
|
2024-06-20 20:14:37 +05:30
|
|
|
import { Link, NavLink } from "react-router-dom";
|
2024-06-20 13:59:27 +05:30
|
|
|
import { ChevronDownIcon } from "@chakra-ui/icons";
|
|
|
|
|
|
2024-06-20 20:14:37 +05:30
|
|
|
|
2024-06-20 13:59:27 +05:30
|
|
|
export const nav = [
|
|
|
|
|
{
|
|
|
|
|
title: "Investment",
|
|
|
|
|
path: "/investment",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: "How it works",
|
2024-06-20 20:14:37 +05:30
|
|
|
path: "/how-it-works",
|
2024-06-20 13:59:27 +05:30
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: "FAQ",
|
2024-06-20 20:14:37 +05:30
|
|
|
path: "/faq",
|
2024-06-20 13:59:27 +05:30
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: "About Us",
|
2024-06-20 20:14:37 +05:30
|
|
|
path: "/aboutus",
|
2024-06-20 13:59:27 +05:30
|
|
|
},
|
|
|
|
|
];
|
2024-06-20 12:26:20 +05:30
|
|
|
|
|
|
|
|
const Header = () => {
|
2024-06-20 20:14:37 +05:30
|
|
|
const [showHeader, setShowHeader] = useState(true);
|
|
|
|
|
const [lastScrollY, setLastScrollY] = useState(0);
|
|
|
|
|
const threshold = 50; // Adjust this value to change sensitivity
|
|
|
|
|
const controlHeader = () => {
|
|
|
|
|
if (window.scrollY > lastScrollY + threshold) {
|
|
|
|
|
setShowHeader(false);
|
|
|
|
|
} else if (window.scrollY < lastScrollY - threshold) {
|
|
|
|
|
setShowHeader(true);
|
|
|
|
|
}
|
|
|
|
|
setLastScrollY(window.scrollY);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
window.addEventListener("scroll", controlHeader);
|
|
|
|
|
return () => {
|
|
|
|
|
window.removeEventListener("scroll", controlHeader);
|
|
|
|
|
};
|
|
|
|
|
}, [lastScrollY]);
|
|
|
|
|
|
2024-06-20 12:26:20 +05:30
|
|
|
return (
|
2024-06-20 20:14:37 +05:30
|
|
|
<Box
|
|
|
|
|
zIndex={100}
|
|
|
|
|
top={showHeader ? 0 : "-80px"} // Adjust the -80px to match the height of your header
|
|
|
|
|
transition="top 0.3s" position={"sticky"} backgroundColor={"#002F0F"}>
|
2024-06-20 13:59:27 +05:30
|
|
|
<Container
|
|
|
|
|
p={4}
|
|
|
|
|
display={"flex"}
|
|
|
|
|
justifyContent={"space-between"}
|
|
|
|
|
maxW="container.xl"
|
|
|
|
|
>
|
2024-06-20 20:14:37 +05:30
|
|
|
<Link to={"/"}>
|
|
|
|
|
<Image src={logo} h={8} /></Link>
|
2024-06-20 13:59:27 +05:30
|
|
|
<Box display={"flex"} gap={6}>
|
|
|
|
|
{nav.map(({ title, path }, index) => (
|
|
|
|
|
<NavLink
|
2024-06-20 20:14:37 +05:30
|
|
|
key={index}
|
2024-06-20 13:59:27 +05:30
|
|
|
style={{
|
|
|
|
|
textDecoration: "none",
|
|
|
|
|
color: "white",
|
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
}}
|
|
|
|
|
to={path}
|
|
|
|
|
>
|
|
|
|
|
{title}
|
|
|
|
|
</NavLink>
|
|
|
|
|
))}
|
|
|
|
|
</Box>
|
|
|
|
|
|
|
|
|
|
<Box display={"flex"} alignItems={"center"} gap={4}>
|
|
|
|
|
<span className="d-flex align-items-center gap-1 text-white">
|
|
|
|
|
<Image src={earth} h={4} me={1} /> En <ChevronDownIcon />
|
|
|
|
|
</span>
|
|
|
|
|
<Button color={"#002F0F"} ps={6} pe={6} size={"sm"} rounded={"xl"}>
|
|
|
|
|
Contact Us
|
|
|
|
|
</Button>
|
|
|
|
|
</Box>
|
|
|
|
|
</Container>
|
|
|
|
|
</Box>
|
|
|
|
|
);
|
|
|
|
|
};
|
2024-06-20 12:26:20 +05:30
|
|
|
|
2024-06-20 13:59:27 +05:30
|
|
|
export default Header;
|