"use client"; import React, { useState } from "react"; import { motion, AnimatePresence, useScroll, useMotionValueEvent, } from "motion/react"; import { cn } from "@/lib/utils"; const HomeIcon = () => 🏠; const ServicesIcon = () => 🛠️; const ProductsIcon = () => 📦; const ContactIcon = () => 📞; export const FloatingNav = ({ navItems = [], className, }) => { const { scrollYProgress } = useScroll(); const [visible, setVisible] = useState(false); useMotionValueEvent(scrollYProgress, "change", (current) => { if (typeof current === "number") { let direction = current - scrollYProgress.getPrevious(); if (scrollYProgress.get() < 0.05) { setVisible(false); } else { if (direction < 0) { setVisible(true); } else { setVisible(false); } } } }); return ( {navItems.map((navItem, idx) => ( {navItem.icon} {navItem.name} ))} ); }; // مثال الاستخدام مع 4 روابط export default function App() { const navItems = [ { name: "Home", link: "/", icon: }, { name: "Services", link: "/services", icon: }, { name: "Products", link: "/products", icon: }, { name: "Contact", link: "/contact", icon: }, ]; return ( <>

Scroll down and up to see the navbar appear/disappear

); }