headplane/app/root.tsx

66 lines
1.6 KiB
TypeScript
Raw Normal View History

import type { LoaderFunctionArgs, LinksFunction, MetaFunction } from 'react-router';
import { Links, Meta, Outlet, Scripts, ScrollRestoration, useNavigation } from 'react-router';
import { loadContext } from '~/utils/config/headplane';
import '@fontsource-variable/inter'
2024-03-25 17:51:11 -04:00
import { ProgressBar } from 'react-aria-components';
2024-12-31 10:30:14 +05:30
import { ErrorPopup } from '~/components/Error';
// TODO: Make this a default export
2024-12-31 10:30:14 +05:30
import { Toaster } from '~/components/Toaster';
import stylesheet from '~/tailwind.css?url';
import { cn } from '~/utils/cn';
2024-03-25 17:51:11 -04:00
export const meta: MetaFunction = () => [
{ title: 'Headplane' },
2024-12-31 10:30:14 +05:30
{
name: 'description',
content: 'A frontend for the headscale coordination server',
},
];
2024-03-25 17:51:11 -04:00
export const links: LinksFunction = () => [
{ rel: 'stylesheet', href: stylesheet },
2024-12-31 10:30:14 +05:30
];
2024-03-25 17:51:11 -04:00
export function Layout({ children }: { readonly children: React.ReactNode }) {
return (
<html lang="en">
2024-03-25 17:51:11 -04:00
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<Meta />
<Links />
2024-03-25 17:51:11 -04:00
</head>
<body className="overscroll-none dark:bg-headplane-900 dark:text-headplane-50">
2024-03-25 17:51:11 -04:00
{children}
<Toaster />
<ScrollRestoration />
<Scripts />
2024-03-25 17:51:11 -04:00
</body>
</html>
2024-12-31 10:30:14 +05:30
);
2024-03-25 17:51:11 -04:00
}
export function ErrorBoundary() {
2024-12-31 10:30:14 +05:30
return <ErrorPopup />;
}
export default function App() {
const nav = useNavigation();
return (
<>
<ProgressBar aria-label="Loading...">
<div
className={cn(
'fixed top-0 left-0 z-50 w-1/2 h-1',
'bg-blue-500 dark:bg-blue-400 opacity-0',
nav.state === 'loading' && 'animate-loading opacity-100',
)}
/>
</ProgressBar>
<Outlet />
</>
)
}