Onboarding — Multi-step setup wizard
A full-page, four-step setup wizard that walks a new user from Account to Workspace to Invite team to a Review-and-finish screen. A progress stepper tracks position, Back and Continue buttons gate forward motion behind per-step validation, and every field persists when you navigate back so nothing is lost. The review step summarises all entries with inline edit links, and launching the workspace fires a canvas confetti celebration. Live variant switchers toggle a horizontal stepper against a vertical sidebar and a percentage bar against a step counter.
MCP
程式碼
:root {
--brand: #5b5bf0;
--brand-d: #4646d6;
--brand-700: #3a3ab8;
--brand-50: #eef0ff;
--accent: #00b4a6;
--accent-soft: #d8f5f2;
--ink: #101322;
--ink-2: #3a4060;
--muted: #6c7393;
--bg: #f6f7fb;
--white: #ffffff;
--surface: #ffffff;
--line: rgba(16, 19, 34, 0.1);
--line-2: rgba(16, 19, 34, 0.16);
--ok: #2f9e6f;
--warn: #d98a2b;
--danger: #d4503e;
--r-sm: 8px;
--r-md: 14px;
--r-lg: 20px;
--sh-1: 0 1px 2px rgba(16, 19, 34, 0.08);
--sh-2: 0 8px 24px rgba(16, 19, 34, 0.08);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
margin: 0;
font-family: "Inter", system-ui, -apple-system, sans-serif;
line-height: 1.5;
color: var(--ink);
background:
radial-gradient(1100px 540px at 85% -10%, rgba(91, 91, 240, 0.1), transparent 60%),
radial-gradient(900px 480px at -5% 0%, rgba(0, 180, 166, 0.08), transparent 55%),
var(--bg);
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
min-height: 100vh;
}
button { font-family: inherit; }
:focus-visible {
outline: 2px solid var(--brand);
outline-offset: 2px;
border-radius: var(--r-sm);
}
/* Page shell */
.page {
max-width: 980px;
margin: 0 auto;
padding: 28px 20px 64px;
}
/* Topbar */
.topbar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
flex-wrap: wrap;
margin-bottom: 22px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
display: grid;
place-items: center;
width: 38px;
height: 38px;
border-radius: 11px;
color: var(--white);
background: linear-gradient(135deg, var(--brand), var(--brand-d));
box-shadow: var(--sh-1), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 16px; font-weight: 800; letter-spacing: -0.01em; }
.brand-text span { font-size: 12px; color: var(--muted); font-weight: 500; }
.topbar-tools { display: flex; gap: 10px; flex-wrap: wrap; }
.seg {
display: inline-flex;
padding: 3px;
gap: 2px;
background: var(--white);
border: 1px solid var(--line);
border-radius: var(--r-md);
box-shadow: var(--sh-1);
}
.seg-btn {
border: 0;
background: transparent;
padding: 6px 12px;
font-size: 12.5px;
font-weight: 600;
color: var(--muted);
border-radius: 10px;
cursor: pointer;
transition: background 0.16s, color 0.16s;
}
.seg-btn:hover { color: var(--ink-2); }
.seg-btn.is-active {
background: var(--brand-50);
color: var(--brand-700);
}
/* Wizard card */
.wizard {
display: grid;
grid-template-columns: 1fr;
gap: 0;
background: var(--surface);
border: 1px solid var(--line);
border-radius: var(--r-lg);
box-shadow: var(--sh-2);
overflow: hidden;
}
.wizard[data-layout="vertical"] {
grid-template-columns: 264px 1fr;
}
/* Stepper */
.stepper {
padding: 22px 24px;
border-bottom: 1px solid var(--line);
background: linear-gradient(180deg, rgba(238, 240, 255, 0.5), transparent);
}
.wizard[data-layout="vertical"] .stepper {
border-bottom: 0;
border-right: 1px solid var(--line);
background: linear-gradient(180deg, rgba(238, 240, 255, 0.55), var(--surface));
display: flex;
flex-direction: column;
}
.steps {
list-style: none;
margin: 0;
padding: 0;
display: flex;
align-items: flex-start;
gap: 6px;
}
.wizard[data-layout="vertical"] .steps {
flex-direction: column;
align-items: stretch;
gap: 2px;
flex: 1;
}
.step {
display: flex;
align-items: center;
gap: 10px;
flex: 1;
position: relative;
padding: 4px 0;
}
/* horizontal connector line */
.wizard[data-layout="horizontal"] .step:not(:last-child)::after {
content: "";
flex: 1;
height: 2px;
margin: 0 4px;
border-radius: 2px;
background: var(--line-2);
transition: background 0.2s;
}
.wizard[data-layout="horizontal"] .step.is-done::after { background: var(--brand); }
/* vertical layout: stack dot over rail */
.wizard[data-layout="vertical"] .step {
padding: 10px 10px;
border-radius: var(--r-md);
}
.wizard[data-layout="vertical"] .step.is-active {
background: var(--white);
box-shadow: var(--sh-1);
}
.wizard[data-layout="vertical"] .step:not(:last-child)::after {
content: "";
position: absolute;
left: 24px;
top: 38px;
bottom: -2px;
width: 2px;
background: var(--line-2);
}
.wizard[data-layout="vertical"] .step.is-done::after { background: var(--brand); }
.step-dot {
flex: 0 0 auto;
display: grid;
place-items: center;
width: 30px;
height: 30px;
border-radius: 50%;
background: var(--white);
border: 2px solid var(--line-2);
color: var(--muted);
font-size: 13px;
font-weight: 700;
transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.2s;
z-index: 1;
}
.step.is-active .step-dot {
background: var(--brand);
border-color: var(--brand);
color: var(--white);
box-shadow: 0 0 0 4px var(--brand-50);
}
.step.is-done .step-dot {
background: var(--accent);
border-color: var(--accent);
color: var(--white);
}
.step.is-done .step-dot::before {
content: "";
width: 11px;
height: 6px;
border-left: 2.4px solid currentColor;
border-bottom: 2.4px solid currentColor;
transform: rotate(-45deg) translateY(-1px);
}
.step.is-done .step-dot { font-size: 0; }
.step-meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.step-title { font-size: 13px; font-weight: 700; color: var(--ink); letter-spacing: -0.01em; }
.step-sub { font-size: 11.5px; color: var(--muted); }
/* hide labels in horizontal on small */
.wizard[data-layout="horizontal"] .step .step-meta { display: none; }
@media (min-width: 680px) {
.wizard[data-layout="horizontal"] .step .step-meta { display: flex; }
}
/* Progress bar */
.progress {
margin-top: 18px;
display: flex;
align-items: center;
gap: 12px;
}
.wizard[data-layout="vertical"] .progress { margin-top: auto; padding-top: 18px; }
.progress-track {
flex: 1;
height: 8px;
border-radius: 999px;
background: var(--line);
overflow: hidden;
}
.progress-fill {
display: block;
height: 100%;
width: 0;
border-radius: 999px;
background: linear-gradient(90deg, var(--brand), var(--accent));
transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.progress-label {
font-size: 12px;
font-weight: 600;
color: var(--muted);
white-space: nowrap;
font-variant-numeric: tabular-nums;
}
/* hide progress bar when in count mode */
.wizard[data-progress="count"] .progress-track { display: none; }
.wizard[data-progress="count"] .progress-label { color: var(--brand-700); font-size: 13px; }
/* Panels */
.panel-wrap { padding: 30px 32px 24px; display: flex; flex-direction: column; }
.panel { animation: fade 0.32s ease; }
.panel[hidden] { display: none; }
@keyframes fade {
from { opacity: 0; transform: translateY(8px); }
to { opacity: 1; transform: translateY(0); }
}
.panel-head { margin-bottom: 22px; }
.panel-kicker {
display: inline-block;
font-size: 11.5px;
font-weight: 700;
letter-spacing: 0.06em;
text-transform: uppercase;
color: var(--brand-700);
background: var(--brand-50);
padding: 4px 10px;
border-radius: 999px;
margin-bottom: 12px;
}
.panel-title {
margin: 0 0 6px;
font-size: 24px;
font-weight: 800;
letter-spacing: -0.02em;
}
.panel-lead { margin: 0; color: var(--muted); font-size: 14.5px; max-width: 52ch; }
/* Fields */
.grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 16px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field--full { grid-column: 1 / -1; }
.field-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field-hint { font-size: 12px; color: var(--muted); }
.field input {
width: 100%;
padding: 11px 13px;
font-size: 14px;
color: var(--ink);
background: var(--white);
border: 1px solid var(--line-2);
border-radius: var(--r-sm);
transition: border-color 0.16s, box-shadow 0.16s;
}
.field input::placeholder { color: #a3a8c0; }
.field input:hover { border-color: var(--muted); }
.field input:focus {
outline: none;
border-color: var(--brand);
box-shadow: 0 0 0 3px var(--brand-50);
}
.field.has-error input { border-color: var(--danger); }
.field.has-error input:focus { box-shadow: 0 0 0 3px rgba(212, 80, 62, 0.16); }
.field-error {
font-size: 12px;
font-weight: 600;
color: var(--danger);
min-height: 0;
display: none;
}
.field.has-error .field-error { display: block; }
.field.has-error .field-hint { display: none; }
.input-affix {
display: flex;
align-items: stretch;
border: 1px solid var(--line-2);
border-radius: var(--r-sm);
overflow: hidden;
transition: border-color 0.16s, box-shadow 0.16s;
}
.input-affix:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }
.input-affix .affix {
display: grid;
place-items: center;
padding: 0 12px;
font-size: 13px;
font-weight: 600;
color: var(--muted);
background: var(--bg);
border-right: 1px solid var(--line);
}
.input-affix input { border: 0; border-radius: 0; }
.input-affix input:focus { box-shadow: none; }
.field.has-error .input-affix { border-color: var(--danger); }
/* Chips / radiogroup */
.chooser { border: 0; margin: 0; padding: 0; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
border: 1px solid var(--line-2);
background: var(--white);
color: var(--ink-2);
padding: 9px 16px;
border-radius: 999px;
font-size: 13px;
font-weight: 600;
cursor: pointer;
transition: all 0.15s;
}
.chip:hover { border-color: var(--brand); color: var(--brand-700); }
.chip[aria-checked="true"] {
background: var(--brand);
border-color: var(--brand);
color: var(--white);
box-shadow: var(--sh-1);
}
/* Invite step */
.invite-row { display: flex; gap: 8px; }
.invite-row input { flex: 1; }
.invite-list { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.invite-item {
display: flex;
align-items: center;
gap: 12px;
padding: 10px 12px;
background: var(--white);
border: 1px solid var(--line);
border-radius: var(--r-md);
box-shadow: var(--sh-1);
animation: fade 0.25s ease;
}
.invite-avatar {
flex: 0 0 auto;
width: 32px;
height: 32px;
border-radius: 50%;
display: grid;
place-items: center;
font-size: 12.5px;
font-weight: 700;
color: var(--white);
}
.invite-email { flex: 1; font-size: 13.5px; font-weight: 500; color: var(--ink); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invite-role { font-size: 11.5px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 3px 9px; border-radius: 999px; }
.invite-remove {
border: 0;
background: transparent;
color: var(--muted);
cursor: pointer;
display: grid;
place-items: center;
width: 28px;
height: 28px;
border-radius: var(--r-sm);
transition: background 0.15s, color 0.15s;
}
.invite-remove:hover { background: rgba(212, 80, 62, 0.1); color: var(--danger); }
.invite-empty {
padding: 22px;
text-align: center;
font-size: 13px;
color: var(--muted);
border: 1px dashed var(--line-2);
border-radius: var(--r-md);
}
/* Review */
.review {
margin: 0;
display: grid;
gap: 2px;
border: 1px solid var(--line);
border-radius: var(--r-md);
overflow: hidden;
}
.review-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
padding: 14px 16px;
background: var(--white);
}
.review-row:nth-child(odd) { background: rgba(246, 247, 251, 0.6); }
.review-row dt { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.review-row dd { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--ink); text-align: right; max-width: 60%; overflow-wrap: anywhere; }
.review-row dd.tags { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.review-tag { font-size: 12px; font-weight: 600; color: var(--brand-700); background: var(--brand-50); padding: 3px 9px; border-radius: 999px; }
.review-edit {
border: 0;
background: transparent;
color: var(--brand);
font-size: 12.5px;
font-weight: 700;
cursor: pointer;
padding: 2px 4px;
}
.review-edit:hover { text-decoration: underline; }
/* Actions footer */
.actions {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-top: 26px;
padding-top: 20px;
border-top: 1px solid var(--line);
}
.actions-right { display: flex; align-items: center; gap: 10px; }
.btn {
display: inline-flex;
align-items: center;
gap: 7px;
border: 1px solid transparent;
border-radius: var(--r-sm);
padding: 11px 18px;
font-size: 14px;
font-weight: 600;
cursor: pointer;
transition: transform 0.12s, background 0.16s, box-shadow 0.16s, color 0.16s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
background: linear-gradient(135deg, var(--brand), var(--brand-d));
color: var(--white);
box-shadow: var(--sh-1);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 6px 18px rgba(91, 91, 240, 0.32); }
.btn-ghost {
background: var(--white);
border-color: var(--line-2);
color: var(--ink-2);
}
.btn-ghost:hover:not(:disabled) { border-color: var(--brand); color: var(--brand-700); background: var(--brand-50); }
.btn-text {
background: transparent;
color: var(--muted);
padding: 11px 10px;
}
.btn-text:hover { color: var(--ink-2); }
/* Done screen */
.done { text-align: center; padding: 18px 0 8px; }
.done-icon {
width: 76px;
height: 76px;
margin: 6px auto 18px;
border-radius: 50%;
display: grid;
place-items: center;
color: var(--white);
background: linear-gradient(135deg, var(--accent), #0b8f86);
box-shadow: 0 10px 28px rgba(0, 180, 166, 0.4);
animation: pop 0.45s cubic-bezier(0.2, 1.4, 0.5, 1) both;
}
@keyframes pop {
from { transform: scale(0.5); opacity: 0; }
to { transform: scale(1); opacity: 1; }
}
.done-title { margin: 0 0 8px; font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.done-lead { margin: 0 auto 26px; color: var(--muted); font-size: 15px; max-width: 44ch; }
.done-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
/* Confetti canvas */
#confetti {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 50;
}
/* Toast */
.toast-wrap {
position: fixed;
left: 50%;
bottom: 24px;
transform: translateX(-50%);
display: flex;
flex-direction: column;
gap: 8px;
z-index: 60;
width: max-content;
max-width: calc(100% - 32px);
}
.toast {
display: flex;
align-items: center;
gap: 10px;
padding: 11px 16px;
background: var(--ink);
color: var(--white);
border-radius: var(--r-md);
font-size: 13.5px;
font-weight: 500;
box-shadow: var(--sh-2);
animation: toastIn 0.25s ease;
}
.toast.out { animation: toastOut 0.25s ease forwards; }
.toast svg { color: var(--accent); flex: 0 0 auto; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(12px); } }
/* Responsive */
@media (max-width: 760px) {
.wizard[data-layout="vertical"] { grid-template-columns: 1fr; }
.wizard[data-layout="vertical"] .stepper {
border-right: 0;
border-bottom: 1px solid var(--line);
}
.wizard[data-layout="vertical"] .steps { flex-direction: row; align-items: flex-start; }
.wizard[data-layout="vertical"] .step { flex-direction: column; text-align: center; gap: 8px; padding: 6px 2px; }
.wizard[data-layout="vertical"] .step.is-active { background: transparent; box-shadow: none; }
.wizard[data-layout="vertical"] .step:not(:last-child)::after { display: none; }
.wizard[data-layout="vertical"] .step .step-meta { display: none; }
.wizard[data-layout="vertical"] .progress { margin-top: 16px; padding-top: 0; }
}
@media (max-width: 520px) {
.page { padding: 18px 14px 48px; }
.topbar { gap: 12px; }
.topbar-tools { width: 100%; }
.panel-wrap { padding: 22px 18px 18px; }
.stepper { padding: 18px 16px; }
.grid { grid-template-columns: 1fr; }
.panel-title { font-size: 21px; }
.step-meta { display: none !important; }
.actions { flex-direction: row; }
.btn { padding: 11px 14px; font-size: 13.5px; }
.btn-text { display: none; }
.review-row { flex-direction: column; align-items: flex-start; gap: 4px; }
.review-row dd { text-align: left; max-width: 100%; }
.review-row dd.tags { justify-content: flex-start; }
}(function () {
"use strict";
var TOTAL = 4; // form steps (0..3); index 3 is review
var current = 0;
// Persisted wizard state
var state = {
fullName: "",
email: "",
password: "",
workspace: "",
slug: "",
teamSize: "",
invites: [], // [{email}]
};
var wizard = document.querySelector(".wizard");
var form = document.getElementById("wizardForm");
var stepsEls = Array.prototype.slice.call(document.querySelectorAll(".step"));
var panels = Array.prototype.slice.call(document.querySelectorAll(".panel[data-panel]"));
var donePanel = document.querySelector('.panel[data-panel="done"]');
var actions = document.getElementById("actions");
var backBtn = document.getElementById("backBtn");
var nextBtn = document.getElementById("nextBtn");
var skipBtn = document.getElementById("skipBtn");
var progressFill = document.getElementById("progressFill");
var progressLabel = document.getElementById("progressLabel");
var progressTrack = document.querySelector(".progress-track");
/* ---------- Toast helper ---------- */
var toastWrap = document.getElementById("toastWrap");
function toast(msg) {
var el = document.createElement("div");
el.className = "toast";
el.innerHTML =
'<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><path d="m4 12 5 5L20 6"/></svg>';
var span = document.createElement("span");
span.textContent = msg;
el.appendChild(span);
toastWrap.appendChild(el);
setTimeout(function () {
el.classList.add("out");
setTimeout(function () { el.remove(); }, 250);
}, 2400);
}
/* ---------- Variant switchers ---------- */
function wireSegments(attr) {
document.querySelectorAll("[data-" + attr + "]").forEach(function (btn) {
btn.addEventListener("click", function () {
var group = btn.closest(".seg");
group.querySelectorAll(".seg-btn").forEach(function (b) {
b.classList.remove("is-active");
b.setAttribute("aria-selected", "false");
});
btn.classList.add("is-active");
btn.setAttribute("aria-selected", "true");
wizard.setAttribute("data-" + attr, btn.getAttribute("data-" + attr));
updateProgress();
});
});
}
wireSegments("layout");
wireSegments("progress");
/* ---------- Validation ---------- */
function setError(name, msg) {
var errEl = document.querySelector('[data-error="' + name + '"]');
if (errEl) errEl.textContent = msg || "";
if (errEl) {
var field = errEl.closest(".field");
if (field) field.classList.toggle("has-error", !!msg);
}
}
function validateStep(step) {
var ok = true;
if (step === 0) {
if (!state.fullName.trim()) { setError("fullName", "Please enter your name."); ok = false; }
else setError("fullName", "");
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(state.email)) { setError("email", "Enter a valid email address."); ok = false; }
else setError("email", "");
if (state.password.length < 8) { setError("password", "Password must be at least 8 characters."); ok = false; }
else setError("password", "");
} else if (step === 1) {
if (!state.workspace.trim()) { setError("workspace", "Give your workspace a name."); ok = false; }
else setError("workspace", "");
if (!/^[a-z0-9-]{2,}$/.test(state.slug)) { setError("slug", "Use lowercase letters, numbers and dashes (2+)."); ok = false; }
else setError("slug", "");
if (!state.teamSize) { setError("teamSize", "Pick a team size."); ok = false; }
else setError("teamSize", "");
}
// step 2 (invites) is optional; step 3 is review
return ok;
}
/* ---------- Input bindings (persist values) ---------- */
function bindInput(id, key, transform) {
var el = document.getElementById(id);
if (!el) return;
el.addEventListener("input", function () {
var v = transform ? transform(el.value) : el.value;
if (transform && v !== el.value) el.value = v;
state[key] = v;
// live-clear error once it becomes valid
if (el.closest(".field") && el.closest(".field").classList.contains("has-error")) {
validateStep(current);
}
});
}
bindInput("fullName", "fullName");
bindInput("email", "email");
bindInput("password", "password");
bindInput("workspace", "workspace", function (v) {
// auto-suggest slug if untouched
var auto = v.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
var slugEl = document.getElementById("slug");
if (slugEl && !slugEl.dataset.touched) { slugEl.value = auto; state.slug = auto; }
return v;
});
var slugEl = document.getElementById("slug");
slugEl.addEventListener("input", function () {
slugEl.dataset.touched = "1";
var v = slugEl.value.toLowerCase().replace(/[^a-z0-9-]/g, "");
slugEl.value = v;
state.slug = v;
if (slugEl.closest(".field").classList.contains("has-error")) validateStep(1);
});
/* ---------- Team size chips (radiogroup) ---------- */
var chips = Array.prototype.slice.call(document.querySelectorAll(".chip"));
chips.forEach(function (chip, i) {
chip.addEventListener("click", function () { selectChip(chip); });
chip.addEventListener("keydown", function (e) {
var idx = chips.indexOf(chip);
if (e.key === "ArrowRight" || e.key === "ArrowDown") {
e.preventDefault();
chips[(idx + 1) % chips.length].focus();
} else if (e.key === "ArrowLeft" || e.key === "ArrowUp") {
e.preventDefault();
chips[(idx - 1 + chips.length) % chips.length].focus();
} else if (e.key === " " || e.key === "Enter") {
e.preventDefault();
selectChip(chip);
}
});
});
function selectChip(chip) {
chips.forEach(function (c) {
c.setAttribute("aria-checked", "false");
c.tabIndex = -1;
});
chip.setAttribute("aria-checked", "true");
chip.tabIndex = 0;
state.teamSize = chip.getAttribute("data-value");
setError("teamSize", "");
}
if (chips[0]) chips[0].tabIndex = 0;
/* ---------- Invites ---------- */
var inviteEmail = document.getElementById("inviteEmail");
var inviteList = document.getElementById("inviteList");
var addInvite = document.getElementById("addInvite");
var AVATAR_COLORS = ["#5b5bf0", "#00b4a6", "#d98a2b", "#d4503e", "#3a3ab8", "#2f9e6f"];
function renderInvites() {
inviteList.innerHTML = "";
if (!state.invites.length) {
var empty = document.createElement("li");
empty.className = "invite-empty";
empty.textContent = "No invites yet — add a teammate or skip this step.";
inviteList.appendChild(empty);
return;
}
state.invites.forEach(function (inv, i) {
var li = document.createElement("li");
li.className = "invite-item";
var initials = inv.email.slice(0, 2).toUpperCase();
var color = AVATAR_COLORS[i % AVATAR_COLORS.length];
var av = document.createElement("span");
av.className = "invite-avatar";
av.style.background = color;
av.textContent = initials;
var em = document.createElement("span");
em.className = "invite-email";
em.textContent = inv.email;
var role = document.createElement("span");
role.className = "invite-role";
role.textContent = "Member";
var rm = document.createElement("button");
rm.type = "button";
rm.className = "invite-remove";
rm.setAttribute("aria-label", "Remove " + inv.email);
rm.innerHTML =
'<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"><path d="M18 6 6 18M6 6l12 12"/></svg>';
rm.addEventListener("click", function () {
state.invites.splice(i, 1);
renderInvites();
toast("Invite removed");
});
li.appendChild(av);
li.appendChild(em);
li.appendChild(role);
li.appendChild(rm);
inviteList.appendChild(li);
});
}
function tryAddInvite() {
var v = inviteEmail.value.trim().toLowerCase();
if (!v) return;
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v)) { toast("That doesn't look like a valid email"); return; }
if (state.invites.some(function (x) { return x.email === v; })) { toast("Already on the list"); return; }
state.invites.push({ email: v });
inviteEmail.value = "";
renderInvites();
toast("Added " + v);
}
addInvite.addEventListener("click", tryAddInvite);
inviteEmail.addEventListener("keydown", function (e) {
if (e.key === "Enter") { e.preventDefault(); tryAddInvite(); }
});
renderInvites();
/* ---------- Review ---------- */
function buildReview() {
var review = document.getElementById("review");
review.innerHTML = "";
var rows = [
{ label: "Name", value: state.fullName, step: 0 },
{ label: "Email", value: state.email, step: 0 },
{ label: "Password", value: "•".repeat(Math.max(8, state.password.length)), step: 0 },
{ label: "Workspace", value: state.workspace, step: 1 },
{ label: "URL", value: "orbital.app/" + state.slug, step: 1 },
{ label: "Team size", value: state.teamSize, step: 1 },
{ label: "Invites", value: state.invites, step: 2, tags: true },
];
rows.forEach(function (r) {
var row = document.createElement("div");
row.className = "review-row";
var dt = document.createElement("dt");
dt.textContent = r.label;
var dd = document.createElement("dd");
if (r.tags) {
dd.className = "tags";
if (!r.value.length) {
dd.textContent = "None added";
dd.className = "";
} else {
r.value.forEach(function (inv) {
var t = document.createElement("span");
t.className = "review-tag";
t.textContent = inv.email;
dd.appendChild(t);
});
}
} else {
dd.textContent = r.value;
}
var edit = document.createElement("button");
edit.type = "button";
edit.className = "review-edit";
edit.textContent = "Edit";
edit.addEventListener("click", function () { goTo(r.step); });
var wrap = document.createElement("div");
wrap.style.display = "flex";
wrap.style.alignItems = "center";
wrap.style.gap = "12px";
wrap.appendChild(dd);
wrap.appendChild(edit);
row.appendChild(dt);
row.appendChild(wrap);
review.appendChild(row);
});
}
/* ---------- Progress + stepper UI ---------- */
function updateProgress() {
var mode = wizard.getAttribute("data-progress");
var pct = Math.round((current / TOTAL) * 100);
progressFill.style.width = pct + "%";
progressTrack.setAttribute("aria-valuenow", String(pct));
if (mode === "percent") {
progressLabel.textContent = pct + "% complete";
} else {
progressLabel.textContent = "Step " + (current + 1) + " of " + TOTAL;
}
}
function updateSteps() {
stepsEls.forEach(function (el, i) {
el.classList.toggle("is-active", i === current);
el.classList.toggle("is-done", i < current);
});
}
/* ---------- Navigation ---------- */
function showPanel(idx) {
panels.forEach(function (p) {
p.hidden = parseInt(p.getAttribute("data-panel"), 10) !== idx;
if (parseInt(p.getAttribute("data-panel"), 10) === idx) {
p.classList.add("is-active");
} else {
p.classList.remove("is-active");
}
});
}
function goTo(idx) {
current = idx;
showPanel(idx);
updateSteps();
updateProgress();
backBtn.disabled = idx === 0;
skipBtn.hidden = idx !== 2; // only on invites step
if (idx === TOTAL - 1) {
buildReview();
nextBtn.innerHTML =
'Launch workspace <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="m5 13 4 4L19 7"/></svg>';
} else {
nextBtn.innerHTML =
'Continue <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="m9 18 6-6-6-6"/></svg>';
}
// focus first input for keyboard users
var first = panels[idx] && panels[idx].querySelector("input, .chip[tabindex='0'], button");
if (first && idx !== TOTAL - 1) setTimeout(function () { first.focus({ preventScroll: true }); }, 60);
}
nextBtn.addEventListener("click", function () {
if (current < TOTAL - 1) {
if (!validateStep(current)) {
toast("Please fix the highlighted fields");
var firstErr = panels[current].querySelector(".has-error input");
if (firstErr) firstErr.focus();
return;
}
goTo(current + 1);
} else {
finish();
}
});
backBtn.addEventListener("click", function () {
if (current > 0) goTo(current - 1);
});
skipBtn.addEventListener("click", function () {
state.invites = [];
renderInvites();
goTo(current + 1);
toast("Skipped invites — you can add people later");
});
// Enter advances (except inside invite/textarea handled separately)
form.addEventListener("keydown", function (e) {
if (e.key === "Enter" && e.target.id !== "inviteEmail" && e.target.tagName !== "BUTTON") {
e.preventDefault();
nextBtn.click();
}
});
/* ---------- Finish + confetti ---------- */
function finish() {
panels.forEach(function (p) { p.hidden = true; p.classList.remove("is-active"); });
actions.hidden = true;
donePanel.hidden = false;
donePanel.classList.add("is-active");
stepsEls.forEach(function (el) { el.classList.add("is-done"); el.classList.remove("is-active"); });
progressFill.style.width = "100%";
progressTrack.setAttribute("aria-valuenow", "100");
progressLabel.textContent =
wizard.getAttribute("data-progress") === "percent" ? "100% complete" : "Setup complete";
var lead = document.getElementById("doneLead");
var count = state.invites.length;
lead.textContent =
"“" + (state.workspace || "Your workspace") + "” is ready" +
(count ? " and " + count + " invite" + (count > 1 ? "s are" : " is") + " on the way." : ". You can invite teammates anytime.");
runConfetti();
toast("Workspace created successfully");
}
document.getElementById("goDashboard").addEventListener("click", function () {
toast("Opening dashboard…");
});
document.getElementById("restart").addEventListener("click", function () {
// reset state
state = { fullName: "", email: "", password: "", workspace: "", slug: "", teamSize: "", invites: [] };
form.reset();
delete slugEl.dataset.touched;
chips.forEach(function (c) { c.setAttribute("aria-checked", "false"); });
renderInvites();
Array.prototype.slice.call(document.querySelectorAll(".has-error")).forEach(function (f) { f.classList.remove("has-error"); });
donePanel.hidden = true;
donePanel.classList.remove("is-active");
actions.hidden = false;
goTo(0);
toast("Wizard reset");
});
/* ---------- Confetti (vanilla canvas) ---------- */
var canvas = document.getElementById("confetti");
var ctx = canvas.getContext("2d");
var pieces = [];
var rafId = null;
function resizeCanvas() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
}
window.addEventListener("resize", resizeCanvas);
resizeCanvas();
function runConfetti() {
var colors = ["#5b5bf0", "#00b4a6", "#d98a2b", "#2f9e6f", "#4646d6", "#d4503e"];
pieces = [];
for (var i = 0; i < 140; i++) {
pieces.push({
x: Math.random() * canvas.width,
y: -20 - Math.random() * canvas.height * 0.4,
w: 6 + Math.random() * 7,
h: 8 + Math.random() * 8,
color: colors[(Math.random() * colors.length) | 0],
vy: 2 + Math.random() * 3.5,
vx: -1.5 + Math.random() * 3,
rot: Math.random() * Math.PI,
vr: -0.12 + Math.random() * 0.24,
life: 1,
});
}
if (rafId) cancelAnimationFrame(rafId);
var start = performance.now();
(function tick(now) {
var elapsed = now - start;
ctx.clearRect(0, 0, canvas.width, canvas.height);
var alive = false;
pieces.forEach(function (p) {
p.x += p.vx;
p.y += p.vy;
p.vy += 0.03;
p.rot += p.vr;
if (elapsed > 2600) p.life -= 0.02;
if (p.y < canvas.height + 40 && p.life > 0) alive = true;
ctx.save();
ctx.globalAlpha = Math.max(0, p.life);
ctx.translate(p.x, p.y);
ctx.rotate(p.rot);
ctx.fillStyle = p.color;
ctx.fillRect(-p.w / 2, -p.h / 2, p.w, p.h);
ctx.restore();
});
if (alive) rafId = requestAnimationFrame(tick);
else ctx.clearRect(0, 0, canvas.width, canvas.height);
})(start);
}
/* ---------- Global Esc (clear focus from overlays / inputs) ---------- */
document.addEventListener("keydown", function (e) {
if (e.key === "Escape" && document.activeElement && document.activeElement.blur) {
document.activeElement.blur();
}
});
/* ---------- Init ---------- */
goTo(0);
})();<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Onboarding — Multi-step setup wizard</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
<main class="page">
<header class="topbar">
<div class="brand">
<span class="brand-mark" aria-hidden="true">
<svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<path d="M12 2 4 6v6c0 5 3.5 8 8 10 4.5-2 8-5 8-10V6z" />
<path d="m9 12 2 2 4-4" />
</svg>
</span>
<div class="brand-text">
<strong>Orbital</strong>
<span>Workspace setup</span>
</div>
</div>
<div class="topbar-tools" role="group" aria-label="Layout variants">
<div class="seg" role="tablist" aria-label="Stepper layout">
<button class="seg-btn is-active" role="tab" aria-selected="true" data-layout="horizontal">Horizontal</button>
<button class="seg-btn" role="tab" aria-selected="false" data-layout="vertical">Vertical</button>
</div>
<div class="seg" role="tablist" aria-label="Progress indicator">
<button class="seg-btn is-active" role="tab" aria-selected="true" data-progress="percent">Percent</button>
<button class="seg-btn" role="tab" aria-selected="false" data-progress="count">Step count</button>
</div>
</div>
</header>
<section class="wizard" data-layout="horizontal" data-progress="percent" aria-label="Setup wizard">
<!-- Stepper -->
<nav class="stepper" aria-label="Progress">
<ol class="steps" id="steps">
<li class="step is-active" data-step="0">
<span class="step-dot" aria-hidden="true">1</span>
<span class="step-meta">
<span class="step-title">Account</span>
<span class="step-sub">Your details</span>
</span>
</li>
<li class="step" data-step="1">
<span class="step-dot" aria-hidden="true">2</span>
<span class="step-meta">
<span class="step-title">Workspace</span>
<span class="step-sub">Name & size</span>
</span>
</li>
<li class="step" data-step="2">
<span class="step-dot" aria-hidden="true">3</span>
<span class="step-meta">
<span class="step-title">Invite team</span>
<span class="step-sub">Add people</span>
</span>
</li>
<li class="step" data-step="3">
<span class="step-dot" aria-hidden="true">4</span>
<span class="step-meta">
<span class="step-title">Review</span>
<span class="step-sub">Confirm setup</span>
</span>
</li>
</ol>
<div class="progress">
<div class="progress-track" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0" aria-label="Setup progress">
<span class="progress-fill" id="progressFill" style="width:0%"></span>
</div>
<span class="progress-label" id="progressLabel" aria-live="polite">0% complete</span>
</div>
</nav>
<!-- Panels -->
<div class="panel-wrap">
<form id="wizardForm" novalidate>
<!-- Step 1: Account -->
<section class="panel is-active" data-panel="0" aria-label="Account">
<div class="panel-head">
<span class="panel-kicker">Step 1 of 4</span>
<h1 class="panel-title">Create your account</h1>
<p class="panel-lead">Tell us who you are. You can change any of this later in settings.</p>
</div>
<div class="grid">
<label class="field">
<span class="field-label">Full name</span>
<input type="text" name="fullName" id="fullName" placeholder="Mara Velez" autocomplete="name" />
<span class="field-error" data-error="fullName"></span>
</label>
<label class="field">
<span class="field-label">Work email</span>
<input type="email" name="email" id="email" placeholder="[email protected]" autocomplete="email" />
<span class="field-error" data-error="email"></span>
</label>
<label class="field field--full">
<span class="field-label">Password</span>
<input type="password" name="password" id="password" placeholder="At least 8 characters" autocomplete="new-password" />
<span class="field-hint" id="pwHint">Use 8+ characters with a mix of letters and numbers.</span>
<span class="field-error" data-error="password"></span>
</label>
</div>
</section>
<!-- Step 2: Workspace -->
<section class="panel" data-panel="1" aria-label="Workspace" hidden>
<div class="panel-head">
<span class="panel-kicker">Step 2 of 4</span>
<h1 class="panel-title">Name your workspace</h1>
<p class="panel-lead">This is where your team will collaborate. Pick something memorable.</p>
</div>
<div class="grid">
<label class="field field--full">
<span class="field-label">Workspace name</span>
<input type="text" name="workspace" id="workspace" placeholder="Northwind Labs" autocomplete="organization" />
<span class="field-error" data-error="workspace"></span>
</label>
<label class="field field--full">
<span class="field-label">Workspace URL</span>
<div class="input-affix">
<span class="affix">orbital.app/</span>
<input type="text" name="slug" id="slug" placeholder="northwind" autocomplete="off" spellcheck="false" />
</div>
<span class="field-error" data-error="slug"></span>
</label>
<fieldset class="field field--full chooser">
<legend class="field-label">Team size</legend>
<div class="chips" role="radiogroup" aria-label="Team size">
<button type="button" class="chip" role="radio" aria-checked="false" data-name="teamSize" data-value="Just me">Just me</button>
<button type="button" class="chip" role="radio" aria-checked="false" data-name="teamSize" data-value="2–10">2–10</button>
<button type="button" class="chip" role="radio" aria-checked="false" data-name="teamSize" data-value="11–50">11–50</button>
<button type="button" class="chip" role="radio" aria-checked="false" data-name="teamSize" data-value="50+">50+</button>
</div>
<span class="field-error" data-error="teamSize"></span>
</fieldset>
</div>
</section>
<!-- Step 3: Invite team -->
<section class="panel" data-panel="2" aria-label="Invite team" hidden>
<div class="panel-head">
<span class="panel-kicker">Step 3 of 4</span>
<h1 class="panel-title">Invite your team</h1>
<p class="panel-lead">Add teammates by email. This step is optional — you can invite people anytime.</p>
</div>
<div class="grid">
<div class="field field--full">
<span class="field-label">Add by email</span>
<div class="invite-row">
<input type="email" id="inviteEmail" placeholder="[email protected]" autocomplete="off" />
<button type="button" class="btn btn-ghost" id="addInvite">
<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"><path d="M12 5v14M5 12h14"/></svg>
Add
</button>
</div>
<span class="field-hint">Press Enter to add. We’ll send invites when setup finishes.</span>
</div>
<ul class="invite-list" id="inviteList" aria-live="polite" aria-label="Pending invites"></ul>
</div>
</section>
<!-- Step 4: Review -->
<section class="panel" data-panel="3" aria-label="Review" hidden>
<div class="panel-head">
<span class="panel-kicker">Step 4 of 4</span>
<h1 class="panel-title">Review & finish</h1>
<p class="panel-lead">Double-check everything below, then launch your workspace.</p>
</div>
<dl class="review" id="review"></dl>
</section>
</form>
<!-- Completion -->
<section class="panel done" data-panel="done" aria-label="Setup complete" hidden>
<div class="done-icon" aria-hidden="true">
<svg viewBox="0 0 24 24" width="40" height="40" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round">
<path d="m4 12 5 5L20 6"/>
</svg>
</div>
<h1 class="done-title">You’re all set! 🎉</h1>
<p class="done-lead" id="doneLead">Your workspace is ready. We’ve sent the invites and a confirmation email.</p>
<div class="done-actions">
<button type="button" class="btn btn-primary" id="goDashboard">Go to dashboard</button>
<button type="button" class="btn btn-ghost" id="restart">Restart wizard</button>
</div>
</section>
<!-- Footer nav -->
<footer class="actions" id="actions">
<button type="button" class="btn btn-ghost" id="backBtn" disabled>
<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="m15 18-6-6 6-6"/></svg>
Back
</button>
<div class="actions-right">
<button type="button" class="btn btn-text" id="skipBtn" hidden>Skip for now</button>
<button type="button" class="btn btn-primary" id="nextBtn">
Continue
<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="m9 18 6-6-6-6"/></svg>
</button>
</div>
</footer>
</div>
</section>
</main>
<canvas id="confetti" aria-hidden="true"></canvas>
<div class="toast-wrap" id="toastWrap" aria-live="polite" aria-atomic="true"></div>
<script src="script.js"></script>
</body>
</html>Multi-step setup wizard
A complete product onboarding flow rendered as a single self-contained page. Four steps — Account, Workspace, Invite team, and Review — sit inside a card with a progress stepper across the top, a per-step form body, and a persistent Back / Continue footer. Each step validates before it lets you advance: the Account step checks name, email and an 8-character password; the Workspace step requires a name, a lowercase URL slug (auto-suggested from the workspace name), and a team-size choice from a keyboard-navigable chip radiogroup. The invite step is optional and offers a Skip-for-now shortcut.
All entered values persist in a single state object, so moving backward and forward never loses data. Invites are added by email (with validation and de-duplication) and rendered as removable rows with coloured avatar initials. The final Review step builds a summary list with inline Edit links that jump straight back to the relevant step, and launching the workspace swaps in a completion screen with an animated check, a contextual message, and a vanilla-canvas confetti burst. A small toast confirms each meaningful action.
Two segmented switchers in the top bar demonstrate the variants live: Horizontal versus Vertical lays the stepper out as a top rail or a left sidebar, and Percent versus Step count swaps the progress bar for an “X of 4” counter. The layout collapses cleanly to a single column down to 360px, with focus-visible rings, ARIA roles on the progress bar and radiogroups, and Esc to drop focus.
Illustrative UI only — fictional names, workspaces, and data.