Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/onboarding-registry-items.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@codelitdev/design-system": minor
---

New registry items for product onboarding: `onboarding-shell` (top bar with step indicator, form pane with button footer, live-preview pane), `onboarding-ui` (step building blocks such as `StepHeader`, `FieldBlock`, `Note`, `Tile` and `ProgressList`) and `onboarding-resume-dialog`. Extracted from CourseLit's setup wizard and switched to design-system tokens.
50 changes: 50 additions & 0 deletions docs/decisions/0021-shared-onboarding-layout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# ADR 0021: Product onboarding shares a layout, not a wizard

Status: accepted
Date: 2026-11-22

## Context

Every product needs a setup flow for new accounts. CourseLit built one first.
FrontLit and SendLit need the same kind of flow but haven't built theirs yet.
If each product copies CourseLit's, the three will drift apart in look and
behaviour, and fixes would have to be made three times.

CourseLit's onboarding has two kinds of code:

- **Layout and building blocks:** the top bar with the step indicator, the
form pane with its button footer, the live-preview pane (a sheet on phones),
field and note primitives, and the "welcome back" dialog. None of this
depends on what is being set up.
- **The flow itself:** which steps exist, what they ask, the live previews,
the AI panel, and how progress is saved through the product's API. This
differs per product.

## Decision

- The layout and building blocks ship as three design-system registry items,
installed like any other component (ADR 0020):
- `onboarding-shell`: `OnboardingShell`, `OnboardingFooter`,
`OnboardingPreview` and `PreviewBrowser`.
- `onboarding-ui`: `StepHeader`, `FieldBlock`, `Hint`, `Note`, `Seg`, `Tile`,
`ProgressList`, `DropZone`, `FileRow`, `CopyRow`, `StatusBadge`, `Spinner`
and `useCopy`.
- `onboarding-resume-dialog`: `OnboardingResumeDialog`.
- The shell holds no state. The product passes in its steps, the current step,
the save status and the footer buttons, and keeps its own step machine,
saving and previews.
- Colours come from design-system tokens only (`--success`, `--warning`,
`--primary-soft` and so on), so each product's accent applies.
- No shared wizard engine, step registry or progress API. Revisit this only
if FrontLit's and SendLit's flows turn out to repeat the same step logic,
not just the layout.

## Consequences

- New onboarding in FrontLit and SendLit starts from
`shadcn add @codelit/onboarding-shell @codelit/onboarding-ui
@codelit/onboarding-resume-dialog`, and writes only its own steps.
- Layout fixes are made once in the platform and reach each product through a
release and `shadcn add --overwrite`.
- A shared step, such as "how did you hear about us", can later ship as its own
registry item built on `onboarding-ui`.
27 changes: 27 additions & 0 deletions packages/design-system/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ committing.
| `dropdown-menu` | Matches `select`'s popover treatment; full Radix parts incl. checkbox/radio items and submenus |
| `tooltip` | Dark chip; `TooltipProvider` included |
| `toast` | Presentational card (`default`/`success`/`destructive`) — drive with your own queue |
| `onboarding-shell` | Setup-wizard frame: top bar with step indicator, form pane with `OnboardingFooter`, `OnboardingPreview` pane (sheet on phones), `PreviewBrowser`. Stateless; see ADR 0021 |
| `onboarding-ui` | Step building blocks: `StepHeader`, `FieldBlock`, `Hint`, `Note`, `Seg`, `Tile`, `ProgressList`, `DropZone`, `FileRow`, `CopyRow`, `StatusBadge`, `Spinner`, `useCopy` |
| `onboarding-resume-dialog` | "Welcome back" dialog for a part-done setup |

Install everything at once:

