forked from nodejs/nodejs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.tsx
More file actions
38 lines (33 loc) · 1.01 KB
/
index.tsx
File metadata and controls
38 lines (33 loc) · 1.01 KB
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
import type { TableData } from '#ui/types';
import type { ResponsiveTableProps } from '..';
import styles from './index.module.css';
import { Card, CardBody, CardHeader } from '../../Card';
function MobileTable<T extends TableData>({
data,
columns,
getRowId,
getRowLabel,
}: ResponsiveTableProps<T>) {
return (
<div role="table" className="space-y-4">
{data.map((row, index) => (
<Card role="rowgroup" key={getRowId(row, index)}>
{getRowLabel && <CardHeader>{getRowLabel(row)}</CardHeader>}
<CardBody role="row">
{columns.map(column => (
<div key={column.key} className={styles.row}>
<div role="columnheader" className={styles.header}>
{column.header}
</div>
<div role="cell" className={styles.value}>
{row[column.key]}
</div>
</div>
))}
</CardBody>
</Card>
))}
</div>
);
}
export default MobileTable;