File tree Expand file tree Collapse file tree 2 files changed +26
-3
lines changed
dotcom-rendering/src/components Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -85,11 +85,13 @@ export const LoopVideoPlayer = forwardRef(
85
85
} : Props ,
86
86
ref : React . ForwardedRef < HTMLVideoElement > ,
87
87
) => {
88
+ const loopVideoId = `loop-video-${ videoId } ` ;
89
+
88
90
return (
89
91
< >
90
92
{ /* eslint-disable-next-line jsx-a11y/media-has-caption -- Captions will be considered later. */ }
91
93
< video
92
- id = { `loop-video- ${ videoId } ` }
94
+ id = { loopVideoId }
93
95
ref = { ref }
94
96
preload = "none"
95
97
loop = { true }
@@ -138,6 +140,7 @@ export const LoopVideoPlayer = forwardRef(
138
140
</ button >
139
141
) }
140
142
< LoopVideoProgressBar
143
+ videoId = { loopVideoId }
141
144
currentTime = { currentTime }
142
145
duration = { ref . current . duration }
143
146
/>
Original file line number Diff line number Diff line change @@ -13,17 +13,37 @@ const styles = (progressPercentage: number) => css`
13
13
` ;
14
14
15
15
type Props = {
16
+ videoId : string ;
16
17
currentTime : number ;
17
18
duration : number ;
18
19
} ;
19
20
20
- export const LoopVideoProgressBar = ( { currentTime, duration } : Props ) => {
21
+ /**
22
+ * A progress bar for the loop video component.
23
+ *
24
+ * Why don't we use the <progress /> element?
25
+ * It was not possible to properly style the native progress element in safari.
26
+ */
27
+ export const LoopVideoProgressBar = ( {
28
+ videoId,
29
+ currentTime,
30
+ duration,
31
+ } : Props ) => {
21
32
if ( duration <= 0 ) return null ;
22
33
23
34
const progressPercentage = ( currentTime * 100 ) / duration ;
24
35
if ( Number . isNaN ( progressPercentage ) ) {
25
36
return null ;
26
37
}
27
38
28
- return < div role = "progressbar" css = { styles ( progressPercentage ) } /> ;
39
+ return (
40
+ < div
41
+ role = "progressbar"
42
+ aria-labelledby = { videoId }
43
+ aria-valuenow = { progressPercentage }
44
+ aria-valuemin = { 0 }
45
+ aria-valuemax = { 100 }
46
+ css = { styles ( progressPercentage ) }
47
+ />
48
+ ) ;
29
49
} ;
You can’t perform that action at this time.
0 commit comments