forked from PinSpace-Org/GistPin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComparisonTable.tsx
More file actions
51 lines (48 loc) · 1.82 KB
/
Copy pathComparisonTable.tsx
File metadata and controls
51 lines (48 loc) · 1.82 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
39
40
41
42
43
44
45
46
47
48
49
50
51
'use client';
export interface ComparisonRow {
metric: string;
current: number;
previous: number;
delta: number;
pctChange: number;
}
interface ComparisonTableProps {
rows: ComparisonRow[];
currentLabel: string;
previousLabel: string;
}
export default function ComparisonTable({ rows, currentLabel, previousLabel }: ComparisonTableProps) {
return (
<div style={{ overflowX: 'auto', WebkitOverflowScrolling: 'touch' }}>
<table style={{ width: '100%', borderCollapse: 'collapse', minWidth: 480 }}>
<thead>
<tr>
<th style={{ textAlign: 'left', padding: '12px 10px' }}>Metric</th>
<th style={{ textAlign: 'left', padding: '12px 10px' }}>{currentLabel}</th>
<th style={{ textAlign: 'left', padding: '12px 10px' }}>{previousLabel}</th>
<th style={{ textAlign: 'left', padding: '12px 10px' }}>Delta</th>
<th style={{ textAlign: 'left', padding: '12px 10px' }}>% Change</th>
</tr>
</thead>
<tbody>
{rows.map((row) => {
const improved = row.delta >= 0;
return (
<tr key={row.metric} style={{ borderTop: '1px solid #e2e8f0' }}>
<td style={{ padding: '14px 10px', fontWeight: 700 }}>{row.metric}</td>
<td style={{ padding: '14px 10px' }}>{row.current}</td>
<td style={{ padding: '14px 10px' }}>{row.previous}</td>
<td style={{ padding: '14px 10px', color: improved ? '#15803d' : '#b91c1c' }}>
{improved ? '↑' : '↓'} {row.delta}
</td>
<td style={{ padding: '14px 10px', color: improved ? '#15803d' : '#b91c1c' }}>
{row.pctChange}%
</td>
</tr>
);
})}
</tbody>
</table>
</div>
);
}