import React from 'react'; import { clsx } from 'clsx'; import { Card } from '@/components/ui/Card'; import { Skeleton } from '@/components/loading/Skeleton'; interface TableSkeletonProps { rows?: number; columns?: number; hasHeader?: boolean; hasActions?: boolean; hasAvatar?: boolean; className?: string; } /** * Loading skeleton for data tables * Provides flexible column and row configuration with realistic table structure */ export const TableSkeleton: React.FC = ({ rows = 8, columns = 5, hasHeader = true, hasActions = true, hasAvatar = false, className = '' }) => { // Adjust effective columns based on avatar and actions const effectiveColumns = hasActions ? columns : columns; return ( {/* Table header */} {hasHeader && (
{Array.from({ length: effectiveColumns }).map((_, index) => ( ))}
)} {/* Table rows */}
{Array.from({ length: rows }).map((_, rowIndex) => (
{Array.from({ length: effectiveColumns }).map((_, colIndex) => { // First column with optional avatar if (colIndex === 0) { return (
{hasAvatar && }
); } // Last column with actions (if enabled) if (colIndex === effectiveColumns - 1 && hasActions) { return (
); } // Regular data columns with varied widths for realism const widths = ['w-16', 'w-20', 'w-24', 'w-32', 'w-28']; const widthClass = widths[colIndex % widths.length]; return ( ); })}
))}
{/* Table footer (pagination area) */}
); }; export default TableSkeleton;