import React, { useState, useEffect } from 'react'; import { motion, useAnimation } from…
- User
import React, { useState, useEffect } from 'react'; import { motion, useAnimation } from 'framer-motion'; import Link from 'next/link'; import { useRouter } from 'next/navigation';
const Navbar = () => { const router = useRouter(); const controls = useAnimation(); const [isOpen, setIsOpen] = useState(false); const [isScrolled, setIsScrolled] = useState(false);
const isActive = (route) => (router.pathname === route ? 'text-teal-400' : '');
useEffect(() => { const handleScroll = () => { if (window.scrollY > 0) { setIsScrolled(true); } else { setIsScrolled(false); } };
window.addEventListener('scroll', handleScroll); return () => window.removeEventListener('scroll', handleScroll);}, []);
const toggleMenu = () => { setIsOpen(!isOpen);
if (isOpen) { controls.start({ opacity: 0, y: -20, transition: { duration: 0.3 }, }); } else { controls.start({ opacity: 1, y: 0, transition: { duration: 0.3 }, }); }};
const handleHover = (e) => { const target = e.target; const rect = target.getBoundingClientRect();
if (rect.height > 100) { target.style.animation = 'hover-animation 0.5s ease-in-out'; }};
const handleMouseLeave = (e) => { const target = e.target; target.style.animation = ''; };
return ( <motion.nav initial={{ opacity: 0, y: -20 }} animate={{ opacity: 1, y: 0 }} transition={{ duration: 0.5 }} className={
fixed top-0 left-0 w-full z-50 transition-all duration-300 ${ isScrolled ? 'bg-white bg-opacity-90 backdrop-blur-lg shadow-lg' : 'bg-transparent' }} > <Link href="/" className={text-3xl md:text-5xl font-extrabold tracking-tight text-gray-900 hover:text-teal-400 transition duration-300} onMouseEnter={handleHover} onMouseLeave={handleMouseLeave}> <motion.span className="flex items-center space-x-2"> Obay Rashad </motion.span><div className="md:hidden"> <button onClick={toggleMenu} className="text-gray-900 focus:outline-none" > <svg className="h-6 w-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" > {isOpen ? ( <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" /> ) : ( <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 6h16M4 12h16M4 18h16" /> )} </svg> </button> </div> <motion.ul initial={{ opacity: 0, y: 20 }} animate={controls} className={`flex flex flex-col md:flex-row mt-6 md:mt-0 space-y-4 md:space-y-0 md:space-x-12 transition-all duration-300 ${ isOpen ? 'block' : 'hidden md:block' }`} > <motion.li className="group relative" onMouseEnter={handleHover} onMouseLeave={handleMouseLeave}> <Link href="/about" className={`hover:text-teal-400 transition duration-300 text-lg font-medium ${isActive( '/about' )}`} > <motion.div whileHover={{ y: -2 }}>About Me</motion.div> </Link> <div className="absolute bottom-0 left-0 w-full h-1 bg-teal-400 opacity-0 group-hover:opacity-100 transition-opacity duration-300"></div> </motion.li> <motion.li className="group relative" onMouseEnter={handleHover} onMouseLeave={handleMouseLeave}> <Link href="/projects" className={`hover:text-teal-400 transition duration-300 text-lg font-medium ${isActive( '/projects' )}`} > <motion.div whileHover={{ y: -2 }}>Projects</motion.div> </Link> <div className="absolute bottom-0 left-0 w-full h-1 bg-teal-400 opacity-0 group-hover:opacity-100 transition-opacity duration-300"></div> </motion.li> <motion.li className="group relative" onMouseEnter={handleHover} onMouseLeave={handleMouseLeave}> <Link href="/contact" className={`hover:text-teal-400 transition duration-300 text-lg font-medium ${isActive( '/contact' )}`} > <motion.div whileHover={{ y: -2 }}>Contact</motion.div> </Link> <div className="absolute bottom-0 left-0 w-full h-1 bg-teal-400 opacity-0 group-hover:opacity-100 transition-opacity duration-300"></div> </motion.li> </motion.ul> </div> </motion.nav> - Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.