From 7e277bad5bd730947bb4b47cdb4ae362451cfb8a Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Tue, 20 May 2025 02:46:48 -0700 Subject: frontend: convert titlebar menus to full page game selector - due to growing number of games supported --- site/src/App.tsx | 4 +- site/src/components/GameNotes.tsx | 14 +++ site/src/components/TitleBar.tsx | 252 ++------------------------------------ site/src/pages/GameSelector.tsx | 99 +++++++++++++++ 4 files changed, 125 insertions(+), 244 deletions(-) create mode 100644 site/src/pages/GameSelector.tsx (limited to 'site') diff --git a/site/src/App.tsx b/site/src/App.tsx index 5142463..79c64a1 100644 --- a/site/src/App.tsx +++ b/site/src/App.tsx @@ -1,13 +1,15 @@ import Home from './pages/Homepage'; +import GameSelector from './pages/GameSelector' import { Routes, Route } from "react-router-dom"; function App() { return ( } /> + } /> } /> ); } -export default App; \ No newline at end of file +export default App; diff --git a/site/src/components/GameNotes.tsx b/site/src/components/GameNotes.tsx index 82f1629..4f5396b 100644 --- a/site/src/components/GameNotes.tsx +++ b/site/src/components/GameNotes.tsx @@ -398,5 +398,19 @@ export const GameNotes = (isMoe: boolean): Record => ({ *Not in main feed as date data is unavailable from this source

+ ), + wmmt: ( + <> +

+ Singular news feed for NA, ASIA/OCE, and JPN +

+

+ All regions run different versions of the game +

+ ) }); diff --git a/site/src/components/TitleBar.tsx b/site/src/components/TitleBar.tsx index daecb4e..2229a45 100644 --- a/site/src/components/TitleBar.tsx +++ b/site/src/components/TitleBar.tsx @@ -1,4 +1,4 @@ -import { useState, useEffect, useRef } from "react"; +import { useEffect } from "react"; import { Link, useSearchParams, @@ -6,25 +6,12 @@ import { useLocation, } from "react-router-dom"; -interface GameCategory { - name: string; - games: { id: string; title: string }[]; -} const TitleBar: React.FC = () => { - const [dropdownOpen, setDropdownOpen] = useState(false); - const [otherDropdownOpen, setOtherDropdownOpen] = useState(false); - const dropdownRef = useRef(null); - const otherDropdownRef = useRef(null); - const rhythmGamesBtnRef = useRef(null); - const otherGamesBtnRef = useRef(null); const [searchParams] = useSearchParams(); const navigate = useNavigate(); const location = useLocation(); const isMoe = searchParams.has("moe"); - const [rhythmDropdownStyle, setRhythmDropdownStyle] = useState({}); - const [otherDropdownStyle, setOtherDropdownStyle] = useState({}); - const toggleTheme = () => { const params = new URLSearchParams(searchParams); @@ -58,121 +45,6 @@ const TitleBar: React.FC = () => { // eslint-disable-next-line react-hooks/exhaustive-deps }, [location.pathname, navigate]); - 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" }, - { id: "dance_rush", title: "DANCERUSH" }, - { id: "dance_around", title: "DANCE aROUND" }, - { id: "polaris_chord", title: "POLARIS CHORD" }, - ], - }, - { - 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" }], - }, - { - name: "COMMUNITY", - games: [ - { id: "wacca_plus", title: "WACCA PLUS" }, - { id: "museca_plus", title: "MÚSECA PLUS" }, - { id: "rb_deluxe_plus", title: "RB DELUXE PLUS" }, - ], - }, - ]; - - const otherGames: GameCategory[] = [ - { - name: "BANDAI NAMCO", - games: [ - { id: "wmmt", title: "WANGAN MAXI" }, - ], - }, - ]; - - const calculateDropdownPosition = (buttonRef: React.RefObject) => { - if (!buttonRef.current) return {}; - - const rect = buttonRef.current.getBoundingClientRect(); - const dropdownWidth = 320; // sm:w-80 equivalent in px - const spaceOnRight = window.innerWidth - rect.right; - if (spaceOnRight < dropdownWidth) { - return { right: 'auto', left: '0' }; - } - return { right: '0', left: 'auto' }; - }; - const toggleRhythmDropdown = () => { - const newState = !dropdownOpen; - if (newState) { - setRhythmDropdownStyle(calculateDropdownPosition(rhythmGamesBtnRef)); - } - setDropdownOpen(newState); - }; - - const toggleOtherDropdown = () => { - const newState = !otherDropdownOpen; - if (newState) { - setOtherDropdownStyle(calculateDropdownPosition(otherGamesBtnRef)); - } - setOtherDropdownOpen(newState); - }; - - useEffect(() => { - const handleResize = () => { - if (dropdownOpen) { - setRhythmDropdownStyle(calculateDropdownPosition(rhythmGamesBtnRef)); - } - if (otherDropdownOpen) { - setOtherDropdownStyle(calculateDropdownPosition(otherGamesBtnRef)); - } - }; - - window.addEventListener('resize', handleResize); - return () => window.removeEventListener('resize', handleResize); - }, [dropdownOpen, otherDropdownOpen]); - - useEffect(() => { - const handleClickOutside = (event: MouseEvent) => { - if ( - dropdownRef.current && - !dropdownRef.current.contains(event.target as Node) - ) { - setDropdownOpen(false); - } - if ( - otherDropdownRef.current && - !otherDropdownRef.current.contains(event.target as Node) - ) { - setOtherDropdownOpen(false); - } - }; - if (dropdownOpen || otherDropdownOpen) - document.addEventListener("mousedown", handleClickOutside); - return () => - document.removeEventListener("mousedown", handleClickOutside); - }, [dropdownOpen, otherDropdownOpen]); - return (
{ to={`/${isMoe ? "?moe" : ""}`} className={`${isMoe ? "text-pink-800 hover:text-pink-600" : "text-gray-300 hover:text-white"} font-medium text-sm sm:text-base`} > - All Games + Main News Feed + + + Game Selector - -
- - - {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} - - ))} -
-
- ))} -
-
- )} -
- -
- - - {otherDropdownOpen && ( -
-
- {otherGames.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) => ( - setOtherDropdownOpen(false)} - > - {game.title} - - ))} -
-
- ))} -
-
- )} -
@@ -330,4 +96,4 @@ const TitleBar: React.FC = () => { ); }; -export default TitleBar +export default TitleBar; diff --git a/site/src/pages/GameSelector.tsx b/site/src/pages/GameSelector.tsx new file mode 100644 index 0000000..d9d5279 --- /dev/null +++ b/site/src/pages/GameSelector.tsx @@ -0,0 +1,99 @@ +import { Link, useSearchParams } from "react-router-dom"; +import TitleBar from "../components/TitleBar"; + +interface GameCategory { + name: string; + description: string; + games: { id: string; title: string }[]; +} + +const gameInfo: GameCategory[] = [ + { + name: "KONAMI", + description: "", + games: [ + { id: "iidx", title: "beatmania IIDX" }, + { id: "sdvx", title: "SOUND VOLTEX" }, + { id: "ddr", title: "DanceDanceRevolution" }, + { id: "jubeat", title: "jubeat" }, + { id: "popn_music", title: "pop'n music" }, + { id: "nostalgia", title: "NOSTALGIA" }, + { id: "gitadora", title: "GITADORA" }, + { id: "dance_rush", title: "DANCERUSH" }, + { id: "dance_around", title: "DANCE aROUND" }, + { id: "polaris_chord", title: "POLARIS CHORD" }, + ], + }, + { + name: "SEGA", + description: "", + games: [ + { id: "chunithm_jp", title: "CHUNITHM (JAPAN)" }, + { id: "chunithm_intl", title: "CHUNITHM (INTERNATIONAL)" }, + { id: "maimaidx_jp", title: "maimai DX (JAPAN)" }, + { id: "maimaidx_intl", title: "maimai DX (INTERNATIONAL)" }, + { id: "ongeki_jp", title: "O.N.G.E.K.I" }, + ], + }, + { + name: "TAITO", + description: "", + games: [{ id: "music_diver", title: "MUSIC DIVER" }], + }, + { + name: "BANDAI NAMCO", + description: "", + games: [{ id: "taiko", title: "Taiko no Tatsujin" }, { id: "wmmt", title: "WANGAN MIDNIGHT MAXIMUM TUNE" }], + }, + { + name: "COMMUNITY", + description: "Community-driven projects to continue the legacy of dead/abandoned rhythm games", + games: [ + { id: "wacca_plus", title: "WACCA PLUS" }, + { id: "museca_plus", title: "MÚSECA PLUS" }, + { id: "rb_deluxe_plus", title: "REFLEC BEAT DELUXE PLUS" }, + ], + }, +]; + +const GameSelector = () => { + const [searchParams] = useSearchParams(); + const isMoe = searchParams.has("moe"); + + const renderCategory = (category: GameCategory) => ( +
+

{category.name}

+

{category.description}

+
+ {category.games.map(game => ( + + {game.title} + + ))} +
+
+ ); + + return ( + <> + +
+
+

+ Select a Game +

+

+ Individual game feeds keep a longer history of news relating to that game than the main feed. +

+ {gameInfo.map(renderCategory)} +
+
+ + ); +}; + +export default GameSelector; -- cgit v1.2.3