Skip to content

Commit 16bb554

Browse files
committed
support video
1 parent 817bcc1 commit 16bb554

File tree

3 files changed

+37
-11
lines changed

3 files changed

+37
-11
lines changed

src/components/Resource/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,4 @@ Both approaches work! Use imported images for better optimization, or use path s
103103
## Resource types
104104

105105
- **article**: Displays "Read the full article" footer with an arrow icon
106-
- **video**: No special footer (just the card with title and description)
106+
- **video**: No special footer (just the card with title and description). For video resources, the `image` prop can be a YouTube video thumbnail URL, and the `link` prop can be the YouTube video URL

src/components/Resource/ResourceCard.astro

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
---
2-
import { Typography, SvgArrowRight2 } from "@chainlink/blocks"
2+
import { Typography, SvgArrowRight2, SvgButtonPlay } from "@chainlink/blocks"
33
import type { ImageMetadata } from "astro"
44
import styles from "./ResourceCard.module.css"
5+
import { ResourceItem } from "./ResourceGrid.astro"
56
6-
interface Props {
7-
image?: string | ImageMetadata
8-
imageAlt?: string
9-
label: string
10-
link: string
11-
description: string
12-
type: "article" | "video"
13-
}
7+
type Props = ResourceItem
148
159
const { image, imageAlt, label, link, description, type } = Astro.props
1610
1711
const imageSrc = typeof image === "string" ? image : image?.src
12+
13+
const isVideo = type === "video"
1814
---
1915

20-
<a href={link} class={styles.card}>
16+
<a href={link} class={styles.card} target={isVideo ? "_blank" : "_self"}>
2117
{
2218
imageSrc && (
2319
<div class={styles.imageWrapper}>
2420
<img src={imageSrc} alt={imageAlt} class={styles.image} />
21+
<div class={styles.overlay}>
22+
<span class={styles.playButtonWrapper}>
23+
<SvgButtonPlay color="card" width={15} height={17.25} />
24+
</span>
25+
</div>
2526
</div>
2627
)
2728
}

src/components/Resource/ResourceCard.module.css

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,36 @@
2020
background-color: var(--muted);
2121
}
2222

23+
.overlay {
24+
position: absolute;
25+
top: 0;
26+
left: 0;
27+
width: 100%;
28+
height: 100%;
29+
display: flex;
30+
justify-content: center;
31+
align-items: center;
32+
}
33+
34+
.playButtonWrapper {
35+
background-color: var(--brand);
36+
width: 45px;
37+
height: 45px;
38+
display: flex;
39+
justify-content: center;
40+
align-items: center;
41+
& svg {
42+
color: var(--white);
43+
fill: var(--white);
44+
}
45+
}
46+
2347
.imageWrapper {
2448
width: 100%;
2549
aspect-ratio: 16 / 9;
2650
overflow: hidden;
2751
border-radius: var(--space-2x);
52+
position: relative;
2853
}
2954

3055
.image {

0 commit comments

Comments
 (0)