Skip to content
File

Blob: app/components/GridTable.jsx

javascript39 lines
1import { formatCell } from "../../lib/sqlDumpUtils";
2 
3export default function GridTable({ columns, rows }) {
4 if (!columns.length) {
5 return <p className="px-4 py-6 text-center text-sm text-zinc-600">No columns.</p>;
6 }
7 
8 return (
9 <table className="w-max min-w-full border-collapse">
10 <thead>
11 <tr>
12 {columns.map((column) => (
13 <th
14 key={column}
15 className="sticky top-0 z-10 border-b border-zinc-800/60 bg-zinc-900 px-3 py-2 text-left text-xs font-semibold uppercase tracking-wider text-zinc-500"
16 >
17 {column}
18 </th>
19 ))}
20 </tr>
21 </thead>
22 <tbody>
23 {rows.map((row, rowIndex) => (
24 <tr key={rowIndex} className="hover:bg-zinc-800/30">
25 {row.map((value, colIndex) => (
26 <td
27 key={`${rowIndex}-${colIndex}`}
28 className="max-w-xs break-words border-b border-zinc-800/40 px-3 py-2 text-sm text-zinc-300"
29 >
30 {formatCell(value)}
31 </td>
32 ))}
33 </tr>
34 ))}
35 </tbody>
36 </table>
37 );
38}