File size: 6,475 Bytes
af1bee9 fb43301 af1bee9 589f639 ea59f21 0d811c3 ea59f21 af1bee9 ea59f21 af1bee9 0d811c3 589f639 153376e 0d811c3 af1bee9 153376e 0d811c3 af1bee9 0d811c3 589f639 153376e af1bee9 0d811c3 af1bee9 153376e af1bee9 0d811c3 af1bee9 0d811c3 153376e af1bee9 0d811c3 af1bee9 0d811c3 af1bee9 0d811c3 af1bee9 0d811c3 af1bee9 0d811c3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | 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)]';
|