/ concept-collection / benchcompress
Sign in
concept-collection / benchcompress
benchcompress / web-ui / src / components / benchmark / table / BenchmarkTable.tsx
98 lines · 2.7 KBCodeBlameHistory
eacabc8test real dataJeremy Magland 1import {
2 flexRender,
3 getCoreRowModel,
4 getSortedRowModel,
a2daa82reference compression ratiosJeremy Magland 5 useReactTable,
70a7a71code formattingJeremy Magland 6} from "@tanstack/react-table";
7import { BenchmarkResult } from "../../../types";
8import { exportToCsv } from "../export/csvExport";
a2daa82reference compression ratiosJeremy Magland 9import { columns } from "./columns";
eacabc8test real dataJeremy Magland 10
0968553routingJeremy Magland 11interface BenchmarkTableProps {
12 results: BenchmarkResult[];
eacabc8test real dataJeremy Magland 14
3b1d188improve uiJeremy Magland 15export function BenchmarkTable({ results }: BenchmarkTableProps) {
eacabc8test real dataJeremy Magland 16 const table = useReactTable({
3b1d188improve uiJeremy Magland 17 data: results,
eacabc8test real dataJeremy Magland 18 columns,
19 getCoreRowModel: getCoreRowModel(),
20 getSortedRowModel: getSortedRowModel(),
21 });
23 return (
24 <div className="table-container">
25 <table>
26 <thead>
70a7a71code formattingJeremy Magland 27 {table.getHeaderGroups().map((headerGroup) => (
eacabc8test real dataJeremy Magland 28 <tr key={headerGroup.id}>
70a7a71code formattingJeremy Magland 29 {headerGroup.headers.map((header) => (
eacabc8test real dataJeremy Magland 30 <th
31 key={header.id}
32 onClick={header.column.getToggleSortingHandler()}
70a7a71code formattingJeremy Magland 33 style={{ cursor: "pointer" }}
eacabc8test real dataJeremy Magland 34 >
35 {flexRender(
36 header.column.columnDef.header,
70a7a71code formattingJeremy Magland 37 header.getContext(),
eacabc8test real dataJeremy Magland 38 )}
39 {header.column.getIsSorted() && (
70a7a71code formattingJeremy Magland 40 <span style={{ marginLeft: "4px" }}>
41 {header.column.getIsSorted() === "asc" ? "↑" : "↓"}
eacabc8test real dataJeremy Magland 42 </span>
43 )}
44 </th>
45 ))}
46 </tr>
47 ))}
48 </thead>
49 <tbody>
70a7a71code formattingJeremy Magland 50 {table.getRowModel().rows.map((row) => (
eacabc8test real dataJeremy Magland 51 <tr key={row.id}>
70a7a71code formattingJeremy Magland 52 {row.getVisibleCells().map((cell) => (
eacabc8test real dataJeremy Magland 53 <td key={cell.id}>
54 {flexRender(cell.column.columnDef.cell, cell.getContext())}
55 </td>
56 ))}
57 </tr>
58 ))}
59 </tbody>
60 </table>
a10d266update UIJeremy Magland 61
a3cad9bformat codeJeremy Magland 62 <div
63 style={{
64 marginTop: "12px",
65 display: "flex",
66 justifyContent: "flex-end",
67 }}
68 >
a10d266update UIJeremy Magland 69 <button
3b1d188improve uiJeremy Magland 70 onClick={() => exportToCsv(results, "benchmark_results")}
a10d266update UIJeremy Magland 71 style={{
72 padding: "8px 16px",
73 backgroundColor: "#4CAF50",
74 color: "white",
75 border: "none",
76 borderRadius: "4px",
77 cursor: "pointer",
78 display: "flex",
79 alignItems: "center",
80 gap: "8px",
81 }}
82 >
83 <svg
84 width="16"
85 height="16"
86 viewBox="0 0 16 16"
87 fill="none"
88 xmlns="http://www.w3.org/2000/svg"
89 >
90 <path d="M8 12L3 7H6V1H10V7H13L8 12Z" fill="currentColor" />
91 <path d="M2 14V15H14V14H2Z" fill="currentColor" />
92 </svg>
93 Download CSV
94 </button>
95 </div>
eacabc8test real dataJeremy Magland 96 </div>
97 );
moveopenescclose