From 6870ff1e4814f0bd632a2f72522d7125ed235703 Mon Sep 17 00:00:00 2001 From: d3v1l0n Date: Mon, 23 Dec 2024 22:39:06 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20download=20mirror=20detec?= =?UTF-8?q?tion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Download.tsx | 125 +++++++++++++++++++++++++---------------- 1 file changed, 77 insertions(+), 48 deletions(-) diff --git a/src/pages/Download.tsx b/src/pages/Download.tsx index 4060e140..0ef2519d 100644 --- a/src/pages/Download.tsx +++ b/src/pages/Download.tsx @@ -1,11 +1,10 @@ import React, { useEffect, useState } from 'react'; -import { Download as DownloadIcon, Monitor, Server, HardDrive, Smartphone } from 'lucide-react'; +import { Download as DownloadIcon, Monitor, Server, HardDrive, Smartphone, Move } from 'lucide-react'; export function DownloadPage() { const [userLocation, setUserLocation] = useState(null); const [userRegion, setUserRegion] = useState(null); - // Detect user location using a public API useEffect(() => { async function fetchLocation() { try { @@ -22,11 +21,9 @@ export function DownloadPage() { fetchLocation(); }, []); - // Find the closest mirror based on the user's region const getSuggestedMirror = () => { - if (!userRegion) return null; // If region is not detected, return null - - // Normalize userRegion to handle cases like "United States" vs. "USA" + if (!userRegion) return null; + const regionMap: { [key: string]: string } = { "united states": "north america", "canada": "north america", @@ -39,27 +36,25 @@ export function DownloadPage() { "south africa": "africa", "australia": "australia", }; - - // Lowercase the userRegion for more lenient matching + const normalizedRegion = regionMap[userRegion.toLowerCase()] || userRegion.toLowerCase(); - - // Find the closest mirror based on the user's region + return mirrorData.find((mirror) => mirror.region.toLowerCase().includes(normalizedRegion) ); }; - + const suggestedMirror = getSuggestedMirror(); return ( -
+
{/* Hero Section */}
-

+

Download Snigdha OS

-

+

Choose the edition that best suits your needs. All versions are free to download and use, providing the best experience for developers, students, and professionals alike. @@ -70,7 +65,7 @@ export function DownloadPage() {

-

+

Snigdha OS is designed to provide an unparalleled experience, whether you're working on an older device or a high-end system. Built with efficiency, reliability, and beauty in mind, it’s @@ -89,10 +84,10 @@ export function DownloadPage() { {/* System Requirements */}

-

+

System Requirements

-
+
-

+

Download Mirrors

@@ -161,7 +156,7 @@ function FeatureBadge({ }) { return ( {text} @@ -185,17 +180,17 @@ function EditionCard({ }) { return (

{recommended && ( -
+
Recommended
)}
{icon}
-

{title}

+

{title}

{description}

Key Features:

@@ -210,8 +205,8 @@ function EditionCard({

{idealFor}

-
@@ -229,9 +224,9 @@ function SystemRequirements({ notes: string; }) { return ( -
-

{title}

-
    +
    +

    {title}

    +
      {specs.map((spec, index) => (
    • {spec}
    • ))} @@ -246,13 +241,15 @@ function MirrorButton({ speed, host, url, - suggested = false, // Added 'suggested' prop to highlight the suggested mirror + suggested = false, + description, }: { region: string; speed: string; host: string; url: string; - suggested?: boolean; // Optional prop to check if this is the suggested mirror + suggested?: boolean; + description: string; }) { const speedColor = { 'Very Fast': 'text-green-500', @@ -263,30 +260,31 @@ function MirrorButton({ return ( -
      -
      -

      {region}

      -

      {host}

      -
      -
      - {speed} -
      - - {suggested && ( -
      - Suggested Mirror -
      - )} +
      +

      {region}

      +

      {host}

      +
      + {speed} +
      +
      + {description} +
      + + {suggested && ( +
      + Suggested Mirror +
      + )}
      ); } -// Data +// Data for editions and mirrors const editionData = [ { title: 'Gnome Edition', @@ -317,26 +315,57 @@ const editionData = [ idealFor: 'Power users who want control and beauty in equal measure.', icon: , }, + { + title: 'i3 Window Manager Edition', + description: 'Minimal and efficient. Perfect for users who prefer keyboard-driven navigation.', + keyFeatures: ['Tiling Window Manager', 'Lightweight', 'Highly Configurable'], + idealFor: 'Users who value efficiency and are comfortable with manual configuration.', + icon: , + }, + { + title: 'Openbox Edition', + description: 'A fast and lightweight window manager with full customization.', + keyFeatures: ['Highly Customizable', 'Low Memory Usage', 'Simple Layout'], + idealFor: 'Users looking for a lightweight and minimal window manager.', + icon: , + }, ]; -// Example of mirrorData (you can add more mirrors as needed) const mirrorData = [ { region: 'North America (USA)', speed: 'Very Fast', host: 'ExampleMirrorHost.com', url: 'https://example.com/download', + description: 'Located in the United States, this mirror offers extremely fast download speeds for North American users.', }, { region: 'Europe (Germany)', speed: 'Fast', host: 'EU-Mirror.com', url: 'https://eu-mirror.com/download', + description: 'This server in Germany provides good download speeds for European users.', }, { region: 'Asia (India)', speed: 'Moderate', host: 'IN-Mirror.com', url: 'https://in-mirror.com/download', + description: 'Located in India, this mirror is suitable for users in South Asia. Speeds may vary depending on network conditions.', }, + { + region: 'South America (Brazil)', + speed: 'Fast', + host: 'BR-Mirror.com', + url: 'https://br-mirror.com/download', + description: 'This mirror in Brazil offers fast download speeds for South American users.', + }, + { + region: 'Australia', + speed: 'Very Fast', + host: 'AU-Mirror.com', + url: 'https://au-mirror.com/download', + description: 'Users in Australia can enjoy very fast download speeds from this mirror.', + }, + // Add more mirrors as needed ];