diff --git a/src/components/SupportUsButton.tsx b/src/components/SupportUsButton.tsx index 2baa3c2..50a5c06 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 { @@ -69,11 +70,38 @@ function SupportUsButton({ ctaSection: "", }, buttonVariant = "AOSSIE", + showCopyLinkButton = false, }: supportUsButtonProps): React.JSX.Element { + const [copiedLink, setCopiedLink] = React.useState(null); + + const handleCopyLink = (e: React.MouseEvent, link: string) => { + e.preventDefault(); + e.stopPropagation(); + navigator.clipboard.writeText(link); + setCopiedLink(link); + setTimeout(() => { + setCopiedLink(null); + }, 2000); + }; + + 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 +147,7 @@ function SupportUsButton({ {hero.title}

{hero.description}

@@ -134,21 +162,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 +224,32 @@ function SupportUsButton({
{/* Project information */}

ABOUT PROJECT: {organizationInformation.projectInformation.name}

"{organizationInformation.projectInformation.description}" @@ -234,16 +262,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 +303,7 @@ function SupportUsButton({ {/* Sponsor logos */}
- {sponsors.map((sponsor, index) => ( + {sortedSponsors.map((sponsor, index) => (
-

{sponsor.name}

+
+

{sponsor.name}

+ {showCopyLinkButton && sponsor.link && ( + + )} +
{sponsor.sponsorshipTier && ( {sponsor.sponsorshipTier} @@ -405,7 +449,7 @@ function SupportUsButton({ {/* Call-to-action section with title, description, and sponsor links */}

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

{ctaSection.description}

diff --git a/src/types/index.ts b/src/types/index.ts index a715ef7..1672a5f 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" @@ -152,4 +152,7 @@ export interface supportUsButtonProps { // Optional button variant for styling the call-to-action buttons buttonVariant?: ButtonVariant; + + // Optional flag to show a copy link button on sponsor cards + showCopyLinkButton?: boolean; }