Files
botsmann/components/shared/LoadingSpinner.tsx
T
g-butandClaude Opus 4.5 5906f625cd refactor: extract shared components for CLAUDE.md compliance
DRY improvements:
- Add LoadingSpinner component (PageLoading, InlineLoading variants)
- Add centralized color config (ACCENT_BORDER_CLASSES, helpers)
- Add shared icons (CheckIcon, ClockIcon, EditIcon, etc.)

Updated files to use shared components:
- All auth pages now use PageLoading instead of inline spinners
- Profile page uses InlineLoading and centralized accent colors
- Settings page uses shared icons (CheckIcon, ChevronRightIcon)

This reduces code duplication across 17+ files for spinners
and 15+ files for accent color mappings.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 17:03:46 +01:00

58 lines
1.2 KiB
TypeScript

/**
* Loading Spinner Component
*
* SSOT for loading spinners across the app.
* Use this instead of duplicating spinner markup.
*/
interface LoadingSpinnerProps {
/** Size variant */
size?: 'sm' | 'md' | 'lg';
/** Whether to center in full screen */
fullScreen?: boolean;
/** Custom className for the spinner */
className?: string;
}
const sizeClasses = {
sm: 'h-4 w-4',
md: 'h-6 w-6',
lg: 'h-8 w-8',
} as const;
export function LoadingSpinner({
size = 'lg',
fullScreen = false,
className,
}: LoadingSpinnerProps) {
const spinner = (
<div
className={`animate-spin rounded-full border-b-2 border-blue-600 ${sizeClasses[size]} ${className || ''}`}
/>
);
if (fullScreen) {
return <div className="min-h-screen flex items-center justify-center">{spinner}</div>;
}
return spinner;
}
/**
* Full page loading state - use for page-level loading
*/
export function PageLoading() {
return <LoadingSpinner size="lg" fullScreen />;
}
/**
* Inline loading state - use within sections
*/
export function InlineLoading({ className }: { className?: string }) {
return (
<div className={`flex justify-center py-8 ${className || ''}`}>
<LoadingSpinner size="md" />
</div>
);
}