"use client"; import { useRef, useState, useEffect } from "react"; import { motion } from "framer-motion"; const NavItems = ({ isNavOpen }) => { const [isMobile, setIsMobile] = useState(false); const navVariant = { open: (height = 1000) => ({ clipPath: `circle(${height + 400}px at calc(100% - 40px) 40px)`, transition: { type: "spring", stiffness: 400, damping: 30, }, }), closed: { clipPath: "circle(0px at calc(100% - 120px) 35px)", transition: { delay: 0.5, type: "spring", stiffness: 400, damping: 30, }, }, }; useEffect(() => { const updateScreenWidth = () => { setIsMobile(window.innerWidth <= 768); }; // Initial check and event listener updateScreenWidth(); window.addEventListener("resize", updateScreenWidth); // Clean up the event listener on unmount return () => { window.removeEventListener("resize", updateScreenWidth); }; }, []); // Check screen width and adjust clipPath for smaller screens if (isMobile) { navVariant.closed = { clipPath: "circle(0px at calc(100% - 35px) 35px)", // Adjusted value for mobile screens transition: { delay: 0.5, type: "spring", stiffness: 400, damping: 40, }, }; } else { navVariant.closed = { clipPath: "circle(0px at calc(100% - 120px) 35px)", transition: { delay: 0.5, type: "spring", stiffness: 400, damping: 40, }, }; } const itemVariants = { open: { opacity: 1, y: 0, rotate: 0, }, closed: { opacity: 0, y: -40, rotate: 0, }, }; return ( <>
{/* title */} Menu Home About Projects Contact
); }; const Navbar = () => { const navRef = useRef(null); const [isNavOpen, setIsNavOpen] = useState(false); const toggleNav = () => { setIsNavOpen(!isNavOpen); }; return ( <> {/* items */} ); }; export default Navbar;