"use client"; import React, { useEffect, useRef, useState } from "react"; import Image from "next/image"; import Link from "next/link"; import { motion, Variants } from "framer-motion"; import { cn } from "@/lib/utils"; import Button from "../shared/Button"; const MobileNavbar = () => { const [isOpen, setIsOpen] = useState(false); const [scrolled, setScrolled] = useState(false); const mobileRef = useRef(null); useEffect(() => { const handleScroll = () => { const currentScroll = window.scrollY; setScrolled(currentScroll > 30); }; window.addEventListener("scroll", handleScroll); return () => window.removeEventListener("scroll", handleScroll); }, []); const navLinks = [ { label: "Home", href: "#home" }, { label: "About Us", href: "#about" }, { label: "Features", href: "#features" }, { label: "Benefits", href: "#benefits" }, { label: "FAQ", href: "#faq" }, ]; const containerVariants: Variants = { hidden: { y: -100, opacity: 0 }, visible: { y: 0, opacity: 1, transition: { duration: 1.2, ease: [0.19, 1, 0.22, 1] }, // expo.out‑ish }, }; // ✅ Correctly typed Framer Motion variants const mobileNavVariants: Variants = { hidden: { opacity: 0, y: 20 }, visible: { opacity: 1, y: 0, transition: { staggerChildren: 0.1, duration: 0.4, ease: "easeInOut", // ✅ typed correctly }, }, }; const linkVariants: Variants = { hidden: { opacity: 0, y: 20 }, visible: { opacity: 1, y: 0, transition: { duration: 0.3, ease: "easeInOut", // ✅ allowed by Framer }, }, }; // ✅ Safe smooth scroll handler const handleClick = ( e: React.MouseEvent, href: string ) => { e.preventDefault(); const targetId = href.replace("#", ""); const section = document.getElementById(targetId); if (section) { const yOffset = -80; const y = section.getBoundingClientRect().top + window.pageYOffset + yOffset; window.scrollTo({ top: y, behavior: "smooth" }); setIsOpen(false); } }; return ( {/* Header Bar */}
Whispering Tree
{/* Mobile Menu Toggle */}
{/* Dropdown Mobile Menu */} {navLinks.map((link, i) => ( handleClick(e, link.href)} className={cn( "font-switzer text-h-4-34 group relative inline-block h-full cursor-pointer leading-9 font-medium transition-all duration-700 ease-[cubic-bezier(0.19,1,0.22,1)]" )} > {/* Text hover animation */} {link.label} {link.label} ))}