From 4eb1ddaddb13227f83dd1bace00c455429676b66 Mon Sep 17 00:00:00 2001 From: eshanized Date: Mon, 23 Dec 2024 10:11:28 +0530 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20style(change):=20content?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.tsx | 2 +- src/pages/Donors.tsx | 188 +++++++++++++++-------------- src/pages/Download.tsx | 114 ++++++------------ src/pages/Home.tsx | 260 ++++++++++++++++++++++++----------------- 4 files changed, 283 insertions(+), 281 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 3dbd5ab3..e93760cc 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,4 +1,4 @@ -import React from 'react'; + import { HashRouter as Router, Routes, Route } from 'react-router-dom'; import { Layout } from './components/layout/Layout'; import { Home } from './pages/Home'; diff --git a/src/pages/Donors.tsx b/src/pages/Donors.tsx index ceb26011..4764c778 100644 --- a/src/pages/Donors.tsx +++ b/src/pages/Donors.tsx @@ -1,89 +1,116 @@ -import { Heart, Trophy, PieChart } from 'lucide-react'; +import { useEffect, useState } from 'react'; +import { Heart, PieChart } from 'lucide-react'; import { FaRupeeSign } from 'react-icons/fa'; +async function getGitHubUserData(username: string): Promise<{ name: string; avatar_url: string }> { + try { + const response = await fetch(`https://api.github.com/users/${username}`); + if (!response.ok) { + throw new Error(`User not found: ${username}`); + } + const data = await response.json(); + return { + name: data.name || username, // Use GitHub name or fallback to username + avatar_url: data.avatar_url || '', + }; + } catch (error) { + console.error(error); + return { name: username, avatar_url: '' }; // Return username if there is an error + } +} + +function useGitHubDonors(usernames: string[]): { [key: string]: { name: string; avatar_url: string } } { + const [donors, setDonors] = useState<{ [key: string]: { name: string; avatar_url: string } }>({}); + + useEffect(() => { + const fetchDonors = async () => { + const donorData: { [key: string]: { name: string; avatar_url: string } } = {}; + for (let username of usernames) { + const data = await getGitHubUserData(username); + donorData[username] = data; + } + setDonors(donorData); + }; + + fetchDonors(); + }, [usernames]); + + return donors; +} + export function Donors() { + const donorUsernames = [ + "eshanized", "GlobalSystemsLtd", "FutureComputingInc", "SarahJohnson", "MichaelChang", + "DataFlowSolutions", "RobertWilson", "EmmaThompson", "RajeshKumar", "PriyaSharma", + "AryanPatel", "MeenaIyer", "VikramSingh" + ]; + + const donorData = useGitHubDonors(donorUsernames); + return (
{/* Hero Section */}
- -

Our Amazing Donors

+ +

Our Amazing Donors

- Snigdha OS is made possible thanks to the generous support of our - donors. We are grateful for their contributions to keep our project - running. + Snigdha OS is made possible thanks to the generous support of our donors. We are grateful for their contributions to keep our project running.

- {/* Donation Tiers */} + {/* Donor List */}
-

- - Donation Tiers -

+

Donors List

- } - color="bg-gradient-to-r from-gray-200 to-gray-100" - donors={[ - "TechCorp International", - "Global Systems Ltd", - "Future Computing Inc", - ]} - /> - } - color="bg-gradient-to-r from-yellow-100 to-yellow-50" - donors={[ - "Sarah Johnson", - "Michael Chang", - "DataFlow Solutions", - "Robert Wilson", - "Emma Thompson", - ]} - /> - } - color="bg-gradient-to-r from-gray-100 to-white" - donors={[ - "Rajesh Kumar", -"Priya Sharma", -"Aryan Patel", -"Meena Iyer", -"Vikram Singh", - // "And many more...", - ]} - /> + {donorUsernames.map((donor) => ( +
+ {donorData[donor]?.avatar_url ? ( + {donorData[donor].name} + ) : ( +
// Placeholder if no avatar + )} +
+ {donorData[donor]?.name || donor} +
+ + + @{donor} + + +
+
+ ))}
{/* Become a Donor */} -
-

+
+

Become a Donor

-

- Your support helps us maintain and improve Snigdha OS. Every donation, - big or small, makes a difference in keeping our project independent and - sustainable. +

+ Your support helps us maintain and improve Snigdha OS. Every donation, big or small, makes a difference in keeping our project independent and sustainable.

-
{/* Yearly Report */}
-

- +

+ Yearly Donation Report

@@ -95,25 +122,25 @@ export function Donors() { averageDonation={1125} />
-

How Donations Are Used

+

How Donations Are Used

} + icon={} /> } + icon={} /> } + icon={} />
@@ -125,37 +152,6 @@ export function Donors() { ); } -type DonationTierProps = { - title: string; - amount: string; - color: string; - icon: React.ReactNode; - donors: string[]; -}; - -function DonationTier({ - title, - amount, - color, - icon, - donors, -}: DonationTierProps) { - return ( -
-

- {icon} - {title} -

-

{amount}

-
    - {donors.map((donor, index) => ( -
  • {donor}
  • - ))} -
-
- ); -} - type YearlyStatsProps = { month: string; amount: number; @@ -171,7 +167,7 @@ function YearlyStats({ }: YearlyStatsProps) { return (
-

{month}

+

{month}

Total Donations

@@ -207,11 +203,11 @@ function UsageCard({
{icon} - + {percentage}%
-

{category}

+

{category}

{description}

); diff --git a/src/pages/Download.tsx b/src/pages/Download.tsx index 6d256447..4060e140 100644 --- a/src/pages/Download.tsx +++ b/src/pages/Download.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useState } from 'react'; -import { Download as DownloadIcon, Monitor, Server, HardDrive, Smartphone, Code } from 'lucide-react'; +import { Download as DownloadIcon, Monitor, Server, HardDrive, Smartphone } from 'lucide-react'; export function DownloadPage() { const [userLocation, setUserLocation] = useState(null); @@ -56,7 +56,7 @@ export function DownloadPage() {
{/* Hero Section */}
-

+

Download Snigdha OS

@@ -66,9 +66,9 @@ export function DownloadPage() {

- - - + + +

Snigdha OS is designed to provide an unparalleled experience, @@ -89,7 +89,7 @@ export function DownloadPage() { {/* System Requirements */}

-

+

System Requirements

@@ -139,7 +139,7 @@ export function DownloadPage() {
{suggestedMirror && (
-

+

Suggested Mirror for You

@@ -161,7 +161,7 @@ function FeatureBadge({ }) { return ( {text} @@ -186,11 +186,11 @@ function EditionCard({ return (
{recommended && ( -
+
Recommended
)} @@ -198,7 +198,7 @@ function EditionCard({

{title}

{description}

-

Key Features:

+

Key Features:

    {keyFeatures.map((feature, index) => (
  • {feature}
  • @@ -206,11 +206,11 @@ function EditionCard({
-

Ideal For:

+

Ideal For:

{idealFor}

- @@ -230,7 +230,7 @@ function SystemRequirements({ }) { return (
-

{title}

+

{title}

{/* Features Section */}