-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRepoLeaderboards.jsx
59 lines (57 loc) · 1.92 KB
/
RepoLeaderboards.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
import { formatSize } from '../utils/number'
export function Table({ repos, fieldName, fieldKey }) {
if (repos.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>Repo</th>
<th>{fieldName}</th>
</tr>
</thead>
<tbody>
{repos.map((repo, i) => {
const { rank, name, description, html_url, owner } = repo
return (
<tr key={i}>
<td className="font-bold text-lg">{rank}</td>
<td className="flex items-center">
<img
className="rounded-full mr-3 my-0"
loading="lazy"
src={owner.avatar_url + '&size=80'}
alt={owner.login}
width={50}
/>
<div>
<a
className="no-underline hover:underline"
href={html_url}
target="_blank"
title={`${name}${description ? ` - ${description}` : ''}`}
>
<strong className="font-bold">{name}</strong> <br />
<span className="text-gray-400">@{owner.login}</span>
</a>
{description && <p>{description}</p>}
</div>
</td>
<td>
{fieldKey !== 'size' ? (
new Intl.NumberFormat().format(repo[fieldKey])
) : (
<span title={repo[fieldKey] + ' KB'}>
{formatSize(repo[fieldKey])}
</span>
)}
</td>
</tr>
)
})}
</tbody>
</table>
</div>
)
}