aethex-forge/client/components/PageTransition.tsx
Builder.io d89067bb67 completionId: cgen-73436182f1f24a2ea006514b70d0f8f8
cgen-73436182f1f24a2ea006514b70d0f8f8
2025-11-06 19:40:08 +00:00

49 lines
1.4 KiB
TypeScript

import { useEffect, useState } from "react";
import { useLocation } from "react-router-dom";
import LoadingScreen from "./LoadingScreen";
interface PageTransitionProps {
children: React.ReactNode;
}
const getArmMessage = (pathname: string): string => {
if (pathname.includes("/labs") || pathname.includes("/research")) {
return "Initializing Research Module...";
}
if (pathname.includes("/game-development")) {
return "Booting GameForge Engine...";
}
if (pathname.includes("/consulting")) {
return "Engaging Corp Systems...";
}
if (pathname.includes("/community")) {
return "Connecting Foundation Network...";
}
if (pathname.includes("/dev-link")) {
return "Loading Dev-Link Platform...";
}
return "Initializing AeThex OS...";
};
export default function PageTransition({ children }: PageTransitionProps) {
const [visible, setVisible] = useState(false);
const location = useLocation();
const message = getArmMessage(location.pathname);
useEffect(() => {
setVisible(false);
const id = requestAnimationFrame(() => setVisible(true));
return () => cancelAnimationFrame(id);
}, [location.pathname]);
return (
<>
{!visible && <LoadingScreen message={message} variant="overlay" />}
<div
className={`transition-opacity duration-300 ease-out transform-gpu will-change-[opacity] ${visible ? "opacity-100" : "opacity-0"}`}
>
{children}
</div>
</>
);
}