Skip to content

Commit

Not found and error pages have one main landmark: their own when signed out, the shell's when signed in

syntaqxcommitted Parent72b183bBrowse files
4 files+22−70/4 viewed
+12−0
1+import { type ComponentProps, createContext, useContext } from "react";
2+
3+/** True inside the app shell, whose `<main id="content">` already holds the page. */
4+export const InMain = createContext(false);
5+
6+/**
7+ * A page's main landmark: `<main>` where nothing above is one (signed out),
8+ * a plain `<div>` inside the shell, so a page never has two.
9+ */
10+export function PageMain(props: ComponentProps<"main">) {
11+ return useContext(InMain) ? <div {...props} /> : <main {...props} />;
12+}
+3−2
55 import { withNext } from "../lib/next";
66 import { useSignUpCopy } from "../lib/registration";
77 import { missingKind, notFoundCopy } from "../lib/not-found";
8+import { PageMain } from "./landmark";
89 import { Pixel404 } from "./logo";
910 import { ButtonLink, SubmitButton } from "./ui";
1011
2930 const here = pathname + search;
3031 const signUp = useSignUpCopy();
3132 return (
32− <main className="mx-auto flex max-w-lg flex-col items-center px-4 py-20 text-center sm:py-28">
33+ <PageMain className="mx-auto flex max-w-lg flex-col items-center px-4 py-20 text-center sm:py-28">
3334 <Pixel404 className="text-[3.5rem] sm:text-[4.5rem]" />
3435 <h1 className="mt-10 text-balance text-2xl font-semibold tracking-tight">{copy.title}</h1>
3536 <p className="mt-2 text-balance text-muted">{copy.body}</p>
8283 </SubmitButton>
8384 </Form>
8485 )}
85− </main>
86+ </PageMain>
8687 );
8788 }
+2−1
44
55 import { type Abilities, type InboxCounts, type Membership, type Spike, type User, mayCreateTeams } from "@g1t/contracts";
66
7+import { InMain } from "./landmark";
78 import { CommandPalette, type PaletteCommand, PaletteKey, usePaletteShortcut } from "./command-palette";
89 import { AgentButton, InboxBell } from "./inbox";
910 import { PinButton } from "./pin-button";
19151916 </header>
19161917 {banner}
19171918 <main id="content" tabIndex={-1} {...leaving} className={`min-w-0 grow outline-none ${leaving.className}`}>
1918− {children}
1919+ <InMain.Provider value={true}>{children}</InMain.Provider>
19191920 </main>
19201921 </div>
19211922 <CommandPalette
+5−4
5353 import { PolicyNotice } from "./components/policy-notice";
5454 import { readCookie } from "./lib/mission";
5555 import { WORKSPACE_COOKIE, workspaceFor } from "./lib/workspace-choice";
56+import { PageMain } from "./components/landmark";
5657 import { NotFound } from "./components/not-found";
5758 import { usesAppShell } from "./lib/chrome";
5859 import { CommandPalette, type PaletteCommand, PaletteKey, usePaletteShortcut } from "./components/command-palette";
578579 }, [reload, href]);
579580 if (reload) {
580581 return (
581− <main className="mx-auto max-w-xl px-4 py-32 text-center text-sm text-muted" aria-busy="true">
582+ <PageMain className="mx-auto max-w-xl px-4 py-32 text-center text-sm text-muted" aria-busy="true">
582583 <title>Loading · g1t</title>
583584 Loading the latest version of g1t…
584− </main>
585+ </PageMain>
585586 );
586587 }
587588
608609 }
609610
610611 return (
611− <main className="mx-auto max-w-xl px-4 py-32 text-center">
612+ <PageMain className="mx-auto max-w-xl px-4 py-32 text-center">
612613 <h1 className="text-2xl font-semibold tracking-tight">{title}</h1>
613614 <p className="mt-3 text-muted">{details}</p>
614615 <div className="mt-8">
621622 <code>{stack}</code>
622623 </pre>
623624 )}
624− </main>
625+ </PageMain>
625626 );
626627 }