diff --git a/src/components/SupportUsButton.tsx b/src/components/SupportUsButton.tsx index 2baa3c2..c89fd97 100644 --- a/src/components/SupportUsButton.tsx +++ b/src/components/SupportUsButton.tsx @@ -2,6 +2,7 @@ import React from "react"; import type { supportUsButtonProps } from "../types/index"; import type { Theme } from "../types/index"; import type { ButtonVariant } from "../types/index"; +import type { Tier } from "../types/index"; // Function to get the appropriate classes based on the selected theme, used for styling different sections of the component according to the chosen theme function classAccordingToTheme(Theme: Theme): string { @@ -70,10 +71,24 @@ function SupportUsButton({ }, buttonVariant = "AOSSIE", }: supportUsButtonProps): React.JSX.Element { + const sortedSponsors = sponsors ? [...sponsors].sort((a, b) => { + const tierPriority: Record = { + Platinum: 1, + Gold: 2, + Silver: 3, + Bronze: 4, + }; + const aTier = a.sponsorshipTier || 'Bronze'; + const bTier = b.sponsorshipTier || 'Bronze'; + return tierPriority[aTier] - tierPriority[bTier]; + }) : []; + + const resolvedTheme = Theme === "system" ? (typeof window !== "undefined" && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light") : Theme; + return ( // Container for the support us button, with dynamic classes based on the selected theme and custom class names
{/* Hero section with optional background image*/}
@@ -119,7 +134,7 @@ function SupportUsButton({ {hero.title}

{hero.description}

@@ -134,21 +149,21 @@ function SupportUsButton({ relative w-[90%] p-15 rounded-2xl overflow-visible // Shadows for different themes - ${Theme === "AOSSIE" && "shadow-xl shadow-primary/20"} - ${Theme === "light" && "shadow-xl shadow-gray-300/30"} - ${Theme === "dark" && "shadow-xl shadow-gray-700/30"} - ${Theme === "minimal" && "shadow-xl shadow-gray-800/30"} - ${Theme === "corporate" && "shadow-xl shadow-blue-600/30"} + ${resolvedTheme === "AOSSIE" && "shadow-xl shadow-primary/20"} + ${resolvedTheme === "light" && "shadow-xl shadow-gray-300/30"} + ${resolvedTheme === "dark" && "shadow-xl shadow-gray-700/30"} + ${resolvedTheme === "minimal" && "shadow-xl shadow-gray-800/30"} + ${resolvedTheme === "corporate" && "shadow-xl shadow-blue-600/30"} // Outline for light and dark themes - ${Theme === "light" && "outline-1 outline-gray-300"} - ${Theme === "dark" && "outline-1 outline-gray-700"} - ${classAccordingToTheme(Theme)}`} + ${resolvedTheme === "light" && "outline-1 outline-gray-300"} + ${resolvedTheme === "dark" && "outline-1 outline-gray-700"} + ${classAccordingToTheme(resolvedTheme)}`} > {/* Background grid */}
{/* Content container */} @@ -196,32 +211,32 @@ function SupportUsButton({
{/* Project information */}

ABOUT PROJECT: {organizationInformation.projectInformation.name}

"{organizationInformation.projectInformation.description}" @@ -234,16 +249,16 @@ function SupportUsButton({ {/* Sponsors section */}

- {sponsors && sponsors.length > 0 && ( + {sortedSponsors && sortedSponsors.length > 0 && ( // List of sponsors with their logos and links, styled according to the selected theme and custom class names
{/* Sponsor pattern AOSSIE */} @@ -275,7 +290,7 @@ function SupportUsButton({ {/* Sponsor logos */}
- {sponsors.map((sponsor, index) => ( + {sortedSponsors.map((sponsor, index) => (

@@ -413,7 +428,7 @@ function SupportUsButton({

{ctaSection.description}

diff --git a/src/types/index.ts b/src/types/index.ts index a715ef7..3bc3bc6 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -4,7 +4,7 @@ import type { ReactNode } from "react"; Theme ========================= */ -export type Theme = "AOSSIE" | "light" | "dark" | "minimal" | "corporate"; +export type Theme = "AOSSIE" | "light" | "dark" | "minimal" | "corporate" | "system"; /* ========================================================= Button Variant @@ -123,7 +123,7 @@ export type Pattern = "AOSSIE" | "dots" | "grid" | "none"; ========================= */ export interface supportUsButtonProps { - // Theme for the button, can be one of "AOSSIE", "light", "dark", "minimal", or "corporate" + // Theme for the button, can be one of "AOSSIE", "light", "dark", "minimal", "corporate", or "system" Theme?: Theme; // Optional background pattern for the button, can be one of "dots", "grid", "stripes", or "none"