"use client"; import { Button } from "@mdxui/primitives/button"; import { ArrowLeft, Moon, Sun } from "lucide-react"; import type { ReactNode } from "react"; import { Link } from "react-router-dom"; import { useScroll } from "../lib/use-scroll"; import { cx } from "../lib/utils"; import { useOnboardingOptional } from "./onboarding-context"; // ============================================================================= // WIZARD-AWARE PROGRESS // ============================================================================= interface WizardProgressProps { className?: string; } /** * Progress indicator that automatically derives steps from OnboardingWizard context */ export function WizardProgress({ className }: WizardProgressProps) { const onboarding = useOnboardingOptional(); if (!onboarding) { return null; } const { steps, currentStep } = onboarding; return ( // biome-ignore lint/a11y/useAriaPropsSupportedByRole: we are not using aria-label here
    {steps.map((step, index) => (
  1. {step.name}{" "} {index < currentStep ? "completed" : index === currentStep ? "current" : ""}
  2. ))}
); } // ============================================================================= // THEME TOGGLE // ============================================================================= interface WizardThemeToggleProps { theme?: string; setTheme?: (theme: string) => void; } /** * Theme toggle button - can be used with next-themes or custom theme state */ export function WizardThemeToggle({ theme, setTheme }: WizardThemeToggleProps) { if (!setTheme) { return null; } return ( ); } // ============================================================================= // WIZARD HEADER // ============================================================================= interface WizardHeaderProps { /** Back button href (external link, outside wizard) */ backHref?: string; /** Back button text */ backText?: string; /** Whether the header is collapsed (scrolled) */ collapsed?: boolean; /** Theme for toggle (optional) */ theme?: string; /** Theme setter (optional) */ setTheme?: (theme: string) => void; /** Custom right-side content */ rightContent?: ReactNode; /** Custom back button handler (overrides backHref link) */ onBack?: () => void; } /** * Wizard-aware header with progress indicator * Uses react-router internally and derives progress from wizard context */ export function WizardHeader({ backHref = "/", backText = "Home", collapsed = false, theme, setTheme, rightContent, onBack, }: WizardHeaderProps) { return (
{onBack ? ( ) : ( )}
{rightContent ?? ( )}
); } // ============================================================================= // WIZARD LAYOUT // ============================================================================= interface WizardLayoutProps { children: ReactNode; /** Back button href (external, outside wizard) */ backHref?: string; /** Back button text */ backText?: string; /** Custom header component (replaces default) */ header?: ReactNode; /** Whether to show the default header */ showHeader?: boolean; /** Theme for toggle (optional) */ theme?: string; /** Theme setter (optional) */ setTheme?: (theme: string) => void; /** Custom back button handler */ onBack?: () => void; /** Custom right-side header content */ headerRightContent?: ReactNode; } /** * Layout wrapper that integrates with OnboardingWizard context * Automatically shows progress based on wizard steps * * @example * ```tsx * ( * * {children} * * )} * /> * ``` */ export function WizardLayout({ children, backHref = "/", backText = "Home", header, showHeader = true, theme, setTheme, onBack, headerRightContent, }: WizardLayoutProps) { const scrolled = useScroll(15); return ( <> {showHeader && (header ?? ( ))}
{children}
); }