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

💄V2 Card component - added option to embed Youtube videos inside the card carousel #3476

Merged
merged 4 commits into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,13 @@ export const CardCarouselSchema: Template = {
component: GUIDGeneratorComponent,
},
},
{
type: "string",
label: "Embed",
name: "embed",
description:
"The YouTube video ID to embed (https://www.youtube.com/watch?v=[embed]).",
},
{
type: "image",
label: "Image",
Expand Down
39 changes: 22 additions & 17 deletions components/blocks/cardCarousel/layout/card.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ListItem } from "@/components/blocksSubtemplates/listItem";
import { PillGroup } from "@/components/blocksSubtemplates/pillGroup";
import { YouTubeEmbed } from "@/components/embeds/youtubeEmbed";
import Image from "next/image";
import { useState } from "react";
import { tinaField } from "tinacms/dist/react";
Expand All @@ -24,23 +25,27 @@ const Card = ({ data, placeholder }: CardProps) => {
})?.classes
}`}
>
{(data.image || placeholder) && (
<div
className="relative mb-2 min-h-36 w-full overflow-hidden rounded-md"
data-tina-field={tinaField(data, "image")}
>
<Image
src={
usePlaceholder
? placeholderImage
: (data.image ?? placeholderImage)
}
onError={() => setUsePlaceholder(true)}
alt={data.altText ?? "Card Image"}
fill={true}
className={data.contain ? "object-contain" : "object-cover"}
/>
</div>
{data.embed ? (
<YouTubeEmbed className="mb-2 min-h-36 w-full" id={data.embed} />
) : (
(data.image || placeholder) && (
<div
className="relative mb-2 min-h-36 w-full overflow-hidden rounded-md"
data-tina-field={tinaField(data, "image")}
>
<Image
src={
usePlaceholder
? placeholderImage
: (data.image ?? placeholderImage)
}
onError={() => setUsePlaceholder(true)}
alt={data.altText ?? "Card Image"}
fill={true}
className={data.contain ? "object-contain" : "object-cover"}
/>
</div>
)
)}
<Icon data={{ name: data.icon }} className="size-6 text-sswRed" />
{data.chips && <PillGroup data={data.chips} />}
Expand Down
4 changes: 2 additions & 2 deletions components/embeds/youtubeEmbed.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
type YouTubeEmbedProps = {
className?: string;
width: string;
height: string;
width?: string;
height?: string;
id: string;
autoplay?: boolean;
};
Expand Down
2 changes: 1 addition & 1 deletion tina/tina-lock.json

Large diffs are not rendered by default.

Loading