File tree Expand file tree Collapse file tree 3 files changed +53
-20
lines changed Expand file tree Collapse file tree 3 files changed +53
-20
lines changed Original file line number Diff line number Diff line change 1
1
import { css } from '@emotion/react' ;
2
2
import type { Meta , StoryObj } from '@storybook/react' ;
3
+ import { ArticleDesign , ArticleDisplay , Pillar } from '../lib/articleFormat' ;
3
4
import { VideoAtom } from './VideoAtom' ;
4
5
5
6
const meta = {
@@ -25,6 +26,13 @@ export const Default = {
25
26
mimeType : 'video/mp4' ,
26
27
} ,
27
28
] ,
29
+ isMainMedia : false ,
30
+ format : {
31
+ theme : Pillar . News ,
32
+ display : ArticleDisplay . Standard ,
33
+ design : ArticleDesign . Standard ,
34
+ } ,
35
+ caption : 'This is a video caption' ,
28
36
} ,
29
37
decorators : [
30
38
( Story ) => (
Original file line number Diff line number Diff line change
1
+ import type { ArticleFormat } from '../lib/articleFormat' ;
2
+ import { Caption } from './Caption' ;
1
3
import { MaintainAspectRatio } from './MaintainAspectRatio' ;
2
4
3
5
type AssetType = {
@@ -6,41 +8,61 @@ type AssetType = {
6
8
} ;
7
9
8
10
interface Props {
11
+ format : ArticleFormat ;
9
12
assets : AssetType [ ] ;
13
+ isMainMedia : boolean ;
10
14
poster ?: string ;
15
+ caption ?: string ;
11
16
height ?: number ;
12
17
width ?: number ;
13
18
}
14
19
15
20
export const VideoAtom = ( {
21
+ format,
16
22
assets,
23
+ isMainMedia,
17
24
poster,
25
+ caption,
18
26
height = 259 ,
19
27
width = 460 ,
20
28
} : Props ) => {
21
29
if ( assets . length === 0 ) return null ; // Handle empty assets array
22
30
return (
23
- < MaintainAspectRatio
24
- height = { height }
25
- width = { width }
26
- data-spacefinder-role = "inline"
27
- >
28
- { /* eslint-disable-next-line jsx-a11y/media-has-caption -- caption not available */ }
29
- < video
30
- controls = { true }
31
- preload = "metadata"
32
- width = { width }
31
+ < >
32
+ < MaintainAspectRatio
33
33
height = { height }
34
- poster = { poster }
34
+ width = { width }
35
+ data-spacefinder-role = "inline"
35
36
>
36
- { assets . map ( ( asset , index ) => (
37
- < source key = { index } src = { asset . url } type = { asset . mimeType } />
38
- ) ) }
39
- < p >
40
- { `Your browser doesn't support HTML5 video. Here is a ` }
41
- < a href = { assets [ 0 ] ?. url } > link to the video</ a > instead.
42
- </ p >
43
- </ video >
44
- </ MaintainAspectRatio >
37
+ { /* eslint-disable-next-line jsx-a11y/media-has-caption -- caption not available */ }
38
+ < video
39
+ controls = { true }
40
+ preload = "metadata"
41
+ width = { width }
42
+ height = { height }
43
+ poster = { poster }
44
+ >
45
+ { assets . map ( ( asset , index ) => (
46
+ < source
47
+ key = { index }
48
+ src = { asset . url }
49
+ type = { asset . mimeType }
50
+ />
51
+ ) ) }
52
+ < p >
53
+ { `Your browser doesn't support HTML5 video. Here is a ` }
54
+ < a href = { assets [ 0 ] ?. url } > link to the video</ a > instead.
55
+ </ p >
56
+ </ video >
57
+ </ MaintainAspectRatio >
58
+ { ! ! caption && (
59
+ < Caption
60
+ captionText = { caption }
61
+ format = { format }
62
+ mediaType = "Video"
63
+ isMainMedia = { isMainMedia }
64
+ />
65
+ ) }
66
+ </ >
45
67
) ;
46
68
} ;
Original file line number Diff line number Diff line change @@ -478,8 +478,11 @@ export const renderElement = ({
478
478
case 'model.dotcomrendering.pageElements.MediaAtomBlockElement' :
479
479
return (
480
480
< VideoAtom
481
+ format = { format }
481
482
assets = { element . assets }
482
483
poster = { element . posterImage ?. [ 0 ] ?. url }
484
+ caption = { element . title }
485
+ isMainMedia = { isMainMedia }
483
486
/>
484
487
) ;
485
488
case 'model.dotcomrendering.pageElements.MiniProfilesBlockElement' :
You can’t perform that action at this time.
0 commit comments