95 lines
2.9 KiB
TypeScript
95 lines
2.9 KiB
TypeScript
"use client";
|
|
|
|
import { useEffect, useState } from "react";
|
|
import { Bars3Icon, XMarkIcon } from "@heroicons/react/24/solid";
|
|
import NavPages from "./NavPages";
|
|
import logo from "@/public/logo.png";
|
|
import logo_small from "@/public/logo_small.png";
|
|
import Image from "next/image";
|
|
import { usePathname } from "next/navigation";
|
|
|
|
const Navbar = () => {
|
|
const [isTopOfPage, setIsTopOfPage] = useState(true);
|
|
const [menuActive, setMenuActive] = useState(false);
|
|
|
|
const currentPage = "/" + usePathname().split("/")[1];
|
|
|
|
useEffect(() => {
|
|
const handleScroll = () => {
|
|
if (window.scrollY === 0) {
|
|
setIsTopOfPage(true);
|
|
} else {
|
|
setIsTopOfPage(false);
|
|
}
|
|
};
|
|
window.addEventListener("scroll", handleScroll);
|
|
return () => window.removeEventListener("scroll", handleScroll);
|
|
}, []);
|
|
|
|
const useSmallNav: boolean = isTopOfPage && currentPage === "/";
|
|
|
|
return (
|
|
<nav
|
|
className={
|
|
"bg-primary-500 text-primary-100 fixed top-0 z-40 w-full " +
|
|
(useSmallNav
|
|
? "bg-transparent"
|
|
: "bg-opacity-75 backdrop-blur-sm drop-shadow")
|
|
}
|
|
>
|
|
<div className="mx-auto w-11/12 lg:w-5/6 flex justify-between items-center">
|
|
<div className="flex justify-between items-center">
|
|
<Image
|
|
src={useSmallNav ? logo_small : logo_small}
|
|
alt="Feely Center Logo"
|
|
className={
|
|
"drop-shadow-2xl " +
|
|
(useSmallNav ? "w-32 md:w-44" : "w-16 md:w-24")
|
|
}
|
|
/>
|
|
<div
|
|
className={
|
|
"font-cormorant text-2xl p-5 " +
|
|
(useSmallNav ? "text-transparent select-none" : "")
|
|
}
|
|
>
|
|
Richard A. Feely, DO
|
|
</div>
|
|
</div>
|
|
|
|
{/* Burger icon */}
|
|
<div className="md:hidden w-[30px] text-tertiary-300 ">
|
|
<Bars3Icon onClick={() => setMenuActive((e) => !e)}></Bars3Icon>
|
|
</div>
|
|
{/* Burger menu */}
|
|
{menuActive ? (
|
|
<div className="text-lg animate-fadeIn z-50 fixed top-0 right-0 h-screen bg-secondary-500 drop-shadow-lg ">
|
|
<div className="px-12 py-5 flex flex-col gap-6 text-primary-500 text-right">
|
|
<div className="pb-3 flex justify-end ">
|
|
<XMarkIcon
|
|
className="w-[30px]"
|
|
onClick={() => setMenuActive((e) => !e)}
|
|
></XMarkIcon>
|
|
</div>
|
|
<NavPages currentPageClasses="text-primary-100"></NavPages>
|
|
</div>
|
|
</div>
|
|
) : (
|
|
<></>
|
|
)}
|
|
|
|
{/* Nav Bar */}
|
|
<div
|
|
className={
|
|
"hidden md:flex font-abel tems-center gap-6 text-lg text-tertiary-300 " +
|
|
(useSmallNav ? "px-5 py-24" : "p-5")
|
|
}
|
|
>
|
|
<NavPages currentPageClasses="text-secondary-500"></NavPages>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
);
|
|
};
|
|
|
|
export default Navbar;
|