Skip to content

Commit

Permalink
feat(sponsor): only show logo on homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
jsun969 committed Jan 26, 2024
1 parent 4ac4a2f commit 12886ed
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 137 deletions.
37 changes: 28 additions & 9 deletions src/app/(home)/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import FancyRectangle from '@/components/FancyRectangle';
import Sponsors from '@/components/Sponsors';
import Title from '@/components/Title';
import { SPONSOR_TYPES, getSponsors } from '@/data/sponsors';
import Image from 'next/image';
import { Fragment } from 'react';
import ImageCarousel from './ImageCarousel';

export default function HomePage() {
Expand Down Expand Up @@ -184,14 +185,32 @@ export default function HomePage() {
</div>
</div>
</div>
<Sponsors
className="relative z-10 mt-16"
typeTitle={(type) => (
<h3 className="text-2xl font-black capitalize lg:text-3xl">
{type} Sponsors
</h3>
)}
/>
<div className="relative z-10 mt-16 space-y-4">
{SPONSOR_TYPES.map((type) => {
const sponsors = getSponsors(type);
if (sponsors.length === 0) return;
return (
<Fragment key={type}>
<h3 className="text-2xl font-black capitalize lg:text-3xl">
{type} Sponsors
</h3>
<div className="flex flex-wrap gap-2">
{sponsors.map(({ image, website, name }, i) => (
<a href={website} key={i} className="block">
<Image
src={`/images/sponsors/${image}`}
alt={`${name} Logo`}
width={250}
height={250}
className="h-[150px] w-[150px] bg-white object-contain p-2 md:h-[250px] md:w-[250px]"
/>
</a>
))}
</div>
</Fragment>
);
})}
</div>
</section>

{/* CTA part 2 */}
Expand Down
97 changes: 97 additions & 0 deletions src/app/sponsors/Sponsors.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import { SPONSOR_TYPES, getSponsors, type Sponsor, type SponsorType } from '@/data/sponsors';
import Image from 'next/image';
import { Fragment } from 'react';
import FancyRectangle from '../../components/FancyRectangle';

const SPONSOR_TYPE_COLORS = {
gold: '#FCC018',
silver: '#C3C3C3',
bronze: '#E8903F',
} as const satisfies Record<SponsorType, string>;
function SponsorTypeTitle({ type }: { type: SponsorType }) {
const color = SPONSOR_TYPE_COLORS[type];
return (
<div className="flex items-center gap-5">
<div className="text-3xl font-bold md:text-4xl">
Our{' '}
<span className="capitalize" style={{ color }}>
{type}
</span>{' '}
Sponsors
</div>
<div
className="relative hidden h-[3px] grow md:block"
style={{ backgroundColor: color }}
>
<div
className="absolute -top-[4.5px] h-[12px] w-[12px] rotate-45"
style={{ backgroundColor: color }}
/>
<div
className="absolute -top-[4.5px] right-0 h-[12px] w-[12px] rotate-45"
style={{ backgroundColor: color }}
/>
</div>
</div>
);
}

type SponsorCardProps = Sponsor & { reverse?: boolean };
function SponsorCard({ image, name, description, website, type, reverse }: SponsorCardProps) {
return (
<div
className={`flex flex-col items-stretch gap-5 ${reverse ? 'md:flex-row-reverse' : 'md:flex-row'}`}
>
<Image
src={`/images/sponsors/${image}`}
alt={`${name} Logo`}
width={250}
height={250}
className="w-full shrink-0 bg-white object-contain p-4 md:w-[250px]"
/>
<FancyRectangle colour="white" offset="8" rounded>
<div className="space-y-2 rounded-xl bg-white p-4 text-black md:p-6">
<div className="flex items-center gap-4">
<a
className="grow rounded-lg border-[3px] border-black p-2 text-xl hover:underline md:text-2xl"
href={website}
>
{name}
</a>
<Image
src={`/images/sponsors/level-star/${type}.svg`}
alt="Level Star"
width={53}
height={53}
className="h-12 w-12 md:h-14 md:w-14"
/>
</div>
<div className="text-lg md:text-xl">{description}</div>
</div>
</FancyRectangle>
</div>
);
}

export default function Sponsors() {
let count = 0;
return (
<div className="space-y-9">
{SPONSOR_TYPES.map((type) => {
const sponsors = getSponsors(type);
if (sponsors.length === 0) return;
return (
<Fragment key={type}>
<SponsorTypeTitle type={type} />
{sponsors.map((sponsor, i) => {
count++;
return (
<SponsorCard {...sponsor} key={i} reverse={Boolean(count % 2)} />
);
})}
</Fragment>
);
})}
</div>
);
}
40 changes: 3 additions & 37 deletions src/app/sponsors/page.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import Sponsors from '@/app/sponsors/Sponsors';
import Paragraph from '@/components/Paragraph';
import Sponsors from '@/components/Sponsors';
import Title from '@/components/Title';
import { YEAR, type SponsorType } from '@/data/sponsors';
import { YEAR } from '@/data/sponsors';
import Image from 'next/image';

const SPONSOR_TYPE_COLORS = {
gold: '#FCC018',
silver: '#C3C3C3',
bronze: '#E8903F',
} as const satisfies Record<SponsorType, string>;

export default function SponsorsPage() {
return (
<main className="flex flex-col items-center gap-10">
Expand All @@ -36,35 +30,7 @@ export default function SponsorsPage() {
possible, fostering an environment for aspiring tech enthusiastic to excel within
our community.
</div>
<Sponsors
typeTitle={(type) => {
const color = SPONSOR_TYPE_COLORS[type];
return (
<div className="flex items-center gap-5">
<div className="text-3xl font-bold md:text-4xl">
Our{' '}
<span className="capitalize" style={{ color }}>
{type}
</span>{' '}
Sponsors
</div>
<div
className="relative hidden h-[3px] grow md:block"
style={{ backgroundColor: color }}
>
<div
className="absolute -top-[4.5px] h-[12px] w-[12px] rotate-45"
style={{ backgroundColor: color }}
/>
<div
className="absolute -top-[4.5px] right-0 h-[12px] w-[12px] rotate-45"
style={{ backgroundColor: color }}
/>
</div>
</div>
);
}}
/>
<Sponsors />
<Paragraph>
If you&apos;d like to partner with us, please enquire at:{' '}
<a href="mailto:[email protected]" className="underline">
Expand Down
89 changes: 0 additions & 89 deletions src/components/Sponsors.tsx

This file was deleted.

9 changes: 7 additions & 2 deletions src/data/sponsors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export type SponsorType = 'gold' | 'silver' | 'bronze';
export const SPONSOR_TYPES = ['gold', 'silver', 'bronze'] as const;

export type SponsorType = (typeof SPONSOR_TYPES)[number];
export type Sponsor = {
name: string;
description: string;
Expand All @@ -10,7 +12,7 @@ export type Sponsor = {
export const YEAR = 2023;

// Image file should be in `/public/images/sponsors`
export const SPONSORS: Sponsor[] = [
const SPONSORS: Sponsor[] = [
{
name: 'Macquarie',
image: 'macquarie-group.svg',
Expand All @@ -37,3 +39,6 @@ export const SPONSORS: Sponsor[] = [
'Here at Atlassian we believe that behind every great human achievement, there is a team. From medicine and space travel, to disaster response and pizza deliveries, our products help teams all over the planet advance humanity through the power of software. Our mission is to help unleash the potential of every team.',
},
];

export const getSponsors = (type: SponsorType) =>
SPONSORS.filter((sponsor) => sponsor.type === type);

0 comments on commit 12886ed

Please sign in to comment.