diff --git a/src/Pages/Contributors.jsx b/src/Pages/Contributors.jsx index 41dd981..3ad6345 100644 --- a/src/Pages/Contributors.jsx +++ b/src/Pages/Contributors.jsx @@ -37,9 +37,7 @@ const ContributorsPage = () => { const response = await fetch( "https://api.github.com/repos/HarshS16/Civix/contributors?per_page=200" ); - if (!response.ok) { - throw new Error("Failed to fetch contributors"); - } + if (!response.ok) throw new Error("Failed to fetch contributors"); const data = await response.json(); const sortedData = (data || []).sort( (a, b) => b.contributions - a.contributions @@ -48,17 +46,12 @@ const ContributorsPage = () => { setFilteredContributors(sortedData); setDisplayedContributors(sortedData.slice(0, CONTRIBUTORS_PER_PAGE)); setHasMore(sortedData.length > CONTRIBUTORS_PER_PAGE); - const totalContributions = sortedData.reduce( - (sum, c) => sum + c.contributions, - 0 - ); setStats({ totalContributors: sortedData.length, - totalContributions, + totalContributions: sortedData.reduce((sum, c) => sum + c.contributions, 0), topContributor: sortedData[0], }); } catch (err) { - console.error(err); setIsError(true); } finally { setIsLoading(false); @@ -73,8 +66,7 @@ const ContributorsPage = () => { ); filtered.sort((a, b) => { if (sortBy === "contributions") return b.contributions - a.contributions; - if (sortBy === "alphabetical") - return a.login.localeCompare(b.login); + if (sortBy === "alphabetical") return a.login.localeCompare(b.login); return 0; }); setFilteredContributors(filtered); @@ -88,15 +80,9 @@ const ContributorsPage = () => { const nextPage = page + 1; const startIndex = page * CONTRIBUTORS_PER_PAGE; const endIndex = startIndex + CONTRIBUTORS_PER_PAGE; - const newContributors = filteredContributors.slice( - startIndex, - endIndex - ); + const newContributors = filteredContributors.slice(startIndex, endIndex); setTimeout(() => { - setDisplayedContributors((prev) => [ - ...prev, - ...newContributors, - ]); + setDisplayedContributors((prev) => [...prev, ...newContributors]); setPage(nextPage); setHasMore(endIndex < filteredContributors.length); setIsLoadingMore(false); @@ -105,128 +91,115 @@ const ContributorsPage = () => { const getRankIcon = (index) => { if (index === 0) - return ; + return ; if (index === 1) - return ; + return ; if (index === 2) - return ; + return ; return null; }; - + // Modern chip colors but subtle greenish background const getContributionLevel = (contributions) => { if (contributions >= 100) return { level: "Legend", - color: "bg-purple-500", - textColor: "text-purple-100", + color: "bg-gradient-to-r from-purple-400 to-purple-600", + textColor: "text-white", }; if (contributions >= 50) return { level: "Expert", - color: "bg-blue-500", - textColor: "text-blue-100", + color: "bg-gradient-to-r from-sky-400 to-blue-500", + textColor: "text-white", }; if (contributions >= 20) return { level: "Advanced", - color: "bg-green-500", - textColor: "text-green-100", + color: "bg-gradient-to-r from-emerald-400 to-emerald-600", + textColor: "text-white", }; if (contributions >= 10) return { level: "Intermediate", - color: "bg-yellow-500", - textColor: "text-yellow-900", + color: "bg-gradient-to-r from-lime-200 to-emerald-300", + textColor: "text-green-900", }; return { level: "Beginner", - color: "bg-gray-500", - textColor: "text-gray-100", + color: "bg-gray-100 dark:bg-gray-800", + textColor: "text-gray-700 dark:text-gray-200", }; }; return ( -
-
-
-
+
+ {/* HERO + Stats */} +
+
+
-

- Our Amazing - - Contributors - +

+ Our Amazing Contributors

-

- Meet the talented developers making Civix better every day +

+ Meet the talented developers making Civix better every day.

-
-
+
+
-
- {stats.totalContributors} -
-
- Contributors -
+
{stats.totalContributors}
+
Contributors
-
+
- -
-
- {stats.totalContributions} -
-
- Total Contributions +
+
{stats.totalContributions}
+
Total Contributions
-
+
- -
-
- {stats.topContributor?.contributions || 0} -
-
- Top Contributions +
+
{stats.topContributor?.contributions || 0}
+
Top Contributions
-
+
-
-
+ {/* Filters */} +
+
- + setSearchTerm(e.target.value)} - className="w-full pl-12 pr-4 py-3 border-none rounded-xl focus:ring-2 focus:ring-emerald-400 focus:outline-none bg-emerald-100/50 dark:bg-gray-700 dark:text-white shadow-inner transition outline-none" + className="w-full pl-12 pr-3 py-3 border-none rounded-xl focus:ring-2 focus:ring-emerald-400 focus:outline-none bg-emerald-100/50 dark:bg-gray-800 dark:text-white shadow-inner" />
-
+
+ {/* Contributor Cards */} {isLoading ? (
{ {Array.from({ length: 8 }).map((_, index) => (
-
+
-
-
+
+
@@ -290,25 +264,21 @@ const ContributorsPage = () => { }`} > {displayedContributors.map((user, index) => { - const contributionLevel = getContributionLevel( - user.contributions - ); + const contributionLevel = getContributionLevel(user.contributions); const rank = contributors.findIndex( (c) => c.login === user.login ); return (
{rank < 3 && ( -
- {getRankIcon(rank)} -
+
{getRankIcon(rank)}
)} {rank === 0 && (
@@ -320,18 +290,12 @@ const ContributorsPage = () => { : "text-center" }`} > -
+
{user.login} { }`} /> {rank < 3 && ( -
- +
+ #{rank + 1}
)}
-
-

+
+

@{user.login}

-
- - {contributionLevel.level} - - +
+ {contributionLevel.level} + {user.contributions} contributions
@@ -436,13 +388,13 @@ const ContributorsPage = () => { {Array.from({ length: 4 }).map((_, index) => (
-
+
-
-
+
+
@@ -463,6 +415,14 @@ const ContributorsPage = () => { )}
+
); };