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
33 lines (28 loc) · 827 Bytes
/
index.tsx
File metadata and controls
33 lines (28 loc) · 827 Bytes
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
import type { ResponsiveTableProps, TableData } 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 className="space-y-4">
{data.map(row => (
<Card key={getRowId(row)}>
<CardHeader>{getRowLabel(row)}</CardHeader>
<CardBody>
{columns.map(column => (
<div key={column.key} className={styles.row}>
<div className={styles.header}>{column.header}</div>
<div className={styles.value}>{row[column.key]}</div>
</div>
))}
</CardBody>
</Card>
))}
</div>
);
}
export default MobileTable;