Skip to content

Commit f252299

Browse files
wesbillmanBrain
andauthored
feat(desktop): onboarding step dots, identity/key page restyle, overflow scroll (#1993)
Signed-off-by: Wes <[email protected]> Co-authored-by: Brain <21994759fc7a6fa6b965551d35cfd7897d262f2495467f2d78694ddcfa6a5c7e@sprout-oss.stage.blox.sqprod.co>
1 parent db57bc8 commit f252299

9 files changed

Lines changed: 230 additions & 240 deletions

File tree

‎desktop/src/features/onboarding/ui/BackupStep.tsx‎

Lines changed: 30 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import { AlertTriangle, RefreshCw } from "lucide-react";
1+
import { AlertTriangle, Info, RefreshCw } from "lucide-react";
22
import * as React from "react";
33

44
import { getNsec } from "@/shared/api/tauriIdentity";
55
import { Button } from "@/shared/ui/button";
66
import { Spinner } from "@/shared/ui/spinner";
7-
import { StepProgress } from "@/shared/ui/step-progress";
87
import {
98
type OnboardingTransitionDirection,
109
OnboardingSlideTransition,
@@ -14,51 +13,33 @@ import { NsecMaskedDisplay } from "./NsecMaskedDisplay";
1413
/**
1514
* Pure helper so the disabled logic can be unit-tested without a DOM.
1615
*
17-
* Disabled when:
18-
* - still loading (key not fetched yet)
19-
* - load failed (only the explicit "Skip for now" ghost advances past an error)
20-
* - key loaded AND checkbox not yet checked
21-
*
22-
* Enabled when key is null after a clean (non-error) load — backend returned
23-
* nothing, so there is nothing to acknowledge and the user may proceed.
16+
* Disabled while loading (key not fetched yet) or after a failed load (only
17+
* the explicit "Skip for now" ghost advances past an error).
2418
*/
2519
export function backupNextDisabled({
2620
isLoading,
2721
loadError,
28-
nsec,
29-
hasAcknowledged,
3022
}: {
3123
isLoading: boolean;
3224
loadError: string | null;
33-
nsec: string | null;
34-
hasAcknowledged: boolean;
3525
}): boolean {
36-
return isLoading || loadError !== null || (nsec !== null && !hasAcknowledged);
26+
return isLoading || loadError !== null;
3727
}
3828

3929
type BackupStepProps = {
40-
currentStep: number;
4130
direction: OnboardingTransitionDirection;
42-
totalSteps: number;
4331
onBack: () => void;
4432
onNext: () => void;
4533
};
4634

4735
/**
48-
* Onboarding backup step — shows the user their nsec and requires
49-
* acknowledgement before advancing. Only shown on the fresh-key path.
36+
* Onboarding backup step — shows the user their freshly created key so they
37+
* can save it somewhere safe. Only shown on the fresh-key path.
5038
*/
51-
export function BackupStep({
52-
currentStep,
53-
direction,
54-
totalSteps,
55-
onBack,
56-
onNext,
57-
}: BackupStepProps) {
39+
export function BackupStep({ direction, onBack, onNext }: BackupStepProps) {
5840
const [nsec, setNsec] = React.useState<string | null>(null);
5941
const [isLoading, setIsLoading] = React.useState(true);
6042
const [loadError, setLoadError] = React.useState<string | null>(null);
61-
const [hasAcknowledged, setHasAcknowledged] = React.useState(false);
6243
const cancelledRef = React.useRef(false);
6344

6445
const loadNsec = React.useCallback(async () => {
@@ -92,30 +73,29 @@ export function BackupStep({
9273

9374
return (
9475
<OnboardingSlideTransition
95-
className="flex w-full flex-col items-center pb-36 lg:pb-0"
76+
className="flex w-full flex-col items-center"
9677
data-testid="onboarding-page-backup"
9778
direction={direction}
9879
transitionKey={`backup-${direction}`}
9980
>
10081
<div className="w-full max-w-[500px] text-center">
10182
<h1 className="text-3xl font-semibold tracking-tight text-foreground">
102-
Save your private key
83+
Your unique identity has been created
10384
</h1>
104-
<p className="mt-3 text-sm leading-6 text-muted-foreground">
105-
Buzz generated a Nostr private key for you. This key is stored in your
106-
system keychain, but you should also save it somewhere safe in case
107-
you ever need to restore your account on another device.
85+
<p className="mt-3 text-sm leading-6 text-foreground/80">
86+
This key is stored in your system keychain, but save it some place
87+
safe in case you ever need to restore your account.
10888
</p>
10989
</div>
11090

111-
<div className="mt-8 w-full max-w-[500px] space-y-4 text-left">
91+
<div className="mt-10 w-full max-w-[640px]">
11292
{isLoading ? (
113-
<div className="flex items-center gap-2 rounded-lg border border-border/70 bg-muted/30 px-4 py-6 text-sm text-muted-foreground">
93+
<div className="flex items-center justify-center gap-2 py-6 text-sm text-foreground/70">
11494
<Spinner className="h-4 w-4 border-2" />
11595
Loading your private key…
11696
</div>
11797
) : loadError ? (
118-
<div className="space-y-3">
98+
<div className="mx-auto max-w-[500px] space-y-3 text-left">
11999
<div
120100
className="flex items-start gap-3 rounded-lg border border-destructive/30 bg-destructive/10 px-4 py-3 text-sm text-destructive"
121101
data-testid="backup-load-error"
@@ -140,46 +120,31 @@ export function BackupStep({
140120
</Button>
141121
</div>
142122
) : nsec ? (
143-
<NsecMaskedDisplay nsec={nsec} />
123+
<div className="rounded-3xl bg-white/85 px-6 py-5 shadow-[0_0_70px_45px_rgba(255,255,255,0.85)]">
124+
<NsecMaskedDisplay nsec={nsec} variant="bare" />
125+
</div>
144126
) : (
145-
<p className="text-sm text-muted-foreground">
127+
<p className="text-center text-sm text-foreground/70">
146128
No key available to back up.
147129
</p>
148130
)}
149131

150132
{nsec ? (
151-
<div className="rounded-lg border border-amber-500/30 bg-amber-500/10 px-4 py-3 text-sm leading-5 text-amber-700 dark:text-amber-400">
152-
<strong>Never share your private key.</strong> Anyone with it can
153-
impersonate you and access everything in your account.
154-
</div>
155-
) : null}
156-
157-
{!isLoading && !loadError && nsec ? (
158-
<label className="flex cursor-pointer items-start gap-3">
159-
<input
160-
checked={hasAcknowledged}
161-
className="mt-0.5 h-4 w-4 shrink-0 cursor-pointer accent-primary"
162-
data-testid="backup-acknowledge"
163-
onChange={(e) => setHasAcknowledged(e.target.checked)}
164-
type="checkbox"
165-
/>
166-
<span className="text-sm leading-5">
167-
I've saved my private key in a safe place
133+
<p className="mx-auto mt-6 flex max-w-[440px] items-start justify-center gap-1.5 text-center text-xs leading-5 text-foreground/70">
134+
<Info className="mt-0.5 h-3.5 w-3.5 shrink-0" />
135+
<span>
136+
Never share your private key. Anyone can impersonate you and
137+
access everything in your account.
168138
</span>
169-
</label>
139+
</p>
170140
) : null}
171141
</div>
172142

173-
<div className="mt-8 flex w-full max-w-[500px] flex-col gap-3 max-lg:pointer-events-none max-lg:fixed max-lg:inset-x-0 max-lg:bottom-0 max-lg:z-40 max-lg:mt-0 max-lg:max-w-none max-lg:border-t max-lg:border-border max-lg:bg-background max-lg:p-4 max-lg:pb-[max(1rem,env(safe-area-inset-bottom))]">
143+
<div className="mt-12 flex flex-col items-center gap-3">
174144
<Button
175-
className="h-10 w-full max-lg:pointer-events-auto"
145+
className="h-10 rounded-full px-8"
176146
data-testid="onboarding-next"
177-
disabled={backupNextDisabled({
178-
isLoading,
179-
loadError,
180-
nsec,
181-
hasAcknowledged,
182-
})}
147+
disabled={backupNextDisabled({ isLoading, loadError })}
183148
onClick={onNext}
184149
type="button"
185150
>
@@ -188,7 +153,7 @@ export function BackupStep({
188153

189154
{loadError ? (
190155
<Button
191-
className="h-10 w-full text-muted-foreground hover:text-accent-foreground max-lg:pointer-events-auto"
156+
className="h-9 rounded-full px-5 text-muted-foreground hover:text-accent-foreground"
192157
data-testid="backup-skip"
193158
onClick={onNext}
194159
type="button"
@@ -199,23 +164,14 @@ export function BackupStep({
199164
) : null}
200165

201166
<Button
202-
className="h-10 w-full text-muted-foreground hover:text-accent-foreground max-lg:pointer-events-auto"
167+
className="h-9 rounded-full bg-foreground/10 px-6 hover:bg-foreground/15"
203168
data-testid="onboarding-back"
204169
onClick={onBack}
205170
type="button"
206171
variant="ghost"
207172
>
208173
Back
209174
</Button>
210-
211-
<StepProgress
212-
activeSegmentClassName="bg-primary"
213-
className="mt-1 max-lg:pointer-events-auto lg:hidden"
214-
completeSegmentClassName="bg-primary/35"
215-
currentStep={currentStep}
216-
inactiveSegmentClassName="bg-muted-foreground/25"
217-
totalSteps={totalSteps}
218-
/>
219175
</div>
220176
</OnboardingSlideTransition>
221177
);

‎desktop/src/features/onboarding/ui/MachineOnboardingFlow.tsx‎

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { BackupStep } from "./BackupStep";
1212
import { LandingBees } from "./LandingBees";
1313
import { NostrKeyImportForm } from "./NostrKeyImportForm";
1414
import { OnboardingSlideTransition } from "./OnboardingSlideTransition";
15+
import { OnboardingStepDots } from "./OnboardingStepDots";
1516
import { SetupStep } from "./SetupStep";
1617

1718
type MachinePage = "identity" | "key-import" | "backup" | "setup";
@@ -87,14 +88,17 @@ export function MachineOnboardingFlow({
8788

8889
return (
8990
<div
90-
className={`buzz-onboarding-neutral-theme buzz-startup-shell flex items-center justify-center px-4 py-8 text-foreground ${
91-
page === "identity" ? "buzz-onboarding-welcome" : ""
92-
}`}
91+
className={`buzz-onboarding-neutral-theme buzz-startup-shell flex max-h-dvh items-start justify-center overflow-y-auto px-4 text-foreground ${
92+
page === "setup" ? "py-24" : "py-8"
93+
} ${page === "identity" ? "buzz-onboarding-welcome" : ""}`}
9394
data-testid="machine-onboarding-gate"
9495
>
9596
<StartupWindowDragRegion />
9697
{page === "identity" ? <LandingBees /> : null}
97-
<div className="relative flex w-full max-w-[920px] flex-col items-center text-center">
98+
{page !== "identity" ? (
99+
<OnboardingStepDots current={page === "setup" ? 3 : 2} />
100+
) : null}
101+
<div className="relative my-auto flex w-full max-w-[920px] flex-col items-center text-center">
98102
{page === "identity" ? (
99103
<OnboardingSlideTransition
100104
className="flex w-full max-w-[720px] flex-col items-center text-center"
@@ -135,17 +139,17 @@ export function MachineOnboardingFlow({
135139
</OnboardingSlideTransition>
136140
) : page === "key-import" ? (
137141
<OnboardingSlideTransition
138-
className="flex w-full max-w-[500px] flex-col items-center text-center"
142+
className="flex w-full max-w-[640px] flex-col items-center text-center"
139143
direction="forward"
140144
transitionKey="machine-key-import"
141145
>
142146
<h1 className="text-3xl font-semibold tracking-tight">
143-
{identityLost ? "Re-import your key" : "Use your existing key"}
147+
{identityLost ? "Re-import your key" : "Enter your private key"}
144148
</h1>
145-
<p className="mt-3 text-sm leading-6 text-muted-foreground">
149+
<p className="mt-3 max-w-[440px] text-sm leading-6 text-foreground/80">
146150
{identityLost
147151
? "Your identity is no longer in the system keyring. Re-import your nsec to restore it."
148-
: "Import your Nostr private key to use that identity with Buzz."}
152+
: "If you already have a Nostr account, enter your private key below to get started."}
149153
</p>
150154
<NostrKeyImportForm
151155
backLabel={identityLost ? "Start new identity" : "Back"}
@@ -155,15 +159,14 @@ export function MachineOnboardingFlow({
155159
: () => setPage("identity")
156160
}
157161
onImport={importExistingIdentity}
162+
variant="spotlight"
158163
/>
159164
</OnboardingSlideTransition>
160165
) : page === "backup" ? (
161166
<BackupStep
162-
currentStep={2}
163167
direction="forward"
164168
onBack={() => setPage("identity")}
165169
onNext={() => setPage("setup")}
166-
totalSteps={3}
167170
/>
168171
) : (
169172
<SetupStep

0 commit comments

Comments
 (0)