import React, { type ReactNode } from 'react'; import { classNames } from '../../../utils'; import styles from './SkeletonTable.module.css'; import tableStyles from '../../../theme/table.module.css'; export type Column = { width?: number | string; cell: ReactNode; }; export type SkeletonTableProps = { /** * className for the element. */ className?: string; /** * The amount of table rows to display. * @default 5 */ numberOfRows?: number; /** * The size of the rows. * @default normal */ rowHeight?: 'normal' | 'compact'; /** * Whether the columns should be separated by a line. */ withColumnSeparator?: boolean; } & ( | { /** * Whether the table should have a header. */ withHeader?: true; /** * The columns to display in the Skeleton. */ columns: (Column & { header: ReactNode })[]; } | { withHeader?: false; columns: Column[]; } ); export const SkeletonTable = ({ className, columns, numberOfRows = 5, rowHeight = 'normal', withColumnSeparator, withHeader, }: SkeletonTableProps) => { return (
|
{column.header}
|
),
)}
|---|
|
{column.cell}
|
),
)}