-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Homepage Partners Section (#352)
* feat: homepage partners section * fix: center partner icons vertically --------- Co-authored-by: Sam Der <[email protected]>
- Loading branch information
1 parent
38b67de
commit 6db54e9
Showing
8 changed files
with
125 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { defineType, defineField, defineArrayMember } from "sanity"; | ||
import { HeartHandshake } from "lucide-react"; | ||
|
||
export default defineType({ | ||
name: "partners", | ||
title: "Partners", | ||
icon: HeartHandshake, | ||
type: "document", | ||
fields: [ | ||
defineField({ | ||
name: "partners", | ||
title: "Partners", | ||
type: "array", | ||
of: [ | ||
defineArrayMember({ | ||
type: "object", | ||
name: "partner", | ||
fields: [ | ||
defineField({ | ||
name: "name", | ||
title: "Name", | ||
type: "string", | ||
validation: (Rule) => Rule.required(), | ||
}), | ||
defineField({ | ||
name: "url", | ||
title: "URL", | ||
type: "url", | ||
}), | ||
defineField({ | ||
name: "logo", | ||
title: "Logo", | ||
type: "image", | ||
validation: (Rule) => Rule.required(), | ||
}), | ||
], | ||
}), | ||
], | ||
}), | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
apps/site/src/app/(main)/(home)/sections/Partners/Partners.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.title { | ||
text-shadow: 0px 0px 20px rgba(255, 255, 255, 0.75); | ||
} |
45 changes: 45 additions & 0 deletions
45
apps/site/src/app/(main)/(home)/sections/Partners/Partners.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* eslint-disable @next/next/no-img-element */ | ||
import Image from "next/image"; | ||
|
||
import { getPartners } from "./getPartners"; | ||
import fishingBoat from "@/assets/images/fishing-boat.png"; | ||
|
||
import { client } from "@/lib/sanity/client"; | ||
import imageUrlBuilder from "@sanity/image-url"; | ||
|
||
import styles from "./Partners.module.scss"; | ||
|
||
const builder = imageUrlBuilder(client); | ||
|
||
export default async function Sponsors() { | ||
const partners = await getPartners(); | ||
|
||
return ( | ||
<section className="container py-24 md:my-16 relative items-center flex flex-col md:p-8 w-3/4 mx-auto text-center"> | ||
<h2 | ||
className={`${styles.title} my-12 font-display sm:text-[3rem] text-[#fffce2] text-4xl text-center`} | ||
> | ||
Partners | ||
</h2> | ||
<div className="flex flex-wrap gap-8 justify-center pb-32 items-center"> | ||
{partners.partners.map(({ _key, name, url, logo }) => ( | ||
<a | ||
key={_key} | ||
href={url} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
className="max-w-xs flex-grow" | ||
> | ||
{/* eslint-disable-next-line @next/next/no-img-element*/} | ||
<img | ||
src={builder.image(logo).format("webp").url()} | ||
alt={name + " logo"} | ||
className={"max-w-full max-h-full m-auto my-2"} | ||
/> | ||
</a> | ||
))} | ||
</div> | ||
<Image src={fishingBoat} alt="boat" width="400" height="400" /> | ||
</section> | ||
); | ||
} |
23 changes: 23 additions & 0 deletions
23
apps/site/src/app/(main)/(home)/sections/Partners/getPartners.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { z } from "zod"; | ||
import { cache } from "react"; | ||
import { client } from "@/lib/sanity/client"; | ||
import { SanityDocument, SanityImageReference } from "@/lib/sanity/types"; | ||
|
||
export const Partner = z.object({ | ||
_type: z.literal("partner"), | ||
_key: z.string(), | ||
name: z.string(), | ||
url: z.string().url().optional(), | ||
logo: SanityImageReference, | ||
}); | ||
|
||
const Partners = SanityDocument.extend({ | ||
partners: z.array(Partner), | ||
}); | ||
|
||
export const getPartners = cache(async () => { | ||
const partners = Partners.parse( | ||
await client.fetch("*[_type == 'partners' && _id == 'partners'][0]"), | ||
); | ||
return partners; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters