diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index fd5eac86..bae3b550 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -1,12 +1,14 @@ -import { NavLink, Link } from "react-router-dom"; +import { NavLink, Link, useNavigate, useLocation } from "react-router-dom"; import { useState, useContext } from "react"; import { ThemeContext } from "../context/ThemeContext"; -import { Moon, Sun, Menu, X, Github } from "lucide-react"; +import { Moon, Sun, Menu, X } from "lucide-react"; const Navbar: React.FC = () => { const [isOpen, setIsOpen] = useState(false); const themeContext = useContext(ThemeContext); + const navigate = useNavigate(); + const location = useLocation(); if (!themeContext) return null; @@ -19,8 +21,28 @@ const Navbar: React.FC = () => { : "text-slate-700 dark:text-gray-300 hover:text-blue-500" }`; + const featureLinkStyles = + "px-4 py-2 rounded-xl text-sm lg:text-base font-semibold transition-all duration-300 text-slate-700 dark:text-gray-300 hover:text-blue-500 cursor-pointer"; + const closeMenu = () => setIsOpen(false); + // Smooth scroll to #features on homepage + const handleFeaturesClick = () => { + closeMenu(); + if (location.pathname === "/") { + const section = document.getElementById("features"); + if (section) { + section.scrollIntoView({ behavior: "smooth" }); + } + } else { + navigate("/#features"); + setTimeout(() => { + const section = document.getElementById("features"); + if (section) section.scrollIntoView({ behavior: "smooth" }); + }, 100); + } + }; + return (