Skip to content

Commit 3d5868a

Browse files
authored
Merge pull request #14117 from guardian/doml/loop-progress-bar
Ensure Loop Video looks correct in DCR containers
2 parents 41d0b51 + b9392b0 commit 3d5868a

File tree

6 files changed

+23
-14
lines changed

6 files changed

+23
-14
lines changed

dotcom-rendering/src/components/Card/components/ImageWrapper.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,14 @@ export const ImageWrapper = ({
159159
imagePositionOnDesktop === 'left' || imagePositionOnDesktop === 'right';
160160
const isHorizontalOnMobile =
161161
imagePositionOnMobile === 'left' || imagePositionOnMobile === 'right';
162+
162163
return (
163164
<div
164165
css={[
165166
(imageType === 'slideshow' ||
166167
imageType === 'picture' ||
167-
imageType === 'video') &&
168+
imageType === 'video' ||
169+
imageType === 'loop-video') &&
168170
isHorizontalOnDesktop &&
169171
flexBasisStyles({
170172
imageSize,
@@ -182,7 +184,6 @@ export const ImageWrapper = ({
182184
}
183185
`,
184186
isHorizontalOnMobile && fixImageWidth(imageFixedSizes),
185-
186187
isHorizontalOnDesktop &&
187188
css`
188189
${from.tablet} {

dotcom-rendering/src/components/FlexibleGeneral.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ const ImmersiveCardLayout = ({
105105
const isLoopingVideo = card.mainMedia?.type === 'LoopVideo';
106106

107107
return (
108-
<UL padBottom={true}>
109-
<LI key={card.url} padSides={true}>
108+
<UL padBottom={true} key={card.url}>
109+
<LI padSides={true}>
110110
<FeatureCard
111111
collectionId={collectionId}
112112
linkTo={card.url}
@@ -447,6 +447,7 @@ const FullWidthCardLayout = ({
447447
showTopBar={!isFirstRow}
448448
padBottom={!isLastRow}
449449
hasLargeSpacing={!isLastRow}
450+
key={card.url}
450451
>
451452
<LI
452453
padSides={true}
@@ -501,6 +502,7 @@ const HalfWidthCardLayout = ({
501502
isFirstRow,
502503
isFirstStandardRow,
503504
aspectRatio,
505+
row,
504506
isLastRow,
505507
containerLevel,
506508
isInHideTrailsAbTest,
@@ -513,6 +515,7 @@ const HalfWidthCardLayout = ({
513515
showAge?: boolean;
514516
absoluteServerTimes: boolean;
515517
aspectRatio: AspectRatio;
518+
row: number;
516519
isLastRow: boolean;
517520
containerLevel: DCRContainerLevel;
518521
isInHideTrailsAbTest?: boolean;
@@ -527,6 +530,7 @@ const HalfWidthCardLayout = ({
527530
showTopBar={!isFirstRow}
528531
/** We use one full top bar for the first row and use a split one for subsequent rows */
529532
splitTopBar={!isFirstStandardRow}
533+
key={row}
530534
>
531535
{cards.map((card, cardIndex) => {
532536
return (
@@ -642,6 +646,7 @@ export const FlexibleGeneral = ({
642646
isFirstRow={!splash.length && i === 0}
643647
isFirstStandardRow={i === 0}
644648
aspectRatio={aspectRatio}
649+
row={i + 1}
645650
isLastRow={i === groupedCards.length - 1}
646651
containerLevel={containerLevel}
647652
isInHideTrailsAbTest={isInHideTrailsAbTest}

dotcom-rendering/src/components/LoopVideo.importable.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ type Props = {
2626
export const LoopVideo = ({
2727
src,
2828
videoId,
29-
width = 600,
30-
height = 360,
29+
width,
30+
height,
3131
thumbnailImage,
3232
fallbackImageComponent,
3333
hasAudio = true,

dotcom-rendering/src/components/LoopVideo.stories.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ export const Default = {
2121
args: {
2222
src: 'https://uploads.guim.co.uk/2024/10/01/241001HeleneLoop_2.mp4',
2323
videoId: 'test-video-1',
24-
height: 337.5,
25-
width: 600,
24+
height: 1080,
25+
width: 1920,
2626
thumbnailImage:
2727
'https://media.guim.co.uk/9bdb802e6da5d3fd249b5060f367b3a817965f0c/0_0_1800_1080/master/1800.jpg',
2828
fallbackImageComponent: (
@@ -39,6 +39,8 @@ export const WithWebmFile = {
3939
name: 'With Webm File',
4040
args: {
4141
...Default.args,
42+
height: 496,
43+
width: 620,
4244
src: 'https://interactive.guim.co.uk/atoms/2023/01/2025-trump-100-days/assets/v/1746020259/videos/header-video.webm',
4345
},
4446
} satisfies StoryObj<typeof LoopVideo>;

dotcom-rendering/src/components/LoopVideoPlayer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import { LoopVideoProgressBar } from './LoopVideoProgressBar';
99

1010
const videoStyles = (width: number, height: number) => css`
1111
position: relative;
12+
display: block;
13+
height: auto;
1214
width: 100%;
13-
/* Find out why this is needed to align the video with its container. */
14-
margin-bottom: -3px;
1515
cursor: pointer;
1616
/* Prevents CLS by letting the browser know the space the video will take up. */
1717
aspect-ratio: ${width} / ${height};

dotcom-rendering/src/components/LoopVideoProgressBar.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ type Props = {
3030
/**
3131
* A progress bar for the loop video component.
3232
*
33-
* Why don't we use the <progress /> element?
34-
* It was not possible to properly style the native progress element in safari.
33+
* Q. Why don't we use the <progress /> element?
34+
* A. It was not possible to properly style the native progress element in safari.
3535
*/
3636
export const LoopVideoProgressBar = ({
3737
videoId,
@@ -44,17 +44,18 @@ export const LoopVideoProgressBar = ({
4444
if (Number.isNaN(progressPercentage)) {
4545
return null;
4646
}
47+
const roundedProgressPercentage = Number(progressPercentage.toFixed(2));
4748

4849
return (
4950
<div
5051
role="progressbar"
5152
aria-labelledby={videoId}
52-
aria-valuenow={progressPercentage}
53+
aria-valuenow={roundedProgressPercentage}
5354
aria-valuemin={0}
5455
aria-valuemax={100}
5556
css={styles}
5657
>
57-
<span css={foregroundStyles(progressPercentage)} />
58+
<span css={foregroundStyles(roundedProgressPercentage)} />
5859
</div>
5960
);
6061
};

0 commit comments

Comments
 (0)