Skip to content

Commit 91c1deb

Browse files
committed
added url in orginfo
1 parent 8ed381d commit 91c1deb

2 files changed

Lines changed: 40 additions & 44 deletions

File tree

src/components/SupportUsButton.tsx

Lines changed: 37 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ function getButtonClasses(buttonVariant: ButtonVariant): string {
4949
}
5050

5151
// Main component function that renders the support us button, taking in various props for customization and rendering different sections such as hero, organization information, sponsors, and call-to-action based on the provided data and selected theme and button variant
52-
function SupportUsButton(
53-
54-
{
52+
function SupportUsButton({
5553
Theme = "AOSSIE",
5654
pattern = "AOSSIE",
5755
hero = {
@@ -72,29 +70,11 @@ function SupportUsButton(
7270
},
7371
buttonVariant = "AOSSIE",
7472
}: supportUsButtonProps): React.JSX.Element {
75-
// Ensure required props are provided to prevent runtime crashes
76-
77-
if (!organizationInformation) {
78-
console.warn(
79-
"SupportUsButton: 'organizationInformation' is required."
80-
);
81-
}
82-
83-
if (!ctaSection) {
84-
console.warn(
85-
"SupportUsButton: 'ctaSection' is required."
86-
);
87-
}
88-
89-
// Defensive fallback to handle unexpected missing props at runtime
90-
const org = organizationInformation ?? null;
91-
const cta = ctaSection ?? null;
9273
return (
9374
// Container for the support us button, with dynamic classes based on the selected theme and custom class names
9475
<div
9576
className={`w-full font-sans justify-center items-center text-center ${Theme == "light" || Theme == "dark" ? classAccordingToTheme(Theme) : "bg-black text-white"} ${classNames.container}`}
9677
>
97-
9878
{/* Hero section with optional background image*/}
9979
<div className="relative w-full h-[50vh] flex justify-center">
10080
{hero.Image && (
@@ -148,9 +128,7 @@ function SupportUsButton(
148128
</div>
149129

150130
{/* Organization information section */}
151-
{/* Avoid rendering empty organization section when data is not provided */}
152-
{org && (
153-
<div className="w-full flex justify-center p-10 mb-50">
131+
<div className="w-full flex justify-center p-10 mb-50">
154132
<div
155133
className={`${classNames.organizationInformation}
156134
relative w-[90%] p-15 rounded-2xl overflow-visible
@@ -184,21 +162,21 @@ function SupportUsButton(
184162

185163
{/* Organization logo */}
186164
<div>
187-
{typeof org.logo === "string" ? (
165+
{typeof organizationInformation.logo === "string" ? (
188166
<span
189167
className="block h-fit w-fit p-4 bg-black text-white rounded-2xl"
190-
title={org.logo}
168+
title={organizationInformation.logo}
191169
>
192170
<b className="text-2xl italic">
193-
{org.logo}
171+
{organizationInformation.logo}
194172
</b>
195173
</span>
196174
) : (
197175
<img
198176
className="w-24 h-24 bg-white/80 pointer-none:cursor-none select-none rounded-2xl object-cover object-center"
199-
src={org.logo?.src}
200-
alt={org.logo?.alt}
201-
title={org.logo?.alt}
177+
src={organizationInformation.logo?.src}
178+
alt={organizationInformation.logo?.alt}
179+
title={organizationInformation.logo?.alt}
202180
draggable={false}
203181
/>
204182
)}
@@ -207,15 +185,34 @@ function SupportUsButton(
207185
{/* Organization name and description */}
208186
<div className="flex flex-col gap-4">
209187
<h2 className={`font-extrabold text-4xl md:text-5xl lg:text-6xl`}>
210-
{org.name}
188+
{organizationInformation.name}
211189
</h2>
212190
<p className="font-[650] text-lg">
213-
{org.description}
191+
{organizationInformation.description}
214192
</p>
215193
</div>
216194

195+
{/* Visit Organization Button */}
196+
{organizationInformation.url && (
197+
<a
198+
href={organizationInformation.url}
199+
target="_blank"
200+
rel="noopener noreferrer"
201+
title={`Visit ${organizationInformation.name}'s website`}
202+
className={`w-fit px-6 py-2 rounded-lg font-bold transition-all active:scale-[0.98] shadow-md
203+
${Theme === "AOSSIE" && "bg-black text-white hover:bg-gray-800"}
204+
${Theme === "light" && "bg-gray-800 text-white hover:bg-black"}
205+
${Theme === "dark" && "bg-white text-black hover:bg-gray-200"}
206+
${Theme === "minimal" && "bg-gray-800 text-white hover:bg-black"}
207+
${Theme === "corporate" && "bg-blue-800 text-white hover:bg-blue-900"}
208+
`}
209+
>
210+
Visit Organisation
211+
</a>
212+
)}
213+
217214
{/* Line */}
218-
{org.projectInformation && (
215+
{organizationInformation.projectInformation && (
219216
<div
220217
className={`
221218
border
@@ -228,7 +225,7 @@ function SupportUsButton(
228225
)}
229226

230227
{/* Project information */}
231-
{org.projectInformation && (
228+
{organizationInformation.projectInformation && (
232229
<div className="flex flex-col gap-2">
233230
<h3
234231
className={`font-bold w-fit uppercase text-sm p-2 rounded-lg
@@ -239,7 +236,7 @@ function SupportUsButton(
239236
${Theme === "corporate" && "bg-blue-600/50"}`}
240237
>
241238
ABOUT PROJECT:{" "}
242-
{org.projectInformation.name}
239+
{organizationInformation.projectInformation.name}
243240
</h3>
244241
<p
245242
className={`italic font-semibold
@@ -250,16 +247,14 @@ function SupportUsButton(
250247
${Theme === "corporate" && "text-blue-600/80"}
251248
`}
252249
>
253-
"{org.projectInformation.description}"
250+
"{organizationInformation.projectInformation.description}"
254251
</p>
255252
</div>
256253
)}
257254
</div>
258255
</div>
259256
</div>
260257

261-
)}
262-
263258
{/* Sponsors section */}
264259
<div
265260
className={`w-full flex justify-center mt-10 p-10
@@ -441,23 +436,21 @@ function SupportUsButton(
441436
</div>
442437

443438
{/* Call-to-action section with title, description, and sponsor links */}
444-
{cta && (
445-
446439
<div
447440
className={`w-full flex justify-center p-10 ${(Theme === "light" || Theme === "dark") && classAccordingToTheme(Theme)} ${classNames.ctaSection}`}
448441
>
449442
<div className="w-4/5 flex flex-col items-center gap-5 py-20 border border-primary rounded-sm mt-20 mb-20">
450443
<h2 className={`font-extrabold text-4xl md:text-5xl lg:text-6xl`}>
451-
{cta.title}
444+
{ctaSection.title}
452445
</h2>
453446
<p
454447
className={`font-semibold
455448
${Theme === "light" ? "text-gray-600" : "text-gray-400"}`}
456449
>
457-
{cta.description}
450+
{ctaSection.description}
458451
</p>
459452
<div className="flex flex-wrap justify-center items-center gap-5 mt-8">
460-
{cta.sponsorLink.map((link, index) => (
453+
{ctaSection.sponsorLink.map((link, index) => (
461454
<a
462455
href={link.url}
463456
key={index}
@@ -475,7 +468,7 @@ function SupportUsButton(
475468
))}
476469
</div>
477470
</div>
478-
</div>)}
471+
</div>
479472
</div>
480473
);
481474
}

src/types/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ export type organizationInformation = {
5656
/** Organization logo */
5757
logo?: Image | string;
5858

59+
/** Organization website or GitHub URL */
60+
url?: string;
61+
5962
projectInformation?: projectInformation;
6063
};
6164

0 commit comments

Comments
 (0)