/**
* Preloader Component
*
* Universal loading indicator component with multiple variants
* Supports inline, fullscreen, and custom layouts
*/
'use client';
import { Loader2 } from 'lucide-react';
import React from 'react';
import { useAppT } from '@djangocfg/i18n';
import { cn } from '../../../lib/utils';
// Spinner is available for future use
// import { Spinner } from './spinner';
export interface PreloaderProps {
/**
* Loading text to display
* @default undefined (no text)
*/
text?: string;
/**
* Additional description/subtitle text
*/
description?: string;
/**
* Size variant
* @default 'md'
*/
size?: 'sm' | 'md' | 'lg' | 'xl';
/**
* Variant: inline (fits container) or fullscreen (fixed overlay)
* @default 'inline'
*/
variant?: 'inline' | 'fullscreen';
/**
* Show backdrop (only for fullscreen variant)
* @default true
*/
backdrop?: boolean;
/**
* Backdrop opacity (0-100, only for fullscreen with backdrop)
* @default 80
*/
backdropOpacity?: number;
/**
* Additional CSS classes
*/
className?: string;
/**
* Spinner className override
*/
spinnerClassName?: string;
}
const sizeMap = {
sm: 'h-4 w-4',
md: 'h-6 w-6',
lg: 'h-8 w-8',
xl: 'h-12 w-12',
};
/**
* Preloader - Universal loading indicator
*
* Features:
* - Multiple size variants (sm, md, lg, xl)
* - Inline or fullscreen variants
* - Optional text and description
* - Optional backdrop for fullscreen
* - Accessible (ARIA labels)
*
* @example
* ```tsx
* // Inline loading
*
{text}
)} {description && ({description}
)} {/* Animated dots */} {text && ({text}
)} {description && ({description}
)}