"use client"; import "./components/ui/tidal.css"; import { useLayoutEffect, useMemo, useRef, useState } from "react"; import { RotateCcw } from "lucide-react"; import { TidalOnboardingChecklist, type TidalOnboardingChecklistStep } from "./components/ui/onboarding-checklist"; import "./components/ui/onboarding-checklist.css"; const tidalExampleStyles = ".tidal-scope .onboarding-checklist-demo,\n.tidal-scope .onboarding-checklist-demo * {\n box-sizing: border-box;\n}\n\n.tidal-scope .onboarding-checklist-demo {\n width: 100%;\n max-width: 1060px;\n min-width: 0;\n padding: clamp(12px, 3vw, 34px);\n color: var(--t-ink);\n background:\n linear-gradient(var(--t-border) 1px, transparent 1px),\n linear-gradient(90deg, var(--t-border) 1px, transparent 1px),\n var(--t-subtle);\n background-size: 28px 28px;\n border: 1px solid var(--t-border);\n border-radius: 18px;\n container: onboarding-demo / inline-size;\n}\n\n.tidal-scope .onboarding-checklist-demo-layout,\n.tidal-scope .onboarding-checklist-demo-layout > .tidal-onboarding-checklist {\n max-width: none;\n min-width: 0;\n}\n\n.tidal-scope .onboarding-checklist-demo-footer {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 14px;\n min-width: 0;\n}\n\n.tidal-scope .onboarding-checklist-demo-footer > span {\n min-width: 0;\n overflow-wrap: anywhere;\n}\n\n.tidal-scope .onboarding-checklist-demo-footer > button {\n gap: 7px;\n flex: none;\n padding: 9px 11px;\n color: var(--t-ink);\n background: var(--t-surface);\n border: 1px solid var(--t-border);\n border-radius: 10px;\n font: inherit;\n font-size: 11px;\n cursor: pointer;\n transition:\n background 160ms,\n transform 140ms var(--t-ease-out);\n}\n\n.tidal-scope .onboarding-checklist-demo-footer > button:hover {\n background: var(--t-wash);\n}\n\n.tidal-scope .onboarding-checklist-demo-footer > button:active {\n transform: scale(0.98);\n}\n\n@container onboarding-demo (max-width: 520px) {\n\n .tidal-scope .onboarding-checklist-demo-footer {\n align-items: flex-start;\n flex-direction: column;\n }\n\n .tidal-scope .onboarding-checklist-demo-footer > button {\n width: 100%;\n }\n}\n\n@media (max-width: 390px) {\n .tidal-scope .onboarding-checklist-demo {\n padding: 8px;\n background-size: 20px 20px;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .tidal-scope .onboarding-checklist-demo-footer > button {\n transition: none;\n transform: none;\n }\n}"; const STEP_ORDER = ["name", "review", "board", "invite"] as const; const LOCAL_RESULTS: Record<(typeof STEP_ORDER)[number], string> = { name: "The sample workspace name is prepared locally. Nothing was saved.", review: "A weekly review rhythm is selected for this preview only.", board: "A sample planning board is now visible in local state.", invite: "The invite note is previewed locally. No message or account was created.", }; export function OnboardingChecklistDemo() { const [completed, setCompleted] = useState>( () => new Set(["name"]), ); const [expandedStepId, setExpandedStepId] = useState("review"); const [notice, setNotice] = useState( "One sample step is ready. Changes stay in this preview.", ); const nameActionRef = useRef(null); const reviewActionRef = useRef(null); const boardActionRef = useRef(null); const inviteActionRef = useRef(null); const resetButtonRef = useRef(null); const pendingFocusRef = useRef<(typeof STEP_ORDER)[number] | "reset" | null>( null, ); useLayoutEffect(() => { const pendingFocus = pendingFocusRef.current; if (!pendingFocus) return; const target = pendingFocus === "reset" ? resetButtonRef.current : { name: nameActionRef.current, review: reviewActionRef.current, board: boardActionRef.current, invite: inviteActionRef.current, }[pendingFocus]; target?.focus({ preventScroll: true }); pendingFocusRef.current = null; }, [completed]); const currentStepId = STEP_ORDER.find( (id) => id !== "invite" && !completed.has(id), ); const steps = useMemo( () => [ { id: "name", title: "Name the workspace", description: "Use a clear label for the local setup preview.", details: (

Sample value: Northstar workspace. It exists only in this rendered demo.

), completed: completed.has("name"), actionLabel: completed.has("name") ? "Complete" : "Use sample name", actionButtonProps: { disabled: completed.has("name") }, actionRef: nameActionRef, }, { id: "review", title: "Choose a review rhythm", description: "Set a simple cadence for checking the sample workspace.", details: (

Weekly review is the local sample choice. No calendar event or reminder is created.

), completed: completed.has("review"), actionLabel: completed.has("review") ? "Complete" : "Choose weekly", actionButtonProps: { disabled: completed.has("review") }, actionRef: reviewActionRef, }, { id: "board", title: "Add a planning board", description: "Prepare one local board for priorities and open work.", details: (

The board contains three fictional columns: Planned, In progress, and Ready for review.

), completed: completed.has("board"), actionLabel: completed.has("board") ? "Complete" : "Add sample board", actionButtonProps: { disabled: completed.has("board") }, actionRef: boardActionRef, }, { id: "invite", title: "Preview an invite note", description: "Review wording without contacting anyone.", details: (

The preview names a fictional teammate and never sends, stores, or logs the message.

), optional: true, completed: completed.has("invite"), actionLabel: completed.has("invite") ? "Complete" : "Preview note", actionButtonProps: { disabled: completed.has("invite") }, actionRef: inviteActionRef, }, ], [completed], ); function completeStep(step: TidalOnboardingChecklistStep) { if (step.completed) return; const nextCompleted = new Set(completed).add(step.id); setCompleted(nextCompleted); const nextStep = STEP_ORDER.find((id) => !nextCompleted.has(id)); pendingFocusRef.current = nextStep ?? "reset"; setExpandedStepId(nextStep ?? null); setNotice( LOCAL_RESULTS[step.id as (typeof STEP_ORDER)[number]] ?? "The sample step changed locally.", ); } function resetPreview() { pendingFocusRef.current = "review"; setCompleted(new Set(["name"])); setExpandedStepId("review"); setNotice("Local setup reset. No account or saved workspace was changed."); } return (
{notice}
} />
); } export default function AgentExample() { return (
); }