From 1dd8ea3bad22a0cb5cb28ad8f1d2e3ea12bf5db0 Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Sun, 20 Apr 2025 00:20:02 -0700 Subject: add light/moe theme loading screen --- site/src/pages/Homepage.tsx | 180 ++++++++++++++++++++++++++------------------ 1 file changed, 108 insertions(+), 72 deletions(-) diff --git a/site/src/pages/Homepage.tsx b/site/src/pages/Homepage.tsx index 6db2748..a3247cc 100644 --- a/site/src/pages/Homepage.tsx +++ b/site/src/pages/Homepage.tsx @@ -5,86 +5,122 @@ import { getGameTitle } from "../utils.ts"; import TitleBar from "../components/TitleBar"; import { GameNotes } from "../components/GameNotes"; - interface ArcadeNewsAPIData { - fetch_time: number; - news_posts: Array; + fetch_time: number; + news_posts: Array; } export default function Home() { - const { gameId } = useParams<{ gameId?: string }>(); - const [searchParams] = useSearchParams(); - const isMoe = searchParams.has("moe"); - - const [newsFeedData, setNewsFeedData] = useState(null); - const [loading, setLoading] = useState(true); + const { gameId } = useParams<{ gameId?: string }>(); + const [searchParams] = useSearchParams(); + const isMoe = searchParams.has("moe"); - useEffect(() => { - const fetchNews = async () => { - setLoading(true); - const jsonFile = gameId ? `${gameId}_news.json` : "news.json"; - try { - const response = await fetch("https://arcade-news.pinapelz.com/"+`${jsonFile}`); - if (!response.ok) { - throw new Error(`Failed to fetch news: ${response.statusText}`); - } - const data: ArcadeNewsAPIData = await response.json(); - setNewsFeedData(data); - } catch (e) { - console.error(e); - } finally { - setLoading(false); - } - }; - fetchNews(); - }, [gameId]); // Re-fetch when gameId changes + const [newsFeedData, setNewsFeedData] = useState( + null, + ); + const [loading, setLoading] = useState(true); - if (loading || newsFeedData === null) { - return ( - <> - -
-
-
- + useEffect(() => { + const fetchNews = async () => { + setLoading(true); + const jsonFile = gameId ? `${gameId}_news.json` : "news.json"; + try { + const response = await fetch( + "https://arcade-news.pinapelz.com/" + `${jsonFile}`, ); - } + if (!response.ok) { + throw new Error(`Failed to fetch news: ${response.statusText}`); + } + const data: ArcadeNewsAPIData = await response.json(); + setNewsFeedData(data); + } catch (e) { + console.error(e); + } finally { + setLoading(false); + } + }; + fetchNews(); + }, [gameId]); // Re-fetch when gameId changes + if (loading || newsFeedData === null) { return ( - <> - -
-
- {gameId ? ( -
-

- {getGameTitle(gameId)} News -

- {GameNotes(isMoe)[gameId] &&
{GameNotes(isMoe)[gameId]}
} -
- ) : ( -
-

Welcome to 573-UPDATES

-
- -
-

News and Information for various arcade games is aggregated here!

-

- Please see the{" "} - - GitHub - {" "} - for API information -

-
- )} - -
-
-

Last updated: {new Date(newsFeedData.fetch_time * 1000).toLocaleString()}

-

a moekyun service

-
-
- + <> + +
+
+
+ ); + } + + return ( + <> + +
+
+ {gameId ? ( +
+

+ {getGameTitle(gameId)} News +

+ {GameNotes(isMoe)[gameId] && ( +
{GameNotes(isMoe)[gameId]}
+ )} +
+ ) : ( +
+

Welcome to 573-UPDATES

+
+ +
+

+ News and Information for various arcade games is aggregated + here! +

+

+ Please see the{" "} + + GitHub + {" "} + for API information +

+
+ )} + +
+ +
+ + ); } -- cgit v1.2.3