Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Resource Card Components #178

Merged
merged 9 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions apps/sanity/schemas/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ export default defineType({
validation: (Rule) => Rule.required(),
}),
defineField({
name: "stickyNoteColor",
title: "Sticky Note Color",
name: "background",
title: "Island Background",
description:
"Note that the color will be used as a background for black text, so please choose a color with enough contrast.",
type: "color",
"There are 4 different backgrounds to make the islands look unique",
type: "image",
validation: (Rule) => Rule.required(),
}),
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
@use "zothacks-theme" as theme;
@use "bootstrap-utils" as utils;

.group {
margin-top: 50px;
width: 344px;
position: relative;
padding: 1rem 0;
box-shadow: 0 6px 5px -2px rgba(gray, 0.5);
@media screen and (max-width: 400px) {
width: 300px;
}
}

.tape {
Expand All @@ -34,6 +30,15 @@
height: 450px;
}

.titleLink {
font-family: inherit;
text-decoration: none;
color: inherit;
:link {
text-decoration: none;
}
}

.tag {
background-image: url("~@/assets/images/resource-link.svg");
background-size: 100% 100%;
Expand Down Expand Up @@ -64,4 +69,49 @@
.text {
width: 90%;
text-align: center;
font-family: utils.$font-family-base;
}

.islandBackground {
position: absolute;
}

.CardContainer {
position: relative;
height: auto;
aspect-ratio: 1 / 1.3;
display: flex;
justify-content: center;
align-items: center;
font-family: utils.$font-family-base;
}

@include utils.media-breakpoint-up(sm) {
.CardContainer {
width: 500px;
min-width: 500px;
}
.islandBackground {
width: 500px;
}
.group {
width: 300px;
}
}

@include utils.media-breakpoint-down(sm) {
.CardContainer {
width: 350px;
min-width: 350px;
}
.islandBackground {
width: 350px;
}
.group {
width: 200px;
}
.description {
max-height: 100px;
overflow: auto;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface ResourceCardProps {
description: JSX.Element;
stickerSrc?: string;
links: Tag[];
stickyNoteColor: string;
islandBackground: string;
}

const variant: Variants = {
Expand Down Expand Up @@ -43,39 +43,26 @@ export default function ResourceCard({
description,
stickerSrc,
links,
stickyNoteColor,
islandBackground,
}: ResourceCardProps) {
return (
<AnimatePresence mode="wait">
<motion.div style={{ position: "relative" }}>
<motion.div
initial={{
scale: 1.1,
opacity: 0,
rotateX: 15,
}}
<motion.div className={styles.CardContainer}>
<motion.img
src={islandBackground}
alt="island"
initial="initial"
viewport={{ once: true }}
whileInView={{
scale: 1,
rotateX: 0,
opacity: 1,
transition: {
delay: 0.1,
duration: 0.65,
ease: cubicBezier(0.64, 0, 0.78, 0),
},
}}
className={styles.tape}
></motion.div>
whileInView="animate"
className={styles.islandBackground}
variants={variant}
/>
<motion.div
variants={variant}
initial="initial"
whileInView="animate"
viewport={{ once: true }}
className={styles.group}
style={{
backgroundColor: `${stickyNoteColor}`,
}}
>
<div className={styles.container + " text-center px-3"}>
{stickerSrc && (
Expand All @@ -86,33 +73,39 @@ export default function ResourceCard({
variants={variant}
/>
)}
<h3>{title}</h3>
{description}
<h3>
{links && links[0] ? (
<motion.a
href={links[0].link}
target="_blank"
rel="noopener noreferrer"
className={styles.titleLink}
>
{title}
</motion.a>
) : (
title
)}{" "}
{links.map(({ text, link }) => (
<motion.a
className="d-inline ms-1 vertical-align-middle"
variants={variant}
key={link}
href={link}
target="_blank"
rel="noopener noreferrer"
>
<Image
src={openNewWindow}
width="20"
height="20"
alt="Open link in new window"
/>
</motion.a>
))}
</h3>
<div className={styles.description}>{description}</div>
</div>

{links.map(({ text, link }) => (
<motion.a
key={link}
href={link}
target="_blank"
rel="noopener noreferrer"
className={styles.tag}
variants={variant}
>
{text}
<motion.div
className="d-inline ms-1 vertical-align-middle"
variants={variant}
>
<Image
src={openNewWindow}
width="20"
height="20"
alt="Open link in new window"
/>
</motion.div>
</motion.a>
))}
</motion.div>
</motion.div>
</AnimatePresence>
Expand Down
10 changes: 6 additions & 4 deletions apps/site/src/views/Resources/getResources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ const Resources = z.array(
_type: z.literal("reference"),
}),
}),
stickyNoteColor: z.object({
_type: z.literal("color"),
alpha: z.number(),
hex: z.string(),
background: z.object({
_type: z.string(),
asset: z.object({
_ref: z.string(),
_type: z.literal("reference"),
}),
}),
title: z.string(),
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

.bottom-spacer {
margin-bottom: 50px;
width: 100%;
height: auto;
}

.column {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@ async function ApiResources() {
<div className={styles["bottom-spacer"] + " row"}>
{/* Sticky Notes */}
{resources.map(
({ _id, title, description, link, logo, stickyNoteColor }) => (
({ _id, title, description, link, logo, background }) => (
<div className={styles.column + " col"} key={_id}>
<ResourceCard
key={_id}
title={title}
description={<PortableText value={description} />}
stickerSrc={imageUrlBuilder(client).image(logo).url()}
links={[{ text: "API Reference", link: link }]}
stickyNoteColor={stickyNoteColor.hex}
islandBackground={imageUrlBuilder(client)
.image(background)
.url()}
/>
</div>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ async function BackendResources() {
<div className={styles["bottom-spacer"] + " row"}>
{/* Sticky Notes */}
{resources.map(
({ _id, title, description, link, logo, stickyNoteColor }) => (
({ _id, title, description, link, logo, background }) => (
<div className={styles.column + " col"} key={_id}>
<ResourceCard
title={title}
description={<PortableText value={description} />}
stickerSrc={urlImageBuilder(client).image(logo).url()}
stickyNoteColor={stickyNoteColor.hex}
islandBackground={urlImageBuilder(client).image(background).url()}
links={[{ text: "Reference", link: link }]}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ async function FrontendResources() {
</div>
<div className={styles["bottom-spacer"] + " row"}>
{resources.map(
({ _id, title, description, link, logo, stickyNoteColor }) => (
({ _id, title, description, link, logo, background }) => (
<div className={styles.column + " col"} key={_id}>
<ResourceCard
title={title}
description={<PortableText value={description} />}
stickerSrc={urlImageBuilder(client).image(logo).url()}
stickyNoteColor={stickyNoteColor.hex}
islandBackground={urlImageBuilder(client).image(background).url()}
links={[{ text: "Reference", link: link }]}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ async function StarterPacks() {
</div>
<div className={styles["bottom-spacer"] + " row"}>
{resources.map(
({ _id, title, description, link, logo, stickyNoteColor }) => (
({ _id, title, description, link, logo, background }) => (
<div className={styles.column + " col"} key={_id}>
<ResourceCard
title={title}
description={<PortableText value={description} />}
stickerSrc={urlImageBuilder(client).image(logo).url()}
stickyNoteColor={stickyNoteColor.hex}
islandBackground={urlImageBuilder(client).image(background).url()}
links={[{ text: "Reference", link: link }]}
/>
</div>
Expand Down
Loading