Expand All @@ -152,6 +155,30 @@ bunx shadcn@4.21.0 add @codelit/button @codelit/icon-button @codelit/badge @code
@codelit/tooltip @codelit/toast
```

For a product's setup flow, add the onboarding items:

```sh
bunx shadcn@4.21.0 add @codelit/onboarding-shell @codelit/onboarding-ui @codelit/onboarding-resume-dialog
```

```tsx
<OnboardingShell
logo={<ProductLogo className="size-7" />}
productName="SendLit"
steps={[{ key: "team", label: "Team" }, { key: "domain", label: "Domain" }]}
current={step}
saveState="saved"
onFinishLater={finishLater}
footer={<OnboardingFooter>{/* Back, <span className="flex-1" />, Continue */}</OnboardingFooter>}
preview={<OnboardingPreview title="Live preview">{/* … */}</OnboardingPreview>}
>
<StepHeader eyebrow="Step 1" title="Name your team" />
{/* fields */}
</OnboardingShell>
```

The shell needs a parent with a fixed height, such as `h-dvh`.

**Maintainers:** component sources live in `registry/codelit/ui/`. After changing
one, rebuild with `bun run registry:build` (→ `public/r/*.json`) and commit the
result. Every file in `registry.json` needs a `target` under `@ui/codelit/`.
Expand Down
22 changes: 22 additions & 0 deletions packages/design-system/public/r/onboarding-resume-dialog.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "onboarding-resume-dialog",
"title": "Onboarding resume dialog",
"description": "Welcome-back dialog for a part-done setup: lists done and next steps, focuses Continue, optional Never show again link.",
"dependencies": [
"lucide-react"
],
"registryDependencies": [
"@codelit/button",
"@codelit/dialog"
],
"files": [
{
"path": "registry/codelit/ui/onboarding-resume-dialog.tsx",
"content": "\"use client\";\n\nimport { ArrowRight, Check } from \"lucide-react\";\nimport * as React from \"react\";\n\nimport { Button } from \"@/components/ui/codelit/button\";\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n} from \"@/components/ui/codelit/dialog\";\nimport { cn } from \"@/lib/utils\";\n\n// CodeLit onboarding resume dialog — offered when someone comes back to a setup\n// that is part way done. Lists the steps with what is done and what comes next,\n// and focuses \"Continue setup\". Closing it (Escape or the scrim) also continues.\n\ntype OnboardingResumeRow = {\n key: string;\n name: string;\n desc: string;\n done?: boolean;\n /** The step the user will land on. */\n next?: boolean;\n};\n\nfunction OnboardingResumeDialog({\n open,\n rows,\n description,\n title = \"Pick up where you left off?\",\n eyebrow = \"Welcome back\",\n continueLabel = \"Continue setup\",\n exitLabel = \"Go to dashboard\",\n onContinue,\n onExit,\n neverAgainLabel,\n onNeverAgain,\n}: {\n open: boolean;\n rows: OnboardingResumeRow[];\n /** For example \"You're part way through setting up Acme. Everything you entered is saved.\" */\n description: React.ReactNode;\n title?: string;\n eyebrow?: string;\n continueLabel?: string;\n exitLabel?: string;\n onContinue: () => void;\n onExit: () => void;\n /** With `onNeverAgain`, adds a quiet link under the buttons, such as \"Never show this again\". */\n neverAgainLabel?: string;\n onNeverAgain?: () => void | Promise<void>;\n}) {\n const [hiding, setHiding] = React.useState(false);\n const continueRef = React.useRef<HTMLButtonElement>(null);\n return (\n <Dialog open={open} onOpenChange={(next) => (next ? undefined : onContinue())}>\n <DialogContent\n className=\"sm:max-w-md\"\n showCloseButton={false}\n onOpenAutoFocus={(event) => {\n // Start on the main action, not the first button in the dialog.\n event.preventDefault();\n continueRef.current?.focus();\n }}\n >\n <DialogHeader>\n <span className=\"font-mono text-[11.5px] tracking-wide text-muted-foreground\">\n {eyebrow}\n </span>\n <DialogTitle className=\"text-xl font-bold\">{title}</DialogTitle>\n <DialogDescription>{description}</DialogDescription>\n </DialogHeader>\n <ul className=\"flex flex-col gap-2\">\n {rows.map((row) => (\n <li\n key={row.key}\n className=\"flex items-center gap-3 rounded-[var(--radius)] border border-border bg-card px-3 py-2.5\"\n >\n <span\n className={cn(\n \"grid size-6 shrink-0 place-items-center rounded-full bg-muted text-muted-foreground\",\n row.done && \"bg-[var(--success-soft)] text-[var(--success)]\",\n row.next && \"bg-[var(--primary-soft)] text-primary\",\n )}\n >\n {row.done ? (\n <Check aria-hidden className=\"size-3.5\" strokeWidth={2.6} />\n ) : null}\n {row.next ? <ArrowRight aria-hidden className=\"size-3.5\" /> : null}\n </span>\n <span className=\"flex min-w-0 flex-1 flex-col\">\n <b className=\"text-sm font-semibold\">{row.name}</b>\n <span className=\"truncate text-[13px] text-muted-foreground\">\n {row.desc}\n </span>\n </span>\n </li>\n ))}\n </ul>\n <DialogFooter>\n <Button type=\"button\" variant=\"outline\" onClick={onExit}>\n {exitLabel}\n </Button>\n <Button ref={continueRef} type=\"button\" onClick={onContinue}>\n {continueLabel}\n </Button>\n </DialogFooter>\n {neverAgainLabel && onNeverAgain ? (\n <button\n type=\"button\"\n className=\"mx-auto mt-4 block rounded-[var(--radius-sm)] text-[13px] text-muted-foreground underline-offset-4 outline-none hover:text-foreground hover:underline focus-visible:shadow-[var(--shadow-focus)] disabled:opacity-50\"\n disabled={hiding}\n onClick={async () => {\n setHiding(true);\n try {\n await onNeverAgain();\n } finally {\n setHiding(false);\n }\n }}\n >\n {neverAgainLabel}\n </button>\n ) : null}\n </DialogContent>\n </Dialog>\n );\n}\n\nexport type { OnboardingResumeRow };\nexport { OnboardingResumeDialog };\n",
"type": "registry:ui",
"target": "@ui/codelit/onboarding-resume-dialog.tsx"
}
],
"type": "registry:ui"
}
Loading
Loading