import React, { useState, useEffect } from "react"; import { Search, LogIn, Menu, X, Moon, Sun, Home, Bell, FileText, BookOpen, } from "lucide-react"; import { NavigationMenu, NavigationMenuList, NavigationMenuItem, } from "@/components/ui/navigation-menu"; import { Button } from "@/components/ui/button"; import { Link, router, usePage } from "@inertiajs/react"; import { Drawer, DrawerClose, DrawerContent, DrawerHeader, DrawerTitle, DrawerTrigger, } from "@/components/ui/drawer"; import RunningText from "./RunningText"; import { useTheme } from "next-themes"; import SearchDialog from "./SearchDialog"; import { Post } from "../DetailArtikel/types"; import { PageProps as InertiaPageProps } from "@inertiajs/core"; interface NavItemsProps { mobile?: boolean; onClose?: () => void; } interface CustomPageProps extends InertiaPageProps { runPosts?: Post[]; errors: Record; auth: { user: any; }; } const Navbar = () => { const { runPosts = [], auth } = usePage().props; const [isScrolled, setIsScrolled] = useState(false); const [isDrawerOpen, setIsDrawerOpen] = useState(false); const { theme, setTheme } = useTheme(); // Handle scroll effect useEffect(() => { const handleScroll = () => { const scrollPosition = window.scrollY; setIsScrolled(scrollPosition > 50); }; window.addEventListener("scroll", handleScroll); return () => window.removeEventListener("scroll", handleScroll); }, []); const toggleTheme = () => { setTheme(theme === "light" ? "dark" : "light"); }; const menuItems = [ { title: "HOME", icon: , href: "/" }, { title: "PENGUMUMAN", icon: , href: "/pengumuman", }, { title: "UNDANGAN", icon: , href: "/undangan", }, { title: "PERATURAN", icon: , href: "/peraturan", }, ]; const NavItems: React.FC = ({ mobile = false, onClose }) => ( <> {menuItems.map((item) => ( {item.icon} {item.title} ))} ); return (
Logo
Login Menu
setIsDrawerOpen(false) } />
{auth?.user ? "DASHBOARD" : "LOGIN"}
); }; export default Navbar;