|
1 | | -import { ArrowUpDown, ExternalLink } from "lucide-react"; |
| 1 | +import { ExternalLink } from "lucide-react"; |
2 | 2 | import { Link } from "react-router"; |
3 | 3 | import { RatingBadge } from "./rating-badge"; |
| 4 | +import { SignalBadge } from "./signal-badge"; |
4 | 5 |
|
5 | | -interface LeaderboardEntry { |
| 6 | +export interface LeaderboardEntry { |
6 | 7 | rank: number; |
7 | 8 | slug: string; |
8 | 9 | name: string; |
9 | 10 | author: string; |
10 | 11 | installs: number; |
11 | 12 | rating: number; |
| 13 | + badges?: string[]; |
12 | 14 | } |
13 | 15 |
|
14 | 16 | interface LeaderboardTableProps { |
15 | 17 | entries: LeaderboardEntry[]; |
16 | | - onSort?: (column: string) => void; |
17 | 18 | } |
18 | 19 |
|
19 | | -export function LeaderboardTable({ entries, onSort }: LeaderboardTableProps) { |
| 20 | +export function LeaderboardTable({ entries }: LeaderboardTableProps) { |
20 | 21 | return ( |
21 | 22 | <div className="overflow-x-auto rounded-lg border border-sx-border"> |
22 | 23 | <table className="w-full"> |
23 | 24 | <thead className="sticky top-0 bg-sx-bg-elevated"> |
24 | 25 | <tr className="border-b border-sx-border"> |
25 | | - <th className="px-4 py-3 text-left"> |
26 | | - <button |
27 | | - onClick={() => onSort?.("rank")} |
28 | | - className="flex items-center gap-1 font-mono text-xs uppercase tracking-wide text-sx-fg-muted hover:text-sx-fg" |
29 | | - > |
30 | | - Rank |
31 | | - <ArrowUpDown size={12} /> |
32 | | - </button> |
| 26 | + <th className="px-4 py-3 text-left font-mono text-xs uppercase tracking-wide text-sx-fg-muted"> |
| 27 | + Rank |
33 | 28 | </th> |
34 | | - <th className="px-4 py-3 text-left"> |
35 | | - <button |
36 | | - onClick={() => onSort?.("skill")} |
37 | | - className="flex items-center gap-1 font-mono text-xs uppercase tracking-wide text-sx-fg-muted hover:text-sx-fg" |
38 | | - > |
39 | | - Skill |
40 | | - <ArrowUpDown size={12} /> |
41 | | - </button> |
| 29 | + <th className="px-4 py-3 text-left font-mono text-xs uppercase tracking-wide text-sx-fg-muted"> |
| 30 | + Skill |
42 | 31 | </th> |
43 | | - <th className="px-4 py-3 text-left"> |
44 | | - <button |
45 | | - onClick={() => onSort?.("author")} |
46 | | - className="flex items-center gap-1 font-mono text-xs uppercase tracking-wide text-sx-fg-muted hover:text-sx-fg" |
47 | | - > |
48 | | - Author |
49 | | - <ArrowUpDown size={12} /> |
50 | | - </button> |
| 32 | + <th className="px-4 py-3 text-left font-mono text-xs uppercase tracking-wide text-sx-fg-muted"> |
| 33 | + Author |
51 | 34 | </th> |
52 | | - <th className="px-4 py-3 text-left"> |
53 | | - <button |
54 | | - onClick={() => onSort?.("installs")} |
55 | | - className="flex items-center gap-1 font-mono text-xs uppercase tracking-wide text-sx-fg-muted hover:text-sx-fg" |
56 | | - > |
57 | | - Installs |
58 | | - <ArrowUpDown size={12} /> |
59 | | - </button> |
| 35 | + <th className="px-4 py-3 text-left font-mono text-xs uppercase tracking-wide text-sx-fg-muted"> |
| 36 | + Installs |
60 | 37 | </th> |
61 | | - <th className="px-4 py-3 text-left"> |
62 | | - <button |
63 | | - onClick={() => onSort?.("rating")} |
64 | | - className="flex items-center gap-1 font-mono text-xs uppercase tracking-wide text-sx-fg-muted hover:text-sx-fg" |
65 | | - > |
66 | | - Rating |
67 | | - <ArrowUpDown size={12} /> |
68 | | - </button> |
| 38 | + <th className="px-4 py-3 text-left font-mono text-xs uppercase tracking-wide text-sx-fg-muted"> |
| 39 | + Rating |
69 | 40 | </th> |
70 | 41 | <th className="px-4 py-3 text-right font-mono text-xs uppercase tracking-wide text-sx-fg-muted"> |
71 | 42 | Actions |
@@ -96,12 +67,17 @@ export function LeaderboardTable({ entries, onSort }: LeaderboardTableProps) { |
96 | 67 | </span> |
97 | 68 | </td> |
98 | 69 | <td className="px-4 py-3"> |
99 | | - <Link |
100 | | - to={`/skills/${entry.slug}`} |
101 | | - className="font-medium text-sx-fg hover:text-sx-accent" |
102 | | - > |
103 | | - {entry.name} |
104 | | - </Link> |
| 70 | + <div className="flex flex-wrap items-center"> |
| 71 | + <Link |
| 72 | + to={`/skills/${entry.slug}`} |
| 73 | + className="font-medium text-sx-fg hover:text-sx-accent" |
| 74 | + > |
| 75 | + {entry.name} |
| 76 | + </Link> |
| 77 | + {entry.badges?.map((b) => ( |
| 78 | + <SignalBadge key={b} type={b} /> |
| 79 | + ))} |
| 80 | + </div> |
105 | 81 | </td> |
106 | 82 | <td className="px-4 py-3 text-sm text-sx-fg-muted"> |
107 | 83 | {entry.author} |
|
0 commit comments