"use client"; // Importation des composants et hooks nécessaires import SmoothLink from "@/component/ui/SmoothLink"; import { AnimatePresence, motion } from "framer-motion"; import { Code2, FolderKanban, Home, LucideIcon, Mail, Menu, User, X, } from "lucide-react"; import Image from "next/image"; import { useEffect, useState } from "react"; // Interface définissant la structure d'un lien de navigation interface NavLink { href: string; label: string; icon: LucideIcon; } // Configuration des liens de navigation avec leurs icônes const navLinks: NavLink[] = [ { href: "/", label: "Accueil", icon: Home }, { href: "#about", label: "À propos", icon: User }, { href: "#skills", label: "Compétences", icon: Code2 }, { href: "#projects", label: "Projets", icon: FolderKanban }, { href: "#contact", label: "Contact", icon: Mail }, ]; export default function NavBar() { const [isOpen, setIsOpen] = useState(false); const [activeSection, setActiveSection] = useState("home"); const [scrolled, setScrolled] = useState(false); // Effet pour gérer le scroll et détecter la section active useEffect(() => { const handleScroll = () => { setScrolled(window.scrollY > 20); const sections = navLinks.map((link) => link.href.replace("#", "")); const currentSection = sections.find((section) => { const element = document.getElementById(section); if (element) { const rect = element.getBoundingClientRect(); return rect.top <= 100 && rect.bottom >= 100; } return false; }); if (currentSection) { setActiveSection(currentSection); } }; window.addEventListener("scroll", handleScroll); return () => window.removeEventListener("scroll", handleScroll); }, []); // Effet pour bloquer le scroll du body quand le menu mobile est ouvert useEffect(() => { if (isOpen) { document.body.style.overflow = "hidden"; } else { document.body.style.overflow = "unset"; } }, [isOpen]); const handleLinkClick = () => { setIsOpen(false); }; return (
{/* Logo et nom - lien vers l'accueil */} {/* Conteneur du logo avec effet hover */}
Logo Jessy David
{/* Nom avec effet de soulignement au hover */}
Jessy David
{/* Navigation pc - cachée sur mobile */}
{navLinks.map((link) => { const isActive = activeSection === link.href.replace("#", ""); const Icon = link.icon; return ( {/* Icône et label du lien */} {link.label} {/* Indicateur animé de la section active */} {isActive && ( )} ); })}
{/* Bouton hamburger pour mobile */}
{/* Menu mobile avec animations */} {isOpen && ( <> {/* Overlay sombre derrière le menu */} setIsOpen(false)} /> {/* Panneau du menu mobile coulissant depuis la droite */} {/* Dégradé décoratif en haut du menu */}
{/* Bouton de fermeture du menu */} setIsOpen(false)} className="absolute top-4 right-4 p-2 rounded-full bg-slate-800/80 border border-slate-700 text-slate-400 hover:text-white hover:bg-slate-700 hover:border-slate-600 transition-all z-10" aria-label="Fermer le menu" > {/* Contenu du menu mobile */}
)}
); }