flagon-io/g1t

public

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t/apps/sudo/app/root.tsx

73 lines2,712 bytesCodeBlame
1import { isRouteErrorResponse, Links, Meta, Outlet, useRouteLoaderData } from "react-router";
2
3import type { Route } from "./+types/root";
4import "./app.css";
5import displayFont from "@g1t/theme/fonts/bricolage-grotesque-latin.woff2?url";
6import sansFont from "@g1t/theme/fonts/hanken-grotesk-latin.woff2?url";
7import { MobileBar, Sidebar } from "./components/shell";
8import { ButtonLink } from "./components/ui";
9import { requireStaff } from "./lib/staff";
10
11export const links: Route.LinksFunction = () => [
12 { rel: "icon", type: "image/svg+xml", href: "/favicon.svg" },
13 // The faces are served by sudo itself (@g1t/theme); these two are on every page.
14 { rel: "preload", href: sansFont, as: "font", type: "font/woff2", crossOrigin: "anonymous" },
15 { rel: "preload", href: displayFont, as: "font", type: "font/woff2", crossOrigin: "anonymous" },
16];
17
18export const meta: Route.MetaFunction = () => [
19 { title: "sudo · g1t" },
20 { name: "robots", content: "noindex, nofollow" },
21];
22
23export async function loader({ context }: Route.LoaderArgs) {
24 return { email: requireStaff(context).email };
25}
26
27export function Layout({ children }: { children: React.ReactNode }) {
28 const root = useRouteLoaderData<typeof loader>("root");
29 return (
30 <html lang="en">
31 <head>
32 <meta charSet="utf-8" />
33 <meta name="viewport" content="width=device-width, initial-scale=1" />
34 <meta name="theme-color" content="#0f0f11" />
35 <Meta />
36 <Links />
37 </head>
38 <body className="min-h-screen">
39 <Sidebar email={root?.email} />
40 <MobileBar email={root?.email} />
41 <div className="lg:pl-60">{children}</div>
42 {/* No <Scripts />: sudo ships no JavaScript, and its policy allows none. */}
43 </body>
44 </html>
45 );
46}
47
48export default function App() {
49 return <Outlet />;
50}
51
52export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) {
53 let title = "Something went wrong";
54 let details = "An unexpected error occurred.";
55 if (isRouteErrorResponse(error)) {
56 title = error.status === 404 ? "Not found" : `Error ${error.status}`;
57 details = typeof error.data === "string" && error.data ? error.data : error.statusText || details;
58 } else if (error instanceof Error) {
59 // Staff only: the real reason helps more than a polite one.
60 details = error.message;
61 }
62 return (
63 <main className="mx-auto max-w-xl px-4 py-24 text-center">
64 <h1 className="text-2xl font-semibold tracking-tight">{title}</h1>
65 <p className="mt-3 break-words text-muted">{details}</p>
66 <div className="mt-8">
67 <ButtonLink to="/" variant="quiet">
68 Back to the overview
69 </ButtonLink>
70 </div>
71 </main>
72 );
73}