/** * LoadingState Component * * Displays loading indicators for different stages of session creation and connection. * Shows appropriate messages and animations based on the current loading state. */ import styles from './LoadingState.module.css'; export type LoadingStateType = 'creating' | 'connecting' | 'reconnecting'; export interface LoadingStateProps { /** * Type of loading state to display */ type: LoadingStateType; /** * Optional additional message to display */ message?: string; /** * Optional className for custom styling */ className?: string; } /** * LoadingState Component * * Usage: * ```tsx * * * * ``` */ export function LoadingState({ type, message, className = '', }: LoadingStateProps) { const getDefaultMessage = () => { switch (type) { case 'creating': return 'Creating session...'; case 'connecting': return 'Connecting to room...'; case 'reconnecting': return 'Reconnecting...'; default: return 'Loading...'; } }; const displayMessage = message || getDefaultMessage(); return (

{displayMessage}

{type === 'reconnecting' && (

Please wait while we restore your connection

)}
); } /** * ConnectionProgressIndicator Component * * Shows a more detailed progress indicator with steps. */ export interface ConnectionProgressProps { currentStep: 'creating' | 'connecting' | 'ready'; className?: string; } export function ConnectionProgressIndicator({ currentStep, className = '', }: ConnectionProgressProps) { const steps = [ { key: 'creating', label: 'Creating session' }, { key: 'connecting', label: 'Connecting to room' }, { key: 'ready', label: 'Ready' }, ]; const currentStepIndex = steps.findIndex((step) => step.key === currentStep); return (
{steps.map((step, index) => (
{index < currentStepIndex ? ( ) : ( {index + 1} )}

{step.label}

))}
); } export default LoadingState;