refactor(web): share standalone page layout (#12354)

This commit is contained in:
Julius Marminge authored and GitHub committed 2026-09-17 20:26:01 -07:00
1 parent 58fcae64ae
commit fa2decfce7
4 files changed
+194 -170

No files matched your search

@@ -2,22 +2,18 @@ import type { ReactNode } from "react";
import { APP_DISPLAY_NAME, APP_STAGE_LABEL } from "../../branding";
import { resolveSidebarStageBackdropVariant, StageBackdropArt } from "../SidebarStageBackdrop";
import { StandalonePage } from "../ui/standalone-page";
/**
* Full-screen card for standalone auth pages, mirroring the pairing surface's
* treatment. Used by the CLI-connect authorize and callback surfaces.
* Branded masthead for the CLI-connect authorize and callback pages.
*/
export function AuthSurfaceShell({ children }: { readonly children: ReactNode }) {
const stageVariant = resolveSidebarStageBackdropVariant(APP_STAGE_LABEL);
return (
<div className="relative flex min-h-screen items-center justify-center overflow-hidden bg-background px-4 py-10 text-foreground sm:px-6">
<div className="pointer-events-none absolute inset-0 opacity-80">
<div className="absolute inset-x-0 top-0 h-72 bg-[radial-gradient(48rem_20rem_at_top,color-mix(in_srgb,var(--color-blue-500)_12%,transparent),transparent)]" />
<div className="absolute inset-0 bg-[linear-gradient(145deg,color-mix(in_srgb,var(--background)_94%,var(--color-black))_0%,var(--background)_62%)]" />
</div>
<section className="relative w-full max-w-xl overflow-hidden rounded-2xl border border-border/80 bg-card/94 shadow-2xl shadow-black/20 backdrop-blur-md">
<StandalonePage
tone="brand"
masthead={
<header className="relative h-24 overflow-hidden bg-[linear-gradient(135deg,#1e61de,#17348e)] text-white">
{stageVariant ? (
<div className="absolute inset-0" aria-hidden>
@@ -36,9 +32,9 @@ export function AuthSurfaceShell({ children }: { readonly children: ReactNode })
</p>
</div>
</header>
<div className="p-6 sm:p-8">{children}</div>
</section>
</div>
}
>
{children}
</StandalonePage>
);
}
@@ -12,29 +12,18 @@ import {
import { readHostedPairingRequest } from "../../hostedPairing";
import { Button } from "../ui/button";
import { Input } from "../ui/input";
import { StandalonePage, StandalonePageHeader } from "../ui/standalone-page";
import { useAtomCommand } from "../../state/use-atom-command";
export function PairingPendingSurface() {
return (
<div className="relative flex min-h-screen items-center justify-center overflow-hidden bg-background px-4 py-10 text-foreground sm:px-6">
<div className="pointer-events-none absolute inset-0 opacity-80">
<div className="absolute inset-x-0 top-0 h-44 bg-[radial-gradient(44rem_16rem_at_top,color-mix(in_srgb,var(--color-emerald-500)_14%,transparent),transparent)]" />
<div className="absolute inset-y-0 left-0 w-72 bg-[radial-gradient(28rem_18rem_at_left,color-mix(in_srgb,var(--color-sky-500)_10%,transparent),transparent)]" />
<div className="absolute inset-0 bg-[linear-gradient(145deg,color-mix(in_srgb,var(--background)_90%,var(--color-black))_0%,var(--background)_55%)]" />
</div>
<section className="relative w-full max-w-xl rounded-2xl border border-border/80 bg-card/90 p-6 shadow-2xl shadow-black/20 backdrop-blur-md sm:p-8">
<p className="text-[11px] font-semibold tracking-[0.18em] text-muted-foreground uppercase">
{APP_DISPLAY_NAME}
</p>
<h1 className="mt-3 text-2xl font-semibold tracking-tight sm:text-3xl">
Pairing with this environment
</h1>
<p className="mt-2 text-sm leading-relaxed text-muted-foreground">
Validating the pairing link and preparing your session.
</p>
</section>
</div>
<StandalonePage tone="pairing">
<StandalonePageHeader
eyebrow={APP_DISPLAY_NAME}
title="Pairing with this environment"
description="Validating the pairing link and preparing your session."
/>
</StandalonePage>
);
}
@@ -97,69 +86,57 @@ export function PairingRouteSurface({
}, [submitCredential]);
return (
<div className="relative flex min-h-screen items-center justify-center overflow-hidden bg-background px-4 py-10 text-foreground sm:px-6">
<div className="pointer-events-none absolute inset-0 opacity-80">
<div className="absolute inset-x-0 top-0 h-44 bg-[radial-gradient(44rem_16rem_at_top,color-mix(in_srgb,var(--color-emerald-500)_14%,transparent),transparent)]" />
<div className="absolute inset-y-0 left-0 w-72 bg-[radial-gradient(28rem_18rem_at_left,color-mix(in_srgb,var(--color-sky-500)_10%,transparent),transparent)]" />
<div className="absolute inset-0 bg-[linear-gradient(145deg,color-mix(in_srgb,var(--background)_90%,var(--color-black))_0%,var(--background)_55%)]" />
</div>
<StandalonePage tone="pairing">
<StandalonePageHeader
eyebrow={APP_DISPLAY_NAME}
title="Pair with this environment"
description={describeAuthGate(auth.bootstrapMethods)}
/>
<section className="relative w-full max-w-xl rounded-2xl border border-border/80 bg-card/90 p-6 shadow-2xl shadow-black/20 backdrop-blur-md sm:p-8">
<p className="text-[11px] font-semibold tracking-[0.18em] text-muted-foreground uppercase">
{APP_DISPLAY_NAME}
</p>
<h1 className="mt-3 text-2xl font-semibold tracking-tight sm:text-3xl">
Pair with this environment
</h1>
<p className="mt-2 text-sm leading-relaxed text-muted-foreground">
{describeAuthGate(auth.bootstrapMethods)}
</p>
<form className="mt-6 space-y-4" onSubmit={(event) => void handleSubmit(event)}>
<div className="space-y-2">
<label className="text-sm font-medium" htmlFor="pairing-token">
Pairing token
</label>
<Input
id="pairing-token"
autoCapitalize="none"
autoComplete="off"
autoCorrect="off"
disabled={isSubmitting}
nativeInput
onChange={(event) => setCredential(event.currentTarget.value)}
placeholder="Paste a one-time token or pairing secret"
spellCheck={false}
value={credential}
/>
</div>
{errorMessage ? (
<div className="rounded-lg border border-destructive/30 bg-destructive/6 px-3 py-2 text-sm text-destructive">
{errorMessage}
</div>
) : null}
<div className="flex flex-wrap gap-2">
<Button disabled={isSubmitting} size="sm" type="submit">
{isSubmitting ? "Pairing..." : "Continue"}
</Button>
<Button
disabled={isSubmitting}
onClick={() => window.location.reload()}
size="sm"
variant="outline"
>
Reload app
</Button>
</div>
</form>
<div className="mt-6 rounded-lg border border-border/70 bg-background/55 px-3 py-3 text-xs leading-relaxed text-muted-foreground">
{describeSupportedMethods(auth.bootstrapMethods)}
<form className="mt-6 space-y-4" onSubmit={(event) => void handleSubmit(event)}>
<div className="space-y-2">
<label className="text-sm font-medium" htmlFor="pairing-token">
Pairing token
</label>
<Input
id="pairing-token"
autoCapitalize="none"
autoComplete="off"
autoCorrect="off"
disabled={isSubmitting}
nativeInput
onChange={(event) => setCredential(event.currentTarget.value)}
placeholder="Paste a one-time token or pairing secret"
spellCheck={false}
value={credential}
/>
</div>
</section>
</div>
{errorMessage ? (
<div className="rounded-lg border border-destructive/30 bg-destructive/6 px-3 py-2 text-sm text-destructive">
{errorMessage}
</div>
) : null}
<div className="flex flex-wrap gap-2">
<Button disabled={isSubmitting} size="sm" type="submit">
{isSubmitting ? "Pairing..." : "Continue"}
</Button>
<Button
disabled={isSubmitting}
onClick={() => window.location.reload()}
size="sm"
variant="outline"
>
Reload app
</Button>
</div>
</form>
<div className="mt-6 rounded-lg border border-border/70 bg-background/55 px-3 py-3 text-xs leading-relaxed text-muted-foreground">
{describeSupportedMethods(auth.bootstrapMethods)}
</div>
</StandalonePage>
);
}
@@ -233,57 +210,49 @@ export function HostedPairingRouteSurface() {
const request = hostedPairingRequestRef.current;
return (
<div className="relative flex min-h-screen items-center justify-center overflow-hidden bg-background px-4 py-10 text-foreground sm:px-6">
<div className="pointer-events-none absolute inset-0 opacity-80">
<div className="absolute inset-x-0 top-0 h-44 bg-[radial-gradient(44rem_16rem_at_top,color-mix(in_srgb,var(--color-emerald-500)_14%,transparent),transparent)]" />
<div className="absolute inset-y-0 left-0 w-72 bg-[radial-gradient(28rem_18rem_at_left,color-mix(in_srgb,var(--color-sky-500)_10%,transparent),transparent)]" />
<div className="absolute inset-0 bg-[linear-gradient(145deg,color-mix(in_srgb,var(--background)_90%,var(--color-black))_0%,var(--background)_55%)]" />
</div>
<section className="relative w-full max-w-xl rounded-2xl border border-border/80 bg-card/90 p-6 shadow-2xl shadow-black/20 backdrop-blur-md sm:p-8">
<p className="text-[11px] font-semibold tracking-[0.18em] text-muted-foreground uppercase">
{APP_DISPLAY_NAME}
</p>
<h1 className="mt-3 text-2xl font-semibold tracking-tight sm:text-3xl">
{status === "paired"
<StandalonePage tone="pairing">
<StandalonePageHeader
eyebrow={APP_DISPLAY_NAME}
title={
status === "paired"
? "Backend paired"
: status === "error"
? "Pairing failed"
: "Pairing backend"}
</h1>
<p className="mt-2 text-sm leading-relaxed text-muted-foreground">{message}</p>
: "Pairing backend"
}
description={message}
/>
{request ? (
<div className="mt-5 rounded-lg border border-border/70 bg-background/55 px-3 py-3 text-xs leading-relaxed text-muted-foreground">
Host: <span className="font-mono text-foreground/80">{request.host}</span>
</div>
) : null}
{status === "error" ? (
<div className="mt-5 rounded-lg border border-destructive/30 bg-destructive/6 px-3 py-2 text-sm text-destructive">
Verify the backend is reachable from this browser, supports CORS for hosted clients, and
is served over HTTPS when opening this page from HTTPS.
</div>
) : null}
<div className="mt-6 flex flex-wrap gap-2">
{status === "pairing" ? (
<Button disabled size="sm">
Pairing...
</Button>
) : canRetry ? (
<Button size="sm" onClick={() => void submitHostedPairingRequest()}>
Try again
</Button>
) : null}
{status === "paired" ? (
<Button size="sm" variant="outline" onClick={() => (window.location.href = "/")}>
Open app
</Button>
) : null}
{request ? (
<div className="mt-5 rounded-lg border border-border/70 bg-background/55 px-3 py-3 text-xs leading-relaxed text-muted-foreground">
Host: <span className="font-mono text-foreground/80">{request.host}</span>
</div>
</section>
</div>
) : null}
{status === "error" ? (
<div className="mt-5 rounded-lg border border-destructive/30 bg-destructive/6 px-3 py-2 text-sm text-destructive">
Verify the backend is reachable from this browser, supports CORS for hosted clients, and
is served over HTTPS when opening this page from HTTPS.
</div>
) : null}
<div className="mt-6 flex flex-wrap gap-2">
{status === "pairing" ? (
<Button disabled size="sm">
Pairing...
</Button>
) : canRetry ? (
<Button size="sm" onClick={() => void submitHostedPairingRequest()}>
Try again
</Button>
) : null}
{status === "paired" ? (
<Button size="sm" variant="outline" onClick={() => (window.location.href = "/")}>
Open app
</Button>
) : null}
</div>
</StandalonePage>
);
}
@@ -0,0 +1,67 @@
import type { ReactNode } from "react";
const backdropClassNames = {
pairing:
"absolute inset-x-0 top-0 h-44 bg-[radial-gradient(44rem_16rem_at_top,color-mix(in_srgb,var(--color-emerald-500)_14%,transparent),transparent)]",
error:
"absolute inset-x-0 top-0 h-44 bg-[radial-gradient(44rem_16rem_at_top,color-mix(in_srgb,var(--color-red-500)_16%,transparent),transparent)]",
brand:
"absolute inset-x-0 top-0 h-72 bg-[radial-gradient(48rem_20rem_at_top,color-mix(in_srgb,var(--color-blue-500)_12%,transparent),transparent)]",
};
/** Shared page and card geometry for entry points outside the app shell. */
export function StandalonePage({
tone,
masthead,
children,
}: {
readonly tone: keyof typeof backdropClassNames;
readonly masthead?: ReactNode;
readonly children: ReactNode;
}) {
return (
<div className="relative flex min-h-screen items-center justify-center overflow-hidden bg-background px-4 py-10 text-foreground sm:px-6">
<div className="pointer-events-none absolute inset-0 opacity-80" aria-hidden>
<div className={backdropClassNames[tone]} />
{tone === "pairing" ? (
<div className="absolute inset-y-0 left-0 w-72 bg-[radial-gradient(28rem_18rem_at_left,color-mix(in_srgb,var(--color-sky-500)_10%,transparent),transparent)]" />
) : null}
<div
className={
tone === "brand"
? "absolute inset-0 bg-[linear-gradient(145deg,color-mix(in_srgb,var(--background)_94%,var(--color-black))_0%,var(--background)_62%)]"
: "absolute inset-0 bg-[linear-gradient(145deg,color-mix(in_srgb,var(--background)_90%,var(--color-black))_0%,var(--background)_55%)]"
}
/>
</div>
<section
className={`relative w-full max-w-xl rounded-2xl border border-border/80 shadow-2xl shadow-black/20 backdrop-blur-md ${tone === "brand" ? "overflow-hidden bg-card/94" : "bg-card/90"}`}
>
{masthead}
<div className="p-6 sm:p-8">{children}</div>
</section>
</div>
);
}
/** Entry-page headings keep their typography and spacing together. */
export function StandalonePageHeader({
eyebrow,
title,
description,
}: {
readonly eyebrow: ReactNode;
readonly title: ReactNode;
readonly description: ReactNode;
}) {
return (
<>
<p className="text-[11px] font-semibold tracking-[0.18em] text-muted-foreground uppercase">
{eyebrow}
</p>
<h1 className="mt-3 text-2xl font-semibold tracking-tight sm:text-3xl">{title}</h1>
<p className="mt-2 text-sm leading-relaxed text-muted-foreground">{description}</p>
</>
);
}
+23 -31
View File
@@ -35,6 +35,7 @@ import { useCopyToClipboard } from "../hooks/useCopyToClipboard";
import { useDefaultThemeAdoption } from "../hooks/useDefaultTheme";
import { useEnvironmentThemeSync } from "../hooks/useEnvironmentTheme";
import { Button } from "../components/ui/button";
import { StandalonePage, StandalonePageHeader } from "../components/ui/standalone-page";
import {
AnchoredToastProvider,
stackedThreadToast,
@@ -368,39 +369,30 @@ function RootRouteErrorView({ error }: ErrorComponentProps) {
const report = useMemo(() => errorReport(error, pathname), [error, pathname]);
return (
<div className="relative flex min-h-screen items-center justify-center overflow-hidden bg-background px-4 py-10 text-foreground sm:px-6">
<div className="pointer-events-none absolute inset-0 opacity-80">
<div className="absolute inset-x-0 top-0 h-44 bg-[radial-gradient(44rem_16rem_at_top,color-mix(in_srgb,var(--color-red-500)_16%,transparent),transparent)]" />
<div className="absolute inset-0 bg-[linear-gradient(145deg,color-mix(in_srgb,var(--background)_90%,var(--color-black))_0%,var(--background)_55%)]" />
<StandalonePage tone="error">
<StandalonePageHeader
eyebrow={APP_DISPLAY_NAME}
title="Something went wrong."
description={message}
/>
<div className="mt-5 flex flex-wrap gap-2">
<Button size="sm" onClick={() => void router.invalidate()}>
Try again
</Button>
<Button size="sm" variant="outline" onClick={() => window.location.reload()}>
Reload app
</Button>
<CopyErrorButton report={report} />
</div>
<section className="relative w-full max-w-xl rounded-2xl border border-border/80 bg-card/90 p-6 shadow-2xl shadow-black/20 backdrop-blur-md sm:p-8">
<p className="text-[11px] font-semibold tracking-[0.18em] text-muted-foreground uppercase">
{APP_DISPLAY_NAME}
</p>
<h1 className="mt-3 text-2xl font-semibold tracking-tight sm:text-3xl">
Something went wrong.
</h1>
<p className="mt-2 text-sm leading-relaxed text-muted-foreground">{message}</p>
<div className="mt-5 flex flex-wrap gap-2">
<Button size="sm" onClick={() => void router.invalidate()}>
Try again
</Button>
<Button size="sm" variant="outline" onClick={() => window.location.reload()}>
Reload app
</Button>
<CopyErrorButton report={report} />
</div>
<div className="mt-5 overflow-hidden rounded-lg border border-border/70 bg-background/55">
<p className="px-3 py-1.5 text-xs font-medium text-muted-foreground">Error report</p>
<pre className="max-h-64 overflow-auto border-t border-border/70 bg-background/80 px-3 py-2 text-xs whitespace-pre-wrap text-foreground/85">
{report}
</pre>
</div>
</section>
</div>
<div className="mt-5 overflow-hidden rounded-lg border border-border/70 bg-background/55">
<p className="px-3 py-1.5 text-xs font-medium text-muted-foreground">Error report</p>
<pre className="max-h-64 overflow-auto border-t border-border/70 bg-background/80 px-3 py-2 text-xs whitespace-pre-wrap text-foreground/85">
{report}
</pre>
</div>
</StandalonePage>
);
}