import { Link } from "react-router-dom"; import { useState, useEffect, useRef } from "react"; interface GameCategory { name: string; games: { id: string; title: string }[]; } const TitleBar: React.FC = () => { const [dropdownOpen, setDropdownOpen] = useState(false); const dropdownRef = useRef(null); const gameCategories: GameCategory[] = [ { name: "KONAMI", games: [ { id: "iidx", title: "beatmania IIDX" }, { id: "sdvx", title: "SOUND VOLTEX" }, { id: "ddr", title: "DDR"}, { id: "jubeat", title: "jubeat"}, { id: "popn_music", title: "pop'n music"}, { id: "nostalgia", title: "NOSTALGIA"}, { id: "gitadora", title: "GITADORA"} ], }, { name: "SEGA", games: [ { id: "chunithm_jp", title: "CHUNITHM (JAPAN)" }, { id: "chunithm_intl", title: "CHUNITHM (INTL)" }, { id: "maimaidx_jp", title: "maimai DX (JAPAN)" }, { id: "maimaidx_intl", title: "maimai DX (INTL)" }, { id: "ongeki_jp", title: "O.N.G.E.K.I" }, ], }, { name: "TAITO", games: [ { id: "music_diver", title: "MUSIC DIVER" }, ], }, { name: "BANDAI NAMCO", games: [ { id: "taiko", title: "TAIKO" }, ], }, ]; useEffect(() => { const handleClickOutside = (event: MouseEvent) => { if ( dropdownRef.current && !dropdownRef.current.contains(event.target as Node) ) { setDropdownOpen(false); } }; if (dropdownOpen) { document.addEventListener("mousedown", handleClickOutside); } return () => { document.removeEventListener("mousedown", handleClickOutside); }; }, [dropdownOpen]); return (
573 Updates Logo
573
{/* Site Title */} UPDATES
{/* Navigation Section */}
All Games {/* Dropdown Menu */}
{dropdownOpen && (
{gameCategories.map((category, index) => (
{category.name}
3 ? "grid grid-cols-1 sm:grid-cols-2 gap-x-2 gap-y-0.5" : "space-y-0.5" }`} > {category.games.map((game) => ( setDropdownOpen(false)} > {game.title} ))}
))}
)}
); }; export default TitleBar;