diff --git a/app/globals.css b/app/globals.css index 7fad8dc..c9ceb44 100644 --- a/app/globals.css +++ b/app/globals.css @@ -1,4 +1,5 @@ @import "tailwindcss"; +@custom-variant dark (&:is(.dark *)); @layer base { :root { @@ -78,3 +79,33 @@ ::-webkit-scrollbar-thumb:hover { background: hsl(var(--muted-foreground)); } + +/* Hero Badge Shimmer */ +@keyframes badge-shimmer { + 0% { + background-position: -200% 0; + } + 100% { + background-position: 200% 0; + } +} + +.badge-shimmer { + background-image: linear-gradient( + 110deg, + transparent 25%, + rgba(59, 130, 246, 0.12) 37%, + transparent 50% + ); + background-size: 200% 100%; + animation: badge-shimmer 4s ease-in-out infinite; +} + +.dark .badge-shimmer { + background-image: linear-gradient( + 110deg, + transparent 25%, + rgba(96, 165, 250, 0.08) 37%, + transparent 50% + ); +} diff --git a/components/navbar.tsx b/components/navbar.tsx index faf5819..da8ab58 100644 --- a/components/navbar.tsx +++ b/components/navbar.tsx @@ -2,11 +2,11 @@ import Link from "next/link"; import Image from "next/image"; -import { useState, useEffect } from "react"; +import { useState, useEffect, useRef } from "react"; import { Menu, X, Sun, Moon } from "lucide-react"; import { motion, AnimatePresence } from "framer-motion"; import { useTheme } from "next-themes"; -import { useRouter } from "next/navigation"; +import { useRouter, usePathname } from "next/navigation"; const navLinks = [ { @@ -33,6 +33,9 @@ export default function Navbar() { const { theme, setTheme } = useTheme(); const [mounted, setMounted] = useState(false); const router = useRouter(); + const pathname = usePathname(); + const [activeSection, setActiveSection] = useState("/#Home"); + const isClickScrolling = useRef(false); useEffect(() => { const timer = setTimeout(() => { @@ -41,9 +44,34 @@ export default function Navbar() { const handleScroll = () => { setScrolled(window.scrollY > 20); + + if (!isClickScrolling.current) { + const sections = navLinks + .filter((link) => link.href.startsWith("/#")) + .map((link) => link.href.substring(2)); + + let current = ""; + for (const section of sections) { + const element = document.getElementById(section); + if (element) { + const rect = element.getBoundingClientRect(); + if (rect.top <= 120 && rect.bottom >= 120) { + current = section; + break; + } + } + } + + if (current) { + setActiveSection(`/#${current}`); + } else if (window.scrollY < 100) { + setActiveSection("/#Home"); + } + } }; window.addEventListener("scroll", handleScroll, { passive: true }); + handleScroll(); return () => { clearTimeout(timer); @@ -62,16 +90,27 @@ export default function Navbar() { const element = document.getElementById(targetId); if (element) { + isClickScrolling.current = true; + setActiveSection(href); element.scrollIntoView({ behavior: "smooth", block: "start" }); // Close mobile menu if open setIsOpen(false); + + setTimeout(() => { + isClickScrolling.current = false; + }, 800); } else { // If element not found, navigate to home and then scroll router.push("/"); setTimeout(() => { const el = document.getElementById(targetId); if (el) { + isClickScrolling.current = true; + setActiveSection(href); el.scrollIntoView({ behavior: "smooth", block: "start" }); + setTimeout(() => { + isClickScrolling.current = false; + }, 800); } }, 100); } @@ -80,53 +119,72 @@ export default function Navbar() { return (
-
+
{/* Logo */} -
+
Hyper Learning Official Logo
-
- +
+ Hyper Learning - -

+

AI-Powered Learning Platform

{/* Desktop Navigation */} -