Skip to content

Commit 3f18c23

Browse files
committed
feat(video): add video source media attribute
1 parent a6778e1 commit 3f18c23

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

docs/plugins/video.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,21 @@ HTML element.
2626
&#123;<br />
2727
&nbsp;&nbsp;src: string;<br />
2828
&nbsp;&nbsp;type: string;<br />
29+
&nbsp;&nbsp;media?: string;<br />
2930
&#125;[]
3031
</td>
3132
<td>
3233
<p>an array of video files</p>
3334
<ul>
3435
<li>`src` - video source URL</li>
35-
<li>`type` - video source type (e.g., <span class="font-mono">video/mp4</span>)</li>
36+
<li>
37+
`type` - video source type
38+
(e.g., <span class="font-mono">video/mp4</span>)
39+
</li>
40+
<li>
41+
`media` - media query for the resource's intended media
42+
(e.g., <span class="font-mono">(min-width: 800px)</span>)
43+
</li>
3644
</ul>
3745
</td>
3846
</tr>

src/plugins/video/VideoSlide.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ export function VideoSlide({ slide, offset }: VideoSlideProps) {
133133
publish(ACTIVE_SLIDE_COMPLETE);
134134
}}
135135
>
136-
{sources.map(({ src, type }) => (
137-
<source key={[src, type].join("|")} src={src} type={type} />
136+
{sources.map(({ src, type, media }) => (
137+
<source key={[src, type, media].filter(Boolean).join("|")} src={src} type={type} media={media} />
138138
))}
139139
</video>
140140
)}

src/plugins/video/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { GenericSlide } from "../../index.js";
21
import { Video } from "./Video.js";
32

43
declare module "../../types.js" {
@@ -44,6 +43,8 @@ declare module "../../types.js" {
4443
src: string;
4544
/** video source type (e.g., `video/mp4`) */
4645
type: string;
46+
/** media query for the resource's intended media (e.g., `(min-width: 800px)`) */
47+
media?: string;
4748
}[];
4849
}
4950

0 commit comments

Comments
 (0)