File size: 6,819 Bytes
8f175f6
 
ca61e3f
8f175f6
ca61e3f
8f175f6
ca61e3f
8f175f6
 
 
 
 
 
 
 
 
 
 
 
 
 
ca61e3f
8f175f6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bcc4b86
8f175f6
 
 
bcc4b86
8f175f6
 
bcc4b86
8f175f6
 
 
 
 
bcc4b86
8f175f6
 
 
 
 
 
 
 
 
bcc4b86
8f175f6
bcc4b86
8f175f6
 
bcc4b86
8f175f6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ca61e3f
8f175f6
 
 
 
 
 
 
 
 
 
 
 
 
bcc4b86
8f175f6
144145d
ca61e3f
 
8f175f6
 
 
 
 
 
 
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
108
109
110
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): always dark; on large screens the

 * Patchwise story and a live 3D scene on the left, the form in a glass card on the right; on small screens only the card.

 * `title` is the visible heading; `srTitle` adds words for screen readers only (e.g. "Sign in" + " to Patchwise").

 */
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 ?? 'Patchwise';
  return (
    <div className="trio-force-dark relative min-h-dvh overflow-hidden bg-[#0a0a0c]">

      {/* a soft gradient that stays if WebGL is missing, and the 3D scene on top of it */}

      <div aria-hidden className="pointer-events-none absolute inset-0 bg-[radial-gradient(60%_55%_at_32%_45%,rgba(255,255,255,0.08),transparent_70%),radial-gradient(40%_40%_at_20%_80%,rgba(48,209,88,0.08),transparent_70%)]" />

      <Suspense fallback={null}>

        <ReleaseScene className="absolute inset-0 opacity-40 lg:bottom-[34%] lg:left-[18%] lg:right-[36%] lg:top-[2%] lg:opacity-100" />

      </Suspense>

      {/* a dark fade under the headline so the scene never competes with the text */}

      <div aria-hidden className="pointer-events-none absolute inset-x-0 bottom-0 hidden h-[55%] bg-gradient-to-t from-[#0a0a0c] via-[#0a0a0c]/85 to-transparent lg:block" />



      <div className="relative z-10 mx-auto grid min-h-dvh max-w-[1440px] grid-cols-1 lg:grid-cols-[minmax(0,1fr)_440px] lg:gap-10 lg:px-14">

        <section className="hidden flex-col justify-between py-12 lg:flex" aria-label={`About ${name}`}>

          <div className="flex items-center gap-3">

            <BrandMark size={40} />

            <div className="leading-tight">

              <div className="text-lg font-semibold tracking-tight">{name}</div>

              <div className="text-sm text-white/50">Oracle patch testing</div>

            </div>

          </div>

          <div className="max-w-[560px] pb-4">

            <p className="m-0 text-display font-semibold tracking-tighter">

              Every Oracle update,<br />tested before it<br /><span className="text-[#30d158]">goes live.</span>

            </p>

            <p className="m-0 mt-5 max-w-[460px] text-md leading-relaxed text-white/60">

              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-white/12 bg-white/[0.04] px-3.5 py-1.5 text-sm text-white/75">{t}</li>

              ))}

            </ul>

          </div>

        </section>



        <main className="flex items-center justify-center px-5 py-10 lg:px-0" aria-label={label}>

          <div className="w-full max-w-[400px] rounded-[28px] border border-white/10 bg-[#141416]/70 p-8 shadow-[0_30px_80px_rgba(0,0,0,0.55)] backdrop-blur-2xl sm:p-9">

            <div data-testid="brand" className="mb-7 flex items-center gap-3 lg:hidden">

              <BrandMark size={36} />

              <span className="text-lg font-semibold tracking-tight">{name}</span>

            </div>

            <h1 className="m-0 text-3xl 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-white/55">{sub}</p>}

            <div className="mt-7">{children}</div>

            <div className="mt-8 border-t border-white/10 pt-5"><MockBanner /></div>

            <p className="m-0 mt-3 text-xs text-white/35">

              {brand.data?.org_name ? `${brand.data.org_name} · ` : ''}{brand.data?.version ? `Version ${brand.data.version}` : ''}

            </p>

          </div>

        </main>

      </div>

    </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-2xl bg-white/[0.06] text-[#30d158] [&_svg]:size-6">{icon}</div>}

      <h2 className="m-0 text-xl font-semibold">{title}</h2>

      <p className="m-0 text-md leading-relaxed text-white/65">{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-white/65 underline-offset-4 hover:!text-white hover:underline';
export const AUTH_LINK_STRONG = 'font-medium !text-white underline-offset-4 hover:underline';
/** A secondary action shaped like the primary button. */
export const AUTH_BUTTON_SECONDARY = 'inline-flex h-12 w-full items-center justify-center rounded-full border border-white/15 !text-white !no-underline hover:bg-white/[0.06]';
export const AUTH_BUTTON_PRIMARY = 'inline-flex h-12 w-full items-center justify-center rounded-full bg-[#f5f5f7] font-semibold !text-[#1d1d1f] !no-underline hover:bg-white';