Skip to content

Commit 0311d9e

Browse files
Support video in resources section (#147)
* support video * Update ResourceCard.astro * Update ResourceCard.astro
1 parent afd5580 commit 0311d9e

File tree

3 files changed

+38
-13
lines changed

3 files changed

+38
-13
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: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
---
2-
import { Typography, SvgArrowRight2 } from "@chainlink/blocks"
3-
import type { ImageMetadata } from "astro"
2+
import { Typography, SvgArrowRight2, SvgButtonPlay } from "@chainlink/blocks"
43
import styles from "./ResourceCard.module.css"
4+
import { ResourceItem } from "./ResourceGrid.astro"
55
6-
interface Props {
7-
image?: string | ImageMetadata
8-
imageAlt?: string
9-
label: string
10-
link: string
11-
description: string
12-
type: "article" | "video"
13-
}
6+
type Props = ResourceItem
147
158
const { image, imageAlt, label, link, description, type } = Astro.props
169
1710
const imageSrc = typeof image === "string" ? image : image?.src
11+
12+
const isVideo = type === "video"
1813
---
1914

20-
<a href={link} class={styles.card}>
15+
<a href={link} class={styles.card} target={isVideo ? "_blank" : "_self"}>
2116
{
2217
imageSrc && (
2318
<div class={styles.imageWrapper}>
2419
<img src={imageSrc} alt={imageAlt} class={styles.image} />
20+
<div class={styles.overlay}>
21+
<span class={styles.playButtonWrapper}>
22+
<SvgButtonPlay color="card" width={15} height={17.25} />
23+
</span>
24+
</div>
2525
</div>
2626
)
2727
}
2828
<div class={styles.content}>
2929
<Typography
3030
variant="body-semi-l"
3131
style={{
32-
marginBottom: "var(--space-8x)",
32+
marginBottom: isVideo ? "var(--space-2x)" : "var(--space-8x)",
3333
}}>{label}</Typography
3434
>
3535
<Typography variant="body-s" color="muted">

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)