From c6266d3fb7fa3f0fb2b33f4ef0d45ca32fb5745a Mon Sep 17 00:00:00 2001 From: rajun Date: Tue, 27 Oct 2026 16:28:58 +0530 Subject: [PATCH] refactor: rebuild root with toaster, model-viewer script and error screen --- app/root.tsx | 115 +++++++++++++++++++++------------------------------ 1 file changed, 47 insertions(+), 68 deletions(-) diff --git a/app/root.tsx b/app/root.tsx index 4f3b053..eedca86 100644 --- a/app/root.tsx +++ b/app/root.tsx @@ -1,80 +1,59 @@ -import { - isRouteErrorResponse, - Links, - Meta, - Outlet, - Scripts, - ScrollRestoration, -} from "react-router"; - -import type { Route } from "./+types/root"; -import "./app.css"; +import type { ReactNode } from 'react'; +import { isRouteErrorResponse, Links, Meta, Outlet, Scripts, ScrollRestoration } from 'react-router'; +import { AlertTriangle } from 'lucide-react'; +import { Toaster } from 'sonner'; +import type { Route } from './+types/root'; +import { Button } from '~/components/ui/button'; +import { StatusScreen } from '~/components/ui/status-screen'; +import { MODEL_VIEWER_SCRIPT_URL } from '~/data/brand'; +import './app.css'; export const links: Route.LinksFunction = () => [ - { rel: "icon", href: "/favicon.svg", type: "image/svg+xml" }, - { rel: "preconnect", href: "https://fonts.googleapis.com" }, - { - rel: "preconnect", - href: "https://fonts.gstatic.com", - crossOrigin: "anonymous", - }, - { - rel: "stylesheet", - href: "https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap", - }, + { rel: 'icon', href: '/favicon.svg', type: 'image/svg+xml' }, + { rel: 'preconnect', href: 'https://fonts.googleapis.com' }, + { rel: 'preconnect', href: 'https://fonts.gstatic.com', crossOrigin: 'anonymous' }, + { + rel: 'stylesheet', + href: 'https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=Geist+Mono:wght@400;500&display=swap', + }, ]; -import { Toaster } from "sonner"; - -export function Layout({ children }: { children: React.ReactNode }) { - return ( - - - - - - - - - - {children} - - - - - - ); +export function Layout({ children }: { children: ReactNode }) { + return ( + + + + + + + + + + {children} + + + + + + ); } export default function App() { - return ; + return ; } export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) { - let message = "Oops!"; - let details = "An unexpected error occurred."; - let stack: string | undefined; + const notFound = isRouteErrorResponse(error) && error.status === 404; + const stack = import.meta.env.DEV && error instanceof Error ? error.stack : undefined; - if (isRouteErrorResponse(error)) { - message = error.status === 404 ? "404" : "Error"; - details = - error.status === 404 - ? "The requested page could not be found." - : error.statusText || details; - } else if (import.meta.env.DEV && error && error instanceof Error) { - details = error.message; - stack = error.stack; - } - - return ( -
-

{message}

-

{details}

- {stack && ( -
-          {stack}
-        
- )} -
- ); + return ( + window.location.reload()}>Try again} + > + {stack &&
{stack}
} +
+ ); }