Skip to content

Commit fa8e29b

Browse files
fix(web): stabilize Den onboarding flow with app routes (anomalyco#1010)
* fix(web): stabilize Den onboarding flow with app routes * fix(web): apply storybook provisioning layout * fix(web): simplify Den dashboard chrome * fix(web): prioritize mobile Den web launch * fix(web): wrap worker controls in progressive disclosure
1 parent e06dbda commit fa8e29b

12 files changed

Lines changed: 4090 additions & 4225 deletions

File tree

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
"use client";
2+
3+
import { useEffect, useRef } from "react";
4+
import { useRouter } from "next/navigation";
5+
import { useDenFlow } from "../_providers/den-flow-provider";
6+
7+
function GitHubLogo() {
8+
return (
9+
<svg viewBox="0 0 16 16" aria-hidden="true" className="h-4 w-4 shrink-0">
10+
<path
11+
fill="currentColor"
12+
d="M8 0C3.58 0 0 3.58 0 8a8 8 0 0 0 5.47 7.59c.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.5-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82a7.5 7.5 0 0 1 4 0c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8 8 0 0 0 16 8c0-4.42-3.58-8-8-8Z"
13+
/>
14+
</svg>
15+
);
16+
}
17+
18+
function GoogleLogo() {
19+
return (
20+
<svg viewBox="0 0 18 18" aria-hidden="true" className="h-4 w-4 shrink-0">
21+
<path fill="#4285F4" d="M17.64 9.2c0-.64-.06-1.25-.16-1.84H9v3.48h4.84a4.14 4.14 0 0 1-1.8 2.72v2.26h2.92c1.71-1.57 2.68-3.89 2.68-6.62Z" />
22+
<path fill="#34A853" d="M9 18c2.43 0 4.47-.8 5.96-2.18l-2.92-2.26c-.81.54-1.84.86-3.04.86-2.34 0-4.31-1.58-5.01-3.7H.96v2.33A9 9 0 0 0 9 18Z" />
23+
<path fill="#FBBC05" d="M3.99 10.72A5.41 5.41 0 0 1 3.71 9c0-.6.1-1.18.28-1.72V4.95H.96A9 9 0 0 0 0 9c0 1.45.35 2.82.96 4.05l3.03-2.33Z" />
24+
<path fill="#EA4335" d="M9 3.58c1.32 0 2.5.45 3.43 1.33l2.57-2.57C13.46.9 11.43 0 9 0A9 9 0 0 0 .96 4.95l3.03 2.33c.7-2.12 2.67-3.7 5.01-3.7Z" />
25+
</svg>
26+
);
27+
}
28+
29+
export function AuthScreen() {
30+
const router = useRouter();
31+
const routingRef = useRef(false);
32+
const {
33+
authMode,
34+
setAuthMode,
35+
email,
36+
setEmail,
37+
password,
38+
setPassword,
39+
authBusy,
40+
authInfo,
41+
authError,
42+
user,
43+
sessionHydrated,
44+
desktopAuthRequested,
45+
desktopRedirectUrl,
46+
desktopRedirectBusy,
47+
showAuthFeedback,
48+
submitAuth,
49+
beginSocialAuth,
50+
resolveUserLandingRoute
51+
} = useDenFlow();
52+
53+
useEffect(() => {
54+
if (!sessionHydrated || !user || desktopAuthRequested || routingRef.current) {
55+
return;
56+
}
57+
58+
routingRef.current = true;
59+
void resolveUserLandingRoute().then((target) => {
60+
if (target) {
61+
router.replace(target);
62+
}
63+
routingRef.current = false;
64+
});
65+
}, [desktopAuthRequested, resolveUserLandingRoute, router, sessionHydrated, user]);
66+
67+
return (
68+
<section className="mx-auto grid w-full max-w-[32rem] gap-6 px-1 py-2">
69+
{sessionHydrated ? (
70+
<div className="grid gap-6 rounded-[32px] border border-white/70 bg-white/92 p-5 shadow-[0_28px_80px_-44px_rgba(15,23,42,0.35)] backdrop-blur md:p-6">
71+
<div className="grid gap-3 text-center">
72+
<h1 className="text-[2rem] font-semibold leading-[1.02] tracking-[-0.045em] text-[var(--dls-text-primary)] md:text-[2.5rem]">
73+
{authMode === "sign-up" ? "Create your OpenWork Den account." : "Sign in to OpenWork Den."}
74+
</h1>
75+
<p className="mx-auto max-w-[24rem] text-[15px] leading-7 text-[var(--dls-text-secondary)]">
76+
Keep your tasks alive even when your computer sleeps.
77+
</p>
78+
</div>
79+
80+
{desktopAuthRequested ? (
81+
<div className="rounded-[24px] border border-sky-200 bg-sky-50/80 px-4 py-3 text-sm text-sky-900">
82+
Finish auth here and we&apos;ll bounce you back into the OpenWork desktop app automatically.
83+
{desktopRedirectUrl ? (
84+
<div className="mt-3">
85+
<button
86+
type="button"
87+
className="inline-flex items-center justify-center gap-2 rounded-xl border border-sky-200 bg-white px-3 py-2 text-xs font-medium text-sky-900 transition hover:border-sky-300 hover:bg-sky-50"
88+
onClick={() => window.location.assign(desktopRedirectUrl)}
89+
>
90+
Open OpenWork
91+
</button>
92+
</div>
93+
) : null}
94+
</div>
95+
) : null}
96+
97+
<form
98+
className="grid gap-3 rounded-[28px] border border-[var(--dls-border)] bg-white p-5 shadow-[var(--dls-card-shadow)] md:p-6"
99+
onSubmit={async (event) => {
100+
const next = await submitAuth(event);
101+
if (next === "dashboard") {
102+
router.replace("/dashboard");
103+
} else if (next === "checkout") {
104+
router.replace("/checkout");
105+
}
106+
}}
107+
>
108+
<button
109+
type="button"
110+
className="inline-flex w-full items-center justify-center gap-3 rounded-2xl border border-slate-200 bg-white px-4 py-3 text-sm font-medium text-slate-700 transition hover:border-slate-300 hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-60"
111+
onClick={() => void beginSocialAuth("github")}
112+
disabled={authBusy || desktopRedirectBusy}
113+
>
114+
<GitHubLogo />
115+
<span>Continue with GitHub</span>
116+
</button>
117+
118+
<button
119+
type="button"
120+
className="inline-flex w-full items-center justify-center gap-3 rounded-2xl border border-slate-200 bg-white px-4 py-3 text-sm font-medium text-slate-700 transition hover:border-slate-300 hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-60"
121+
onClick={() => void beginSocialAuth("google")}
122+
disabled={authBusy || desktopRedirectBusy}
123+
>
124+
<GoogleLogo />
125+
<span>Continue with Google</span>
126+
</button>
127+
128+
<div className="flex items-center gap-3 text-[11px] font-semibold uppercase tracking-[0.18em] text-slate-400" aria-hidden="true">
129+
<span className="h-px flex-1 bg-slate-200" />
130+
<span>or</span>
131+
<span className="h-px flex-1 bg-slate-200" />
132+
</div>
133+
134+
<label className="grid gap-2">
135+
<span className="px-1 text-[11px] font-semibold uppercase tracking-[0.16em] text-slate-500">Email</span>
136+
<input
137+
className="w-full rounded-2xl border border-slate-200 bg-white px-4 py-3 text-[15px] text-slate-900 outline-none transition focus:border-slate-400 focus:ring-4 focus:ring-slate-900/5"
138+
type="email"
139+
value={email}
140+
onChange={(event) => setEmail(event.target.value)}
141+
autoComplete="email"
142+
required
143+
/>
144+
</label>
145+
146+
<label className="grid gap-2">
147+
<span className="px-1 text-[11px] font-semibold uppercase tracking-[0.16em] text-slate-500">Password</span>
148+
<input
149+
className="w-full rounded-2xl border border-slate-200 bg-white px-4 py-3 text-[15px] text-slate-900 outline-none transition focus:border-slate-400 focus:ring-4 focus:ring-slate-900/5"
150+
type="password"
151+
value={password}
152+
onChange={(event) => setPassword(event.target.value)}
153+
autoComplete={authMode === "sign-up" ? "new-password" : "current-password"}
154+
required
155+
/>
156+
</label>
157+
158+
<button
159+
type="submit"
160+
className="inline-flex w-full items-center justify-center rounded-2xl bg-[#011627] px-4 py-3 text-sm font-semibold text-white shadow-[0_12px_24px_rgba(15,23,42,0.14)] transition hover:bg-black disabled:cursor-not-allowed disabled:opacity-60"
161+
disabled={authBusy || desktopRedirectBusy}
162+
>
163+
{authBusy || desktopRedirectBusy ? "Working..." : authMode === "sign-in" ? "Sign in" : "Create account"}
164+
</button>
165+
</form>
166+
167+
<div className="flex items-center justify-between gap-3 px-1 text-sm text-[var(--dls-text-secondary)]">
168+
<p>{authMode === "sign-in" ? "Need an account?" : "Already have an account?"}</p>
169+
<button
170+
type="button"
171+
className="font-medium text-[var(--dls-text-primary)] transition hover:opacity-70"
172+
onClick={() => setAuthMode(authMode === "sign-in" ? "sign-up" : "sign-in")}
173+
>
174+
{authMode === "sign-in" ? "Create account" : "Switch to sign in"}
175+
</button>
176+
</div>
177+
178+
{showAuthFeedback ? (
179+
<div className="grid gap-1 rounded-2xl border border-[var(--dls-border)] bg-[var(--dls-hover)] px-4 py-3 text-center text-[13px] text-[var(--dls-text-secondary)]" aria-live="polite">
180+
<p>{authInfo}</p>
181+
{authError ? <p className="font-medium text-rose-600">{authError}</p> : null}
182+
</div>
183+
) : null}
184+
</div>
185+
) : (
186+
<div className="grid gap-3 rounded-[32px] border border-white/70 bg-white/92 p-6 text-center shadow-[0_28px_80px_-44px_rgba(15,23,42,0.35)]">
187+
<p className="text-sm text-slate-500">Checking your session...</p>
188+
</div>
189+
)}
190+
</section>
191+
);
192+
}

0 commit comments

Comments
 (0)