add loading page

This commit is contained in:
2026-06-11 15:06:13 +02:00
parent 98a5bb742b
commit f4b9820b5b
6 changed files with 47 additions and 7 deletions
+34
View File
@@ -0,0 +1,34 @@
interface IProps {
title?: string;
description?: string;
}
const LoadingView = ({ title, description }: IProps) => {
return (
<div className="flex min-h-[calc(100vh-194px)] flex-col items-center justify-center p-6 bg-base-100">
<div className="relative flex max-w-sm flex-col items-center text-center">
{/* Animated Custom Loader */}
<div className="relative mb-6 flex h-16 w-16 items-center justify-center">
{/* Outer Pulsing Ring */}
<div className="absolute inset-0 animate-ping rounded-full bg-(--accent) opacity-20 [animation-duration:1.5s]"></div>
{/* Inner Spinning Ring */}
<div className="h-12 w-12 animate-spin rounded-full border-4 border-(--accent) border-t-transparent"></div>
</div>
{/* Loading Content */}
<h2 className="text-xl font-bold tracking-tight mb-2 text-(--base-content)">
{title || "Loading Data"}
</h2>
<p className="text-sm text-(--neutral-content) max-w-xs">
{description || "Please wait a moment while we load the data."}
</p>
{/* Decorative background glow matching your layout */}
<div className="absolute -inset-10 -z-10 bg-(--accent)/5 blur-2xl rounded-full pointer-events-none" />
</div>
</div>
);
};
export default LoadingView;
+6 -4
View File
@@ -1,4 +1,6 @@
import { getRouteApi, useNavigate } from "@tanstack/react-router";
import GenericErrorView from "#/components/GenericErrorView.tsx";
import LoadingView from "#/components/LoadingView.tsx";
import { useLichess } from "#/hooks/useLichess.ts";
const routeApi = getRouteApi("/callback");
@@ -11,11 +13,11 @@ const Callback = () => {
if (status === "success") navigate({ to: "/chessboard" });
if (status === "error") {
console.error(error);
}
if (status === "error") return <GenericErrorView error={error} />;
return <div>Loading...</div>;
return (
<LoadingView title="Logging in..." description="Please wait a moment..." />
);
};
export default Callback;
+3 -1
View File
@@ -3,7 +3,8 @@ import { createRootRoute, HeadContent, Scripts } from "@tanstack/react-router";
import { TanStackRouterDevtoolsPanel } from "@tanstack/react-router-devtools";
import { type ReactNode, Suspense } from "react";
import { ToastContainer } from "react-toastify";
import GenericErrorView from "#/components/Error/GenericErrorView.tsx";
import GenericErrorView from "#/components/GenericErrorView.tsx";
import LoadingView from "#/components/LoadingView.tsx";
import { MatomoAnalytics } from "#/components/MatomoAnalytics.tsx";
import { LichessUserProvider } from "#/context/LichessUserContext.tsx";
import Footer from "../components/Footer";
@@ -45,6 +46,7 @@ export const Route = createRootRoute({
}),
shellComponent: RootDocument,
errorComponent: ({ error }) => <GenericErrorView error={error} />,
pendingComponent: () => <LoadingView />,
});
function RootDocument({ children }: { children: ReactNode }) {
+1 -1
View File
@@ -1,6 +1,6 @@
import { createFileRoute, notFound } from "@tanstack/react-router";
import { z } from "zod";
import GenericErrorView from "#/components/Error/GenericErrorView.tsx";
import GenericErrorView from "#/components/GenericErrorView.tsx";
import Callback from "#/pages/Callback.tsx";
const callbackSchema = z.object({