import { Switch, Match, For, Show } from 'solid-js'; import { cn } from '../utils/cn'; export type LoaderVariant = | 'circular' | 'classic' | 'pulse' | 'pulse-dot' | 'dots' | 'typing' | 'wave' | 'bars' | 'terminal' | 'text-blink' | 'text-shimmer' | 'loading-dots'; export type LoaderSize = 'sm' | 'md' | 'lg'; export interface LoaderProps { variant?: LoaderVariant; size?: LoaderSize; text?: string; class?: string; } // --- CircularLoader --- export function CircularLoader(props: { class?: string; size?: LoaderSize }) { const size = () => props.size ?? 'md'; const sizeClasses = { sm: 'size-4', md: 'size-5', lg: 'size-6' }; return (
Loading
); } // --- ClassicLoader --- export function ClassicLoader(props: { class?: string; size?: LoaderSize }) { const size = () => props.size ?? 'md'; const sizeClasses = { sm: 'size-4', md: 'size-5', lg: 'size-6' }; const barSizes = { sm: { height: '6px', width: '1.5px' }, md: { height: '8px', width: '2px' }, lg: { height: '10px', width: '2.5px' }, }; return (
i)}> {(i) => (
)}
Loading
); } // --- PulseLoader --- export function PulseLoader(props: { class?: string; size?: LoaderSize }) { const size = () => props.size ?? 'md'; const sizeClasses = { sm: 'size-4', md: 'size-5', lg: 'size-6' }; return (
Loading
); } // --- PulseDotLoader --- export function PulseDotLoader(props: { class?: string; size?: LoaderSize }) { const size = () => props.size ?? 'md'; const sizeClasses = { sm: 'size-1', md: 'size-2', lg: 'size-3' }; return (
Loading
); } // --- DotsLoader --- export function DotsLoader(props: { class?: string; size?: LoaderSize }) { const size = () => props.size ?? 'md'; const dotSizes = { sm: 'h-1.5 w-1.5', md: 'h-2 w-2', lg: 'h-2.5 w-2.5' }; const containerSizes = { sm: 'h-4', md: 'h-5', lg: 'h-6' }; return (
{(i) => (
)} Loading
); } // --- TypingLoader --- export function TypingLoader(props: { class?: string; size?: LoaderSize }) { const size = () => props.size ?? 'md'; const dotSizes = { sm: 'h-1 w-1', md: 'h-1.5 w-1.5', lg: 'h-2 w-2' }; const containerSizes = { sm: 'h-4', md: 'h-5', lg: 'h-6' }; return (
{(i) => (
)} Loading
); } // --- WaveLoader --- export function WaveLoader(props: { class?: string; size?: LoaderSize }) { const size = () => props.size ?? 'md'; const barWidths = { sm: 'w-0.5', md: 'w-0.5', lg: 'w-1' }; const containerSizes = { sm: 'h-4', md: 'h-5', lg: 'h-6' }; const heights: Record = { sm: ['6px', '9px', '12px', '9px', '6px'], md: ['8px', '12px', '16px', '12px', '8px'], lg: ['10px', '15px', '20px', '15px', '10px'], }; return (
{(i) => (
)} Loading
); } // --- BarsLoader --- export function BarsLoader(props: { class?: string; size?: LoaderSize }) { const size = () => props.size ?? 'md'; const barWidths = { sm: 'w-1', md: 'w-1.5', lg: 'w-2' }; const containerSizes = { sm: 'h-4 gap-1', md: 'h-5 gap-1.5', lg: 'h-6 gap-2' }; return (
{(i) => (
)} Loading
); } // --- TerminalLoader --- export function TerminalLoader(props: { class?: string; size?: LoaderSize }) { const size = () => props.size ?? 'md'; const cursorSizes = { sm: 'h-3 w-1.5', md: 'h-4 w-2', lg: 'h-5 w-2.5' }; const textSizes = { sm: 'text-xs', md: 'text-sm', lg: 'text-base' }; const containerSizes = { sm: 'h-4', md: 'h-5', lg: 'h-6' }; return (
{'>'}
Loading
); } // --- TextBlinkLoader --- export function TextBlinkLoader(props: { text?: string; class?: string; size?: LoaderSize }) { const size = () => props.size ?? 'md'; const textSizes = { sm: 'text-xs', md: 'text-sm', lg: 'text-base' }; return (
{props.text ?? 'Thinking'}
); } // --- TextShimmerLoader --- export function TextShimmerLoader(props: { text?: string; class?: string; size?: LoaderSize }) { const size = () => props.size ?? 'md'; const textSizes = { sm: 'text-xs', md: 'text-sm', lg: 'text-base' }; return (
{props.text ?? 'Thinking'}
); } // --- TextDotsLoader --- export function TextDotsLoader(props: { text?: string; class?: string; size?: LoaderSize }) { const size = () => props.size ?? 'md'; const textSizes = { sm: 'text-xs', md: 'text-sm', lg: 'text-base' }; return (
{props.text ?? 'Thinking'} . . .
); } // --- Loader (variant dispatcher) --- export function Loader(props: LoaderProps) { return ( }> ); }