patchwise-agent-studio / web /src /pages /auth /AuthShell.tsx
EnergyVenom's picture
Tidy the web app: pages by area, CSS in load order, web/README.md (b2a039d)
fb43301 verified
Raw History Blame Contribute Delete
6.48 kB
import { lazy, Suspense, type ReactNode } from 'react';
import { Alert, AlertContent, AlertDescription, AlertIcon } from '@/components/ui/motion/alert';
import { useBrand } from '../../api/hooks';
import { explainError } from '../../api/errors';
import { MockBanner } from '../../components/common';
import { BrandMark } from './login/BrandMark';
// the 3D hero (three.js) loads after the form is on screen, in its own chunk
const ReleaseScene = lazy(() => import('./login/ReleaseScene').then((m) => ({ default: m.ReleaseScene })));
/** beUI fields on a page without Tailwind's reset: no native border on the inner input (the field draws it). */
export const FIELD = { root: 'beui-field', input: 'border-0' };
/**
* The frame of every account page (sign in, create an account, forgot, reset). On large screens a black brand
* panel with the ember glow on the left (the Astra story and a live 3D scene) and the form on the right, in the app's
* own type and accent; on small screens only the form. `title` is the visible heading; `srTitle` adds words for screen
* readers only (e.g. "Sign in" + " to Astra").
*/
export function AuthShell({ children, label, title, srTitle, sub }: {
children: ReactNode; label: string; title: string; srTitle?: string; sub?: ReactNode;
}) {
const brand = useBrand();
const name = brand.data?.product_name ?? 'Astra';
return (
<div className="grid min-h-dvh grid-cols-1 bg-[var(--bg)] text-[var(--label)] lg:grid-cols-[minmax(0,1.15fr)_minmax(0,1fr)]">
<section className="trio-force-dark relative hidden overflow-hidden bg-[#000] lg:flex" aria-label={`About ${name}`}>
<div aria-hidden className="pointer-events-none absolute inset-0 bg-[radial-gradient(60%_55%_at_45%_30%,rgba(59,142,232,0.30),rgba(59,142,232,0.06)_50%,transparent_75%)]" />
<Suspense fallback={null}>
<ReleaseScene className="absolute bottom-[38%] left-[8%] right-[8%] top-[4%] opacity-90" />
</Suspense>
<div className="relative z-10 flex w-full flex-col justify-between p-12 xl:p-14">
<div className="flex items-center gap-3">
<BrandMark size={40} />
<div className="leading-tight">
<div className="astra-wordmark text-lg text-white">{name}</div>
<div className="text-sm text-white/60">Oracle patch testing</div>
</div>
</div>
<div className="max-w-[520px]">
<p className="m-0 text-[48px] font-medium leading-[1.06] tracking-tight text-white" style={{ fontFamily: 'var(--font-display)' }}>
Every Oracle update, tested before it <span className="astra-grad-text">goes live.</span>
</p>
<p className="m-0 mt-5 max-w-[460px] text-md leading-relaxed text-white/70">
Three agents read the patch, test your business processes in a real browser and bring you the evidence.
You approve and sign off.
</p>
<ul className="m-0 mt-8 flex list-none flex-wrap gap-2 p-0" aria-label="What it does">
{['Monthly and quarterly updates', 'Real browser, real evidence', 'You stay in charge'].map((t) => (
<li key={t} className="rounded-full border border-[#3b8ee8]/40 bg-[#3b8ee8]/[0.08] px-3 py-1.5 text-sm text-white/85">{t}</li>
))}
</ul>
</div>
</div>
</section>
<main className="flex items-center justify-center px-5 py-12 sm:px-10" aria-label={label}>
<div className="w-full max-w-[400px]">
<div data-testid="brand" className="mb-8 flex items-center gap-3 lg:hidden">
<BrandMark size={36} />
<span className="astra-wordmark text-lg">{name}</span>
</div>
<h1 className="m-0 text-[28px] font-semibold leading-tight tracking-tight">
{title}{srTitle && <span className="sr-only">{srTitle}</span>}
</h1>
{sub && <p className="m-0 mt-2 text-md text-[var(--label-2)]">{sub}</p>}
<div className="mt-8">{children}</div>
<div className="mt-8 border-t border-[var(--sep)] pt-5"><MockBanner /></div>
<p className="m-0 mt-3 text-xs text-[var(--label-3)]">
{brand.data?.org_name ? `${brand.data.org_name} · ` : ''}{brand.data?.version ? `Version ${brand.data.version}` : ''}
</p>
</div>
</main>
</div>
);
}
/** An account-page problem in plain words, in the animated alert. */
export function AuthError({ err, message, testId }: { err: unknown; message?: string; testId?: string }) {
const i = explainError(err);
return (
<Alert variant="destructive" data-testid={testId} className="beui-motion">
<AlertIcon />
<AlertContent><AlertDescription>{message ?? [i.message, i.hint].filter(Boolean).join(' ')}</AlertDescription></AlertContent>
</Alert>
);
}
/** A finished step ("Check your inbox", "Password changed"): an icon, a heading, one sentence and the next action. */
export function AuthDone({ icon, title, children, action, testId }: { icon?: ReactNode; title: string; children: ReactNode; action: ReactNode; testId?: string }) {
return (
<div className="flex flex-col gap-4" data-testid={testId}>
{icon && <div className="grid size-12 place-items-center rounded-xl bg-[var(--green-soft)] text-[var(--green)] [&_svg]:size-6">{icon}</div>}
<h2 className="m-0 text-xl font-semibold">{title}</h2>
<p className="m-0 text-md leading-relaxed text-[var(--label-2)]">{children}</p>
{action}
</div>
);
}
/** Links on account pages: the app's global link colour would win over Tailwind, so the colour is forced here. */
export const AUTH_LINK = '!text-[var(--label-2)] underline-offset-4 hover:!text-[var(--label)] hover:underline';
export const AUTH_LINK_STRONG = 'font-medium !text-[var(--accent-text)] underline-offset-4 hover:underline';
/** A secondary action shaped like the primary button. */
export const AUTH_BUTTON_SECONDARY = 'inline-flex h-11 w-full items-center justify-center rounded-lg border border-[var(--sep-strong)] bg-[var(--bg-elev)] !text-[var(--label)] !no-underline hover:bg-[var(--fill)]';
export const AUTH_BUTTON_PRIMARY = 'inline-flex h-11 w-full items-center justify-center rounded-lg bg-[var(--accent)] font-semibold !text-[var(--on-accent)] !no-underline hover:bg-[var(--accent-hover)]';