Skip to content

Commit f965532

Browse files
committed
feat: make FeaturedProgram component configurable with props
1 parent c02ab0f commit f965532

File tree

2 files changed

+53
-12
lines changed

2 files changed

+53
-12
lines changed

src/app/page.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,15 @@ export default function Home() {
2424
]}
2525
heightClassName="h-[30rem]"
2626
/>
27-
<FeaturedProgram />
27+
<FeaturedProgram
28+
heading="Featured Program"
29+
description="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
30+
mediaSrc="/favicon/android-chrome-512x512.png"
31+
mediaAlt="ALPHA HKU Icon"
32+
isVideo={false}
33+
ctaHref="/upcoming-event"
34+
ctaLabel="Learn More"
35+
/>
2836
<WhoWeAre />
2937
<WhatsHappening />
3038
</>

src/components/sections/featured-program.tsx

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,59 @@
11
import { Button } from "@/components/ui/button";
22
import { Card } from "@/components/ui/card";
3+
import Image from "next/image";
34
import Link from "next/link";
45

5-
export function FeaturedProgram() {
6+
type FeaturedProgramProps = {
7+
heading: string;
8+
description: string;
9+
mediaSrc: string;
10+
mediaAlt?: string;
11+
isVideo?: boolean;
12+
ctaHref: string;
13+
ctaLabel?: string;
14+
};
15+
16+
export function FeaturedProgram({
17+
heading,
18+
description,
19+
mediaSrc,
20+
mediaAlt,
21+
isVideo = false,
22+
ctaHref,
23+
ctaLabel = "Learn More",
24+
}: FeaturedProgramProps) {
625
return (
726
<section>
827
<div className="container mx-auto px-4">
928
<Card className="p-8 border-primary/35 hover:border-primary transition-all">
1029
<div className="grid md:grid-cols-2 gap-8 items-center">
1130
<div className="space-y-4">
12-
<h2 className="text-3xl font-bold">Featured Program</h2>
13-
<p className="text-muted-foreground">
14-
This is a description of the featured program. It highlights a key initiative and invites
15-
users to learn more.
16-
</p>
17-
<Button asChild>
18-
<Link href="#placeholder">Learn More</Link>
19-
</Button>
31+
<h2 className="text-3xl font-bold">{heading}</h2>
32+
<p className="text-muted-foreground">{description}</p>
33+
{ctaHref && ctaLabel ? (
34+
<Button asChild>
35+
<Link href={ctaHref}>{ctaLabel}</Link>
36+
</Button>
37+
) : null}
2038
</div>
2139
<div>
22-
<div className="aspect-video bg-muted rounded-lg flex items-center justify-center">
23-
<p className="text-muted-foreground">Embedded Video</p>
40+
<div className="relative aspect-video bg-muted rounded-lg overflow-hidden">
41+
{isVideo ? (
42+
<video
43+
src={mediaSrc}
44+
controls
45+
className="h-full w-full object-contain"
46+
/>
47+
) : (
48+
<Image
49+
src={mediaSrc}
50+
alt={mediaAlt ?? heading}
51+
fill
52+
className="object-contain"
53+
sizes="(min-width: 768px) 50vw, 100vw"
54+
unoptimized
55+
/>
56+
)}
2457
</div>
2558
</div>
2659
</div>

0 commit comments

Comments
 (0)