Files
Esiah-s-Universe/src/App.tsx
T
Esiah 8727eac300 Refactor scroll system, regions, layout and download flow
- Completely reworked `useRegionScroll` controller: paginated region-by-region scroll (wheel/swipe/arrows/Home/End/Space), native scroll neutralized, regions taller than viewport split into screens, time-based rAF animation, interruption only on effective deviation.
- Region resolution in 3 levels: `data-region` (single element), `data-region-children` (each direct child), `.page-snap-section` as fallback. Added `data-no-region` to exclude hero/title.
- Homepage: entire MagicBento as a single region. Projects page: one stop per project (`HorizontalMotion` with `data-region-children`), category title preserved, hero excluded.
- Project detail pages (ProjectPage): hero excluded from regions, media in `data-region-children`, download button as separate region.
- Contact/PageShell: updated markers, removed empty zones (no forced `min-height` on `.page-snap-section`).
- Removed unbounded `--region-tail` in favor of capped reserve (15vh) + merged landing spots too close to each other.
- Navigation: more reliable scroll-to-top, footer "Co Hai Se" bold with target cursor.
- ZIP download: stopped propagation + global click handler ignores download.
- Various fixes (cursor, 404, layouts), docs updated, typecheck/ignoreDeprecations adjusted.
2026-10-22 15:20:20 +02:00

158 lines
5.0 KiB
TypeScript

import { Suspense, lazy, useState, useEffect } from "react";
import {
BrowserRouter as Router,
Routes,
Route,
useLocation,
} from "react-router-dom";
import BackgroundWrapper from "./components/backgrounds/BackgroundWrapper";
import LoadingScreen from "./components/LoadingScreen";
import ScrollToTop from "./components/ScrollToTop";
import CardNav from "./components/CardNav";
import NotFound from "./components/NotFound";
import useRegionScroll from "./hooks/useRegionScroll";
const Home = lazy(() => import("./pages/Home"));
const Contact = lazy(() => import("./pages/Contact"));
const Projects = lazy(() => import("./pages/Projects"));
const Zatyshok = lazy(() => import("./pages/projects/Zatyshok"));
const EnsembleScolaireJeanXXIII = lazy(
() => import("./pages/projects/EnsembleScolaireJeanXXIII"),
);
const NeoTokyoRush = lazy(() => import("./pages/projects/NeoTokyoRush"));
const Hinterraum = lazy(() => import("./pages/projects/Hinterraum"));
const OverclockUprising = lazy(
() => import("./pages/projects/OverclockUprising"),
);
const EchoesOfTheLastStop = lazy(
() => import("./pages/projects/EchoesOfTheLastStop"),
);
const ShadowPurgeRiteOfTheDemon = lazy(
() => import("./pages/projects/ShadowPurgeRiteOfTheDemon"),
);
const LesVoixDeLExil = lazy(() => import("./pages/projects/LesVoixDeLExil"));
const WYGTIWIF = lazy(() => import("./pages/projects/WYG-TIWIF"));
function AppContent() {
const location = useLocation();
const [isPageLoading, setIsPageLoading] = useState(false);
const immersivePages = ["/projects/les-voix-de-l-exil"];
const isImmersive = immersivePages.includes(location.pathname);
useEffect(() => {
document.documentElement.classList.toggle("no-snap", isImmersive);
}, [isImmersive]);
useRegionScroll();
useEffect(() => {
const handleGlobalClick = (e: MouseEvent) => {
const el = e.target as HTMLElement;
const target = el.closest("a, button") as HTMLElement | null;
if (!target) return;
if (target.hasAttribute("download")) return;
if (target.tagName === "BUTTON") {
// vérifie si c'est le bouton download
if (target.textContent?.includes("Download")) return;
}
const anchor = target.tagName === "A" ? (target as HTMLAnchorElement) : null;
if (anchor) {
if (!anchor.href) return;
if (anchor.href.match(/\.(zip|exe|rar|7z|msi|dmg|apk|pdf)(\?|$)/i)) return;
if (anchor.target === "_blank") return;
if (anchor.origin !== window.location.origin) return;
if (e.ctrlKey || e.metaKey) return;
if (anchor.href.startsWith("mailto:") || anchor.href.startsWith("tel:")) return;
const currentPath = window.location.pathname;
const targetPath = new URL(anchor.href).pathname;
if (currentPath !== targetPath) {
setIsPageLoading(true);
}
}
};
document.addEventListener("click", handleGlobalClick);
return () => document.removeEventListener("click", handleGlobalClick);
}, []);
useEffect(() => {
setIsPageLoading(true);
const timer = setTimeout(() => {
setIsPageLoading(false);
}, 600);
return () => clearTimeout(timer);
}, [location.pathname]);
return (
<>
{isPageLoading && <LoadingScreen />}
<ScrollToTop />
{!isImmersive && <BackgroundWrapper />}
<CardNav />
<main>
<Suspense fallback={<LoadingScreen />}>
<Routes>
<Route path="/" element={<Home />} />
<Route path="/contact" element={<Contact />} />
<Route path="/projects" element={<Projects />} />
<Route path="/projects/neo-tokyo-rush" element={<NeoTokyoRush />} />
<Route path="/projects/hinterraum" element={<Hinterraum />} />
<Route
path="/projects/overclock-uprising"
element={<OverclockUprising />}
/>
<Route
path="/projects/echoes-of-the-last-stop"
element={<EchoesOfTheLastStop />}
/>
<Route
path="/projects/shadow-purge-rite-of-the-demon"
element={<ShadowPurgeRiteOfTheDemon />}
/>
<Route path="/projects/zatyshok" element={<Zatyshok />} />
<Route path="/projects/wyg-tiwif" element={<WYGTIWIF />} />
<Route
path="/projects/ensemble-scolaire-jean-xxiii"
element={<EnsembleScolaireJeanXXIII />}
/>
<Route
path="/projects/les-voix-de-l-exil"
element={<LesVoixDeLExil />}
/>
<Route path="*" element={<NotFound />} />
</Routes>
</Suspense>
</main>
{!isImmersive && (
<footer>
<p>
© 2026 -{" "}
<a className="cursor-target font-bold" href="https://cohaise.dev">
Co Hai Se
</a>{" "}
| All rights reserved.
</p>
</footer>
)}
</>
);
}
function App() {
return (
<Router>
<AppContent />
</Router>
);
}
export default App;