Skip to content

Commit a661bbb

Browse files
committed
Enhance Leaderboard UI with improved layout and styling for better user experienceasa
1 parent e2daf5f commit a661bbb

1 file changed

Lines changed: 43 additions & 45 deletions

File tree

src/Page/Leaderboard.jsx

Lines changed: 43 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import projectsData from '../DB/projects.json';
33
import { ArrowLeft } from 'lucide-react';
44
import { useNavigate } from 'react-router-dom';
55

6-
// Calculate leaderboard data
76
const leaderboard = projectsData
87
.map((user) => ({
98
username: user.github_username,
@@ -12,68 +11,67 @@ const leaderboard = projectsData
1211
}))
1312
.sort((a, b) => b.projectCount - a.projectCount);
1413

14+
const trophyColors = ['bg-yellow-400', 'bg-purple-500', 'bg-orange-400'];
15+
1516
const Leaderboard = () => {
1617
const navigate = useNavigate();
1718

1819
return (
19-
<div className="min-h-screen bg-gray-900 p-6 text-white">
20-
<div className="mb-8 flex items-center">
21-
<button
22-
className="flex items-center gap-2 rounded-full border border-white p-2 hover:bg-gray-700"
23-
onClick={() => navigate(-1)}
24-
>
25-
<ArrowLeft className="h-5 w-5" />
26-
<span className="hidden md:inline">Back</span>
27-
</button>
28-
<h1 className="ml-4 text-3xl font-bold">Top Project Builder Leaderboard</h1>
29-
</div>
30-
<div className="mb-8 text-center">
31-
<span className="text-lg font-semibold text-[#00a6fb]">Live Leaderboard (Global)</span>
32-
<img
33-
src="https://d8it4huxumps7.cloudfront.net/uploads/images/66ebce3b69885_leaderboard.svg"
34-
alt="Leaderboard Icon"
35-
className="ml-2 inline-block h-6 align-middle"
36-
style={{ verticalAlign: 'middle' }}
37-
/>
20+
<div className="min-h-screen bg-gray-950 px-4 py-8 text-white">
21+
<div className="mb-10 text-center">
22+
<h1 className="text-4xl font-extrabold text-white sm:text-5xl">🚀 Top Project Builder Leaderboard</h1>
23+
<div className="mt-4 flex items-center justify-center gap-2">
24+
<span className="text-lg font-semibold text-[#00a6fb]">Live Leaderboard (Global)</span>
25+
<img
26+
src="https://d8it4huxumps7.cloudfront.net/uploads/images/66ebce3b69885_leaderboard.svg"
27+
alt="Leaderboard Icon"
28+
className="h-6 w-6"
29+
/>
30+
</div>
3831
</div>
39-
{/* Top 3 */}
40-
<div className="mb-10 flex flex-wrap justify-center gap-6">
32+
33+
{/* Top 3 Leaderboard Cards */}
34+
<div className="mb-12 grid grid-cols-1 justify-items-center gap-6 sm:grid-cols-2 md:grid-cols-3">
4135
{leaderboard.slice(0, 3).map((user, idx) => (
4236
<div
4337
key={user.username}
44-
className="flex w-64 flex-col items-center rounded-xl border-2 border-[#00a6fb] bg-gray-800 p-6 shadow-lg"
38+
className="relative w-full max-w-xs transform rounded-2xl bg-[#00a6fb] p-6 text-center text-white shadow-lg transition duration-300 hover:scale-105"
4539
>
46-
<img
47-
src={user.avatar}
48-
alt={user.username}
49-
className="mb-2 h-20 w-20 rounded-full border-4 border-[#00a6fb]"
50-
/>
51-
<div className="mb-1 text-xl font-bold">{user.username}</div>
52-
<div className="mt-2 rounded-lg border border-gray-600 px-4 py-2 font-semibold text-[#00a6fb]">
53-
{user.projectCount} projects
40+
<div className="absolute -top-6 left-1/2 -translate-x-1/2 transform">
41+
<div className="relative h-20 w-20">
42+
<img
43+
src={user.avatar}
44+
alt={user.username}
45+
className="h-full w-full rounded-full border-4 border-white object-cover"
46+
/>
47+
<div className="absolute -bottom-2 -right-2 h-8 w-8 rounded-full bg-white p-1 text-xl">🏆</div>
48+
</div>
5449
</div>
50+
<div className="mt-12 text-xl font-bold">{user.username}</div>
51+
<div className="mt-2 text-sm font-medium">{user.projectCount} projects</div>
5552
</div>
5653
))}
5754
</div>
58-
{/* Table for rest */}
59-
<div className="overflow-x-auto">
60-
<table className="min-w-full rounded-lg border border-gray-700 bg-gray-800">
61-
<thead>
55+
56+
{/* Other Leaderboard Table */}
57+
<div className="overflow-x-auto rounded-xl bg-gray-900 p-4 shadow-md">
58+
<table className="min-w-full divide-y divide-gray-700 text-sm">
59+
<thead className="text-left text-gray-300">
6260
<tr>
63-
<th className="border-b border-gray-700 px-4 py-2">Rank</th>
64-
<th className="border-b border-gray-700 px-4 py-2">Builder Name</th>
65-
<th className="border-b border-gray-700 px-4 py-2">Project Built</th>
61+
<th className="px-4 py-2">Rank</th>
62+
<th className="px-4 py-2">Builder</th>
63+
<th className="px-4 py-2">Projects</th>
6664
</tr>
6765
</thead>
68-
<tbody>
66+
<tbody className="divide-y divide-gray-800">
6967
{leaderboard.slice(3).map((user, idx) => (
70-
<tr key={user.username} className="text-center">
71-
<td className="border-b border-gray-700 px-4 py-2 font-bold">#{idx + 4}</td>
72-
<td className="flex items-center justify-center gap-2 border-b border-gray-700 px-4 py-2">
73-
<img src={user.avatar} alt={user.username} className="h-8 w-8 rounded-full" />
74-
{user.username}
68+
<tr key={user.username} className="hover:bg-gray-800">
69+
<td className="px-4 py-3 font-bold text-[#00a6fb]">#{idx + 4}</td>
70+
<td className="flex items-center gap-3 px-4 py-3">
71+
<img src={user.avatar} alt={user.username} className="h-8 w-8 rounded-full border" />
72+
<span>{user.username}</span>
7573
</td>
76-
<td className="border-b border-gray-700 px-4 py-2">{user.projectCount} projects</td>
74+
<td className="px-4 py-3">{user.projectCount} projects</td>
7775
</tr>
7876
))}
7977
</tbody>

0 commit comments

Comments
 (0)