File size: 1,509 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
import { ReactNode } from 'react'
import { DEFAULT_CONFIG_DATA } from '~/data/fixtures'
import { renderCell } from './TableCell'
import {
firstTableCell,
secondTableCell,
table,
tableHeadCell,
thirdTableCell,
} from './TablesConfig.css'
import clsx from 'clsx'
export type CellData = string | null | { label: string; content: ReactNode }
interface TablesConfigurationProps {
data?: CellData[][]
}
export const TablesConfiguration = ({
data = DEFAULT_CONFIG_DATA,
}: TablesConfigurationProps) => (
<table className={table}>
<thead>
<tr>
<th className={clsx(tableHeadCell, firstTableCell)}>Prop</th>
<th className={clsx(tableHeadCell, secondTableCell)}>Type</th>
<th className={clsx(tableHeadCell, thirdTableCell)}>Default</th>
</tr>
</thead>
<tbody>
{data.map((row, index) => (
<tr key={index}>{row.map(renderCell())}</tr>
))}
</tbody>
</table>
)
interface TableGenericProps extends TablesConfigurationProps {
headData: string[]
}
export const TableGeneric = ({
data = [],
headData = [],
}: TableGenericProps) => (
<table className={table}>
<thead>
<tr>
{headData.map(head =>
head ? (
<th className={tableHeadCell} key={head}>
{head}
</th>
) : null
)}
</tr>
</thead>
<tbody>
{data.map((row, index) => (
<tr key={index}>{row.map(renderCell('generic'))}</tr>
))}
</tbody>
</table>
)
|