-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTopicLeaderboards.jsx
61 lines (60 loc) · 1.88 KB
/
TopicLeaderboards.jsx
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
52
53
54
55
56
57
58
59
60
61
export function Table({ topics, fieldName, fieldKey }) {
if (topics.length === 0) return ''
return (
<div className="overflow-auto">
<table className="table-auto prose-td:align-middle prose-p:mb-0 prose-p:mt-1">
<thead>
<tr>
<th>#</th>
<th>Topic</th>
<th>Released</th>
<th>{fieldName}</th>
</tr>
</thead>
<tbody>
{topics.map((topic, i) => {
const {
rank,
name,
display_name,
short_description,
created_by,
released,
created_at,
html_url
} = topic
return (
<tr key={i}>
<td className="font-bold text-lg">{rank}</td>
<td>
<a
className="no-underline hover:underline"
href={html_url}
target="_blank"
title={`${name}${
short_description ? ` - ${short_description}` : ''
}`}
>
<strong className="font-bold">{display_name}</strong> <br />
<span className="text-gray-400">#{name}</span>
</a>
{created_by && (
<p>
Created by <strong>{created_by}</strong>
</p>
)}
{created_at && (
<p>Created at {new Date(created_at).toUTCString()}</p>
)}
{short_description && <p>{short_description}</p>}
</td>
<td>{released ? released : '-'}</td>
<td>{new Intl.NumberFormat().format(topic[fieldKey])}</td>
</tr>
)
})}
</tbody>
</table>
</div>
)
}