"use client";
import { useRef, useState, useEffect } from "react";
import { motion } from "framer-motion";
import Link from "next/link";
const NavItems = ({ isNavOpen, setIsNavOpen }) => {
const [isMobile, setIsMobile] = useState(false);
const handleItemClick = () => {
setIsNavOpen(false);
};
const navVariant = {
open: {
clipPath: `circle(1920px at calc(100% - 40px) 40px)`,
transition: {
type: "spring",
stiffness: 400,
damping: 40,
},
},
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.open = {
clipPath: `circle(1920px at calc(100% - 40px) 40px)`,
transition: {
type: "tween",
},
}),
(navVariant.closed = {
clipPath: "circle(0px at calc(100% - 35px) 35px)",
transition: {
delay: 0.5,
type: "spring",
stiffness: 400,
damping: 40,
},
});
} else {
(navVariant.open = {
clipPath: `circle(2444px at calc(100% - 40px) 40px)`,
transition: {
type: "spring",
stiffness: 400,
damping: 40,
},
}),
(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 (
<>
>
);
};
const Navbar = () => {
const navRef = useRef(null);
const [isNavOpen, setIsNavOpen] = useState(false);
const toggleNav = () => {
setIsNavOpen(!isNavOpen);
};
return (
<>
{/* items */}
>
);
};
export default Navbar;