aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/packages/ui/src/pages/home-view.tsx
diff options
context:
space:
mode:
author苏向夜 <46275354+fu050409@users.noreply.github.com>2026-03-29 21:35:34 +0800
committerGitHub <noreply@github.com>2026-03-29 21:35:34 +0800
commit70348cefb7de8c1e044800296a99177309c5a81e (patch)
treeeb0fdfbcc880574e9b386a3f2fc9b3a89489e5b5 /packages/ui/src/pages/home-view.tsx
parentf2f5383a1b615a7493316d558dc55271198e772a (diff)
parent1c115141cc7b676e6a07786594155c3ac293fe34 (diff)
downloadDropOut-70348cefb7de8c1e044800296a99177309c5a81e.tar.gz
DropOut-70348cefb7de8c1e044800296a99177309c5a81e.zip
refactor(ui): full rewrite instance and code struct (#129)
## Summary by Sourcery Refactor the UI to modernize effect handling, routing, and legacy APIs while adding a reusable alert dialog component and cleaning up obsolete stores. New Features: - Introduce a shared SaturnEffect context via ParticleBackground so pages can access the effect without relying on global window APIs. - Add a Base UI–powered alert dialog component for consistent confirmation and warning flows across the app. - Define a central router configuration module with instance routes to standardize page wiring. Bug Fixes: - Ensure SaturnEffect nullish checks are handled safely when forwarding pointer and touch events from the home view. Enhancements: - Rewrite ParticleBackground to manage its own SaturnEffect lifecycle via React state and context instead of global accessors. - Update the home view to use the SaturnEffect hook, simplify pointer/touch handlers, and remove legacy game and release store usage. - Refine layout and accessibility attributes for various form field and label components, including field grouping and error rendering keys. - Simplify sidebar navigation and adjust the user dropdown trigger to work with the updated dropdown menu API. - Wrap the root outlet for the home route with ParticleBackground only on the index path to limit the effect to the intended view. - Clean up imports and code style in radio group and other UI primitives for consistency. Chores: - Remove deprecated UI stores and utility modules that are no longer used with the new architecture. - Add changeset entries documenting the Saturn effect refactor, ParticleBackground rewrite, and removal of legacy store code.
Diffstat (limited to 'packages/ui/src/pages/home-view.tsx')
-rw-r--r--packages/ui/src/pages/home-view.tsx174
1 files changed, 0 insertions, 174 deletions
diff --git a/packages/ui/src/pages/home-view.tsx b/packages/ui/src/pages/home-view.tsx
deleted file mode 100644
index 4f80cb0..0000000
--- a/packages/ui/src/pages/home-view.tsx
+++ /dev/null
@@ -1,174 +0,0 @@
-import { useEffect, useState } from "react";
-import { BottomBar } from "@/components/bottom-bar";
-import type { SaturnEffect } from "@/lib/effects/SaturnEffect";
-import { useGameStore } from "../stores/game-store";
-import { useReleasesStore } from "../stores/releases-store";
-
-export function HomeView() {
- const gameStore = useGameStore();
- const releasesStore = useReleasesStore();
- const [mouseX, setMouseX] = useState(0);
- const [mouseY, setMouseY] = useState(0);
-
- useEffect(() => {
- releasesStore.loadReleases();
- }, [releasesStore.loadReleases]);
-
- const handleMouseMove = (e: React.MouseEvent) => {
- const x = (e.clientX / window.innerWidth) * 2 - 1;
- const y = (e.clientY / window.innerHeight) * 2 - 1;
- setMouseX(x);
- setMouseY(y);
-
- // Forward mouse move to SaturnEffect (if available) for parallax/rotation interactions
- try {
- const saturn = (
- window as unknown as {
- getSaturnEffect?: () => SaturnEffect;
- }
- ).getSaturnEffect?.();
- if (saturn?.handleMouseMove) {
- saturn.handleMouseMove(e.clientX);
- }
- } catch {
- /* best-effort, ignore errors from effect */
- }
- };
-
- const handleSaturnMouseDown = (e: React.MouseEvent) => {
- try {
- const saturn = (window as any).getSaturnEffect?.();
- if (saturn?.handleMouseDown) {
- saturn.handleMouseDown(e.clientX);
- }
- } catch {
- /* ignore */
- }
- };
-
- const handleSaturnMouseUp = () => {
- try {
- const saturn = (window as any).getSaturnEffect?.();
- if (saturn?.handleMouseUp) {
- saturn.handleMouseUp();
- }
- } catch {
- /* ignore */
- }
- };
-
- const handleSaturnMouseLeave = () => {
- // Treat leaving the area as mouse-up for the effect
- try {
- const saturn = (window as any).getSaturnEffect?.();
- if (saturn?.handleMouseUp) {
- saturn.handleMouseUp();
- }
- } catch {
- /* ignore */
- }
- };
-
- const handleSaturnTouchStart = (e: React.TouchEvent) => {
- if (e.touches && e.touches.length === 1) {
- try {
- const clientX = e.touches[0].clientX;
- const saturn = (window as any).getSaturnEffect?.();
- if (saturn?.handleTouchStart) {
- saturn.handleTouchStart(clientX);
- }
- } catch {
- /* ignore */
- }
- }
- };
-
- const handleSaturnTouchMove = (e: React.TouchEvent) => {
- if (e.touches && e.touches.length === 1) {
- try {
- const clientX = e.touches[0].clientX;
- const saturn = (window as any).getSaturnEffect?.();
- if (saturn?.handleTouchMove) {
- saturn.handleTouchMove(clientX);
- }
- } catch {
- /* ignore */
- }
- }
- };
-
- const handleSaturnTouchEnd = () => {
- try {
- const saturn = (window as any).getSaturnEffect?.();
- if (saturn?.handleTouchEnd) {
- saturn.handleTouchEnd();
- }
- } catch {
- /* ignore */
- }
- };
-
- return (
- <div
- className="relative z-10 h-full overflow-y-auto custom-scrollbar scroll-smooth"
- style={{
- overflow: releasesStore.isLoading ? "hidden" : "auto",
- }}
- >
- {/* Hero Section (Full Height) - Interactive area */}
- <div
- role="tab"
- className="min-h-full flex flex-col justify-end p-12 pb-32 cursor-grab active:cursor-grabbing select-none"
- onMouseDown={handleSaturnMouseDown}
- onMouseMove={handleMouseMove}
- onMouseUp={handleSaturnMouseUp}
- onMouseLeave={handleSaturnMouseLeave}
- onTouchStart={handleSaturnTouchStart}
- onTouchMove={handleSaturnTouchMove}
- onTouchEnd={handleSaturnTouchEnd}
- tabIndex={0}
- >
- {/* 3D Floating Hero Text */}
- <div
- className="transition-transform duration-200 ease-out origin-bottom-left"
- style={{
- transform: `perspective(1000px) rotateX(${mouseY * -1}deg) rotateY(${mouseX * 1}deg)`,
- }}
- >
- <div className="flex items-center gap-3 mb-6">
- <div className="h-px w-12 bg-white/50"></div>
- <span className="text-xs font-mono font-bold tracking-[0.2em] text-white/50 uppercase">
- Launcher Active
- </span>
- </div>
-
- <h1 className="text-8xl font-black tracking-tighter text-white mb-6 leading-none">
- MINECRAFT
- </h1>
-
- <div className="flex items-center gap-4">
- <div className="bg-white/10 backdrop-blur-md border border-white/10 px-3 py-1 rounded-sm text-xs font-bold uppercase tracking-widest text-white shadow-sm">
- Java Edition
- </div>
- <div className="h-4 w-px bg-white/20"></div>
- <div className="text-sm text-zinc-400">
- Latest Release{" "}
- <span className="text-white font-medium">
- {gameStore.latestRelease?.id || "..."}
- </span>
- </div>
- </div>
- </div>
-
- {/* Action Area */}
- <div className="mt-8 flex gap-4">
- <div className="text-zinc-500 text-sm font-mono">
- &gt; Ready to launch session.
- </div>
- </div>
-
- <BottomBar />
- </div>
- </div>
- );
-}