headplane/app/root.tsx

70 lines
1.7 KiB
TypeScript
Raw Normal View History

2025-04-02 21:29:00 -04:00
import type { LinksFunction, MetaFunction } from 'react-router';
2025-01-28 16:06:41 -05:00
import {
Links,
Meta,
Outlet,
Scripts,
ScrollRestoration,
useNavigation,
} from 'react-router';
import '@fontsource-variable/inter';
2024-12-31 10:30:14 +05:30
import { ErrorPopup } from '~/components/Error';
2025-02-04 11:42:57 -05:00
import ProgressBar from '~/components/ProgressBar';
2025-01-28 16:06:41 -05:00
import ToastProvider from '~/components/ToastProvider';
2024-12-31 10:30:14 +05:30
import stylesheet from '~/tailwind.css?url';
import { LiveDataProvider } from '~/utils/live-data';
2025-01-28 16:06:41 -05:00
import { useToastQueue } from '~/utils/toast';
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 }) {
2025-01-28 16:06:41 -05:00
const toastQueue = useToastQueue();
// LiveDataProvider is wrapped at the top level since dialogs and things
// that control its state are usually open in portal containers which
// are not a part of the normal React tree.
2024-03-25 17:51:11 -04:00
return (
<LiveDataProvider>
<html lang="en">
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<Meta />
<Links />
</head>
<body className="overscroll-none dark:bg-headplane-900 dark:text-headplane-50">
{children}
<ToastProvider queue={toastQueue} />
<ScrollRestoration />
<Scripts />
</body>
</html>
</LiveDataProvider>
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 (
<>
2025-02-04 11:42:57 -05:00
<ProgressBar isVisible={nav.state === 'loading'} />
<Outlet />
</>
2025-01-28 16:06:41 -05:00
);
}