Skip to content

Commit c44ee2c

Browse files
authored
Merge pull request #14866 from guardian/doml/rename-loop-video
Rename LoopVideo to SelfHostedVideo
2 parents 1c30115 + 57b710a commit c44ee2c

17 files changed

+116
-119
lines changed

dotcom-rendering/fixtures/manual/trails.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ export const newsletterTrails: [DCRFrontCard, DCRFrontCard] = [
648648
},
649649
];
650650

651-
export const loopVideoCard: DCRFrontCard = {
651+
export const selfHostedVideoCard: DCRFrontCard = {
652652
...defaultCardProps,
653653
dataLinkName: 'news | group-0 | card-@2',
654654
url: '/uk-news/2025/jan/22/prince-harry-says-sun-publisher-made-historic-admission-as-he-settles-case',

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ import type { Loading } from '../CardPicture';
4242
import { CardPicture } from '../CardPicture';
4343
import { Island } from '../Island';
4444
import { LatestLinks } from '../LatestLinks.importable';
45-
import { LoopVideo } from '../LoopVideo.importable';
46-
import type { SubtitleSize } from '../LoopVideoPlayer';
4745
import { Pill } from '../Pill';
46+
import { SelfHostedVideo } from '../SelfHostedVideo.importable';
47+
import type { SubtitleSize } from '../SelfHostedVideoPlayer';
4848
import { SlideshowCarousel } from '../SlideshowCarousel.importable';
4949
import { Snap } from '../Snap';
5050
import { SnapCssSandbox } from '../SnapCssSandbox';
@@ -946,7 +946,7 @@ export const Card = ({
946946
priority="critical"
947947
defer={{ until: 'visible' }}
948948
>
949-
<LoopVideo
949+
<SelfHostedVideo
950950
sources={media.mainMedia.sources}
951951
atomId={media.mainMedia.atomId}
952952
uniqueId={uniqueId}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const hoverStyles = css`
5959
*/
6060
:has(
6161
ul.sublinks:hover,
62-
.loop-video-container:hover,
62+
.video-container:hover,
6363
.slideshow-carousel:hover,
6464
.branding-logo:hover
6565
) {

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {
55
audioTrails,
66
galleryTrails,
77
getSublinks,
8-
loopVideoCard,
98
opinionTrails,
9+
selfHostedVideoCard,
1010
slideshowCard,
1111
trails,
1212
videoTrails,
@@ -542,14 +542,14 @@ export const ImmersiveCardsSplashAndStandard: Story = {
542542
},
543543
};
544544

545-
export const LoopVideoCards: Story = {
546-
name: 'Looping video cards',
545+
export const SelfHostedVideoCards: Story = {
546+
name: 'Self-hosted video cards',
547547
args: {
548-
frontSectionTitle: 'Loop video cards',
548+
frontSectionTitle: 'Self-hosted video cards',
549549
groupedTrails: {
550550
...emptyGroupedTrails,
551-
splash: [loopVideoCard],
552-
standard: [loopVideoCard], // Loop video is disabled at standard card size
551+
splash: [selfHostedVideoCard],
552+
standard: [selfHostedVideoCard], // Self-hosted video is disabled at standard card size
553553
},
554554
},
555555
};

dotcom-rendering/src/components/FlexibleGeneral.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import type { ResponsiveFontSize } from './CardHeadline';
2121
import type { Loading } from './CardPicture';
2222
import { FeatureCard } from './FeatureCard';
2323
import { FrontCard } from './FrontCard';
24-
import type { SubtitleSize } from './LoopVideoPlayer';
24+
import type { SubtitleSize } from './SelfHostedVideoPlayer';
2525
import type { Alignment } from './SupportingContent';
2626

2727
type Props = {

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { breakpoints } from '@guardian/source/foundations';
22
import type { Meta, StoryObj } from '@storybook/react-webpack5';
33
import { discussionApiUrl } from '../../fixtures/manual/discussionApiUrl';
44
import {
5-
loopVideoCard,
65
opinionTrails,
6+
selfHostedVideoCard,
77
slideshowCard,
88
snapLink,
99
trails,
@@ -280,14 +280,14 @@ export const GigaBoostedSplashWithLiveUpdates: Story = {
280280
},
281281
};
282282

283-
export const LoopVideoCards: Story = {
284-
name: 'Looping video cards',
283+
export const SelfHostedVideoCard: Story = {
284+
name: 'Self-hosted video cards',
285285
args: {
286-
frontSectionTitle: 'Looping video',
286+
frontSectionTitle: 'Self-hosted video',
287287
groupedTrails: {
288288
...emptyGroupedTrails,
289289
snap: [],
290-
standard: [loopVideoCard],
290+
standard: [selfHostedVideoCard],
291291
},
292292
collectionId: 1,
293293
},

dotcom-rendering/src/components/FlexibleSpecial.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { UL } from './Card/components/UL';
1919
import type { ResponsiveFontSize } from './CardHeadline';
2020
import type { Loading } from './CardPicture';
2121
import { FrontCard } from './FrontCard';
22-
import type { SubtitleSize } from './LoopVideoPlayer';
22+
import type { SubtitleSize } from './SelfHostedVideoPlayer';
2323
import type { Alignment } from './SupportingContent';
2424

2525
type Props = {

dotcom-rendering/src/components/LoopVideo.importable.tsx renamed to dotcom-rendering/src/components/SelfHostedVideo.importable.tsx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { useShouldAdapt } from '../lib/useShouldAdapt';
1515
import { useSubtitles } from '../lib/useSubtitles';
1616
import type { CustomPlayEventDetail, Source } from '../lib/video';
1717
import {
18-
customLoopPlayAudioEventName,
18+
customSelfHostedVideoPlayAudioEventName,
1919
customYoutubePlayEventName,
2020
} from '../lib/video';
2121
import { CardPicture, type Props as CardPictureProps } from './CardPicture';
@@ -24,12 +24,12 @@ import type {
2424
PLAYER_STATES,
2525
PlayerStates,
2626
SubtitleSize,
27-
} from './LoopVideoPlayer';
28-
import { LoopVideoPlayer } from './LoopVideoPlayer';
27+
} from './SelfHostedVideoPlayer';
28+
import { SelfHostedVideoPlayer } from './SelfHostedVideoPlayer';
2929
import { ophanTrackerWeb } from './YoutubeAtom/eventEmitters';
3030

3131
const videoContainerStyles = css`
32-
z-index: ${getZIndex('loop-video-container')};
32+
z-index: ${getZIndex('video-container')};
3333
position: relative;
3434
`;
3535

@@ -39,21 +39,21 @@ const videoContainerStyles = css`
3939
*/
4040
export const dispatchCustomPlayAudioEvent = (uniqueId: string) => {
4141
document.dispatchEvent(
42-
new CustomEvent(customLoopPlayAudioEventName, {
42+
new CustomEvent(customSelfHostedVideoPlayAudioEventName, {
4343
detail: { uniqueId },
4444
}),
4545
);
4646
};
4747

4848
const logAndReportError = (src: string, error: Error) => {
49-
const message = `Autoplay failure for loop video. Source: ${src} could not be played. Error: ${String(
49+
const message = `Autoplay failure for self-hosted video. Source: ${src} could not be played. Error: ${String(
5050
error,
5151
)}`;
5252

5353
if (error instanceof Error) {
5454
window.guardian.modules.sentry.reportError(
5555
new Error(message),
56-
'loop-video',
56+
'self-hosted-video',
5757
);
5858
}
5959

@@ -72,7 +72,7 @@ const getOptimisedPosterImage = (mainImage: string): string => {
7272

7373
return generateImageURL({
7474
mainImage,
75-
imageWidth: 940, // The widest a looping video can be: Flexible special, giga-boosted
75+
imageWidth: 940, // The widest a video can be: flexible special container, giga-boosted slot
7676
resolution,
7777
aspectRatio: '5:4',
7878
});
@@ -95,7 +95,7 @@ const doesVideoHaveAudio = (video: HTMLVideoElement): boolean => {
9595
new Error(
9696
'Could not determine if video has audio. This is likely due to the browser not supporting the necessary properties.',
9797
),
98-
'loop-video',
98+
'self-hosted-video',
9999
);
100100

101101
return true;
@@ -127,7 +127,7 @@ type Props = {
127127
subtitleSize: SubtitleSize;
128128
};
129129

130-
export const LoopVideo = ({
130+
export const SelfHostedVideo = ({
131131
sources,
132132
atomId,
133133
uniqueId,
@@ -321,7 +321,7 @@ export const LoopVideo = ({
321321
};
322322

323323
document.addEventListener(
324-
customLoopPlayAudioEventName,
324+
customSelfHostedVideoPlayAudioEventName,
325325
handleCustomPlayAudioEvent,
326326
);
327327
document.addEventListener(
@@ -339,7 +339,7 @@ export const LoopVideo = ({
339339

340340
return () => {
341341
document.removeEventListener(
342-
customLoopPlayAudioEventName,
342+
customSelfHostedVideoPlayAudioEventName,
343343
handleCustomPlayAudioEvent,
344344
);
345345
document.removeEventListener(
@@ -573,13 +573,13 @@ export const LoopVideo = ({
573573
* Sentry and log in the console.
574574
*/
575575
const onError = () => {
576-
const message = `Loop video could not be played. source: ${
576+
const message = `Self-hosted video could not be played. source: ${
577577
vidRef.current?.currentSrc ?? 'unknown'
578578
}`;
579579

580580
window.guardian.modules.sentry.reportError(
581581
new Error(message),
582-
'loop-video',
582+
'self-hosted-video',
583583
);
584584
log('dotcom', message);
585585
};
@@ -643,10 +643,10 @@ export const LoopVideo = ({
643643
<figure
644644
ref={setNode}
645645
css={videoContainerStyles}
646-
className="loop-video-container"
646+
className="video-container"
647647
data-component="gu-video-loop"
648648
>
649-
<LoopVideoPlayer
649+
<SelfHostedVideoPlayer
650650
sources={sources}
651651
atomId={atomId}
652652
uniqueId={uniqueId}

dotcom-rendering/src/components/LoopVideo.stories.tsx renamed to dotcom-rendering/src/components/SelfHostedVideo.stories.tsx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@ import { breakpoints } from '@guardian/source/foundations';
22
import type { Meta, StoryObj } from '@storybook/react-webpack5';
33
import { expect, userEvent, within } from 'storybook/test';
44
import { centreColumnDecorator } from '../../.storybook/decorators/gridDecorators';
5-
import { LoopVideo } from './LoopVideo.importable';
5+
import { SelfHostedVideo } from './SelfHostedVideo.importable';
66

77
const meta = {
8-
component: LoopVideo,
9-
title: 'Components/LoopVideo',
8+
component: SelfHostedVideo,
9+
title: 'Components/SelfHostedVideo',
1010
decorators: [centreColumnDecorator],
11-
render: (args) => <LoopVideo {...args} />,
11+
render: (args) => <SelfHostedVideo {...args} />,
1212
parameters: {
1313
chromatic: {
1414
viewports: [breakpoints.mobile, breakpoints.wide],
1515
disableSnapshot: true,
1616
},
1717
},
18-
} satisfies Meta<typeof LoopVideo>;
18+
} satisfies Meta<typeof SelfHostedVideo>;
1919

2020
export default meta;
21-
type Story = StoryObj<typeof LoopVideo>;
21+
type Story = StoryObj<typeof SelfHostedVideo>;
2222

23-
export const Default: Story = {
24-
name: 'Default',
23+
export const Loop4to5: Story = {
24+
name: 'Looping video in 4:5 aspect ratio',
2525
args: {
2626
sources: [
2727
{
@@ -56,10 +56,10 @@ export const Default: Story = {
5656
// },
5757
// };
5858

59-
export const Without5to4Ratio: Story = {
60-
name: 'Without 5:4 aspect ratio',
59+
export const Loop16to9: Story = {
60+
name: 'Looping video in 16:9 aspect ratio',
6161
args: {
62-
...Default.args,
62+
...Loop4to5.args,
6363
sources: [
6464
{
6565
src: 'https://uploads.guim.co.uk/2024/10/01/241001HeleneLoop_2.mp4',
@@ -72,11 +72,11 @@ export const Without5to4Ratio: Story = {
7272
};
7373

7474
export const PausePlay: Story = {
75-
...Default,
75+
...Loop4to5,
7676
name: 'Pause and play interaction',
7777
play: async ({ canvasElement }) => {
7878
const canvas = within(canvasElement);
79-
const videoEl = canvas.getByTestId('loop-video');
79+
const videoEl = canvas.getByTestId('self-hosted-video-player');
8080

8181
await userEvent.click(videoEl, {
8282
delay: 300, // Allow video to start playing.
@@ -93,7 +93,7 @@ export const PausePlay: Story = {
9393
};
9494

9595
export const UnmuteMute: Story = {
96-
...Default,
96+
...Loop4to5,
9797
name: 'Unmute and mute interaction',
9898
parameters: {
9999
test: {
@@ -120,11 +120,11 @@ function sleep(ms: number) {
120120
}
121121

122122
export const InteractionObserver: Story = {
123-
...Default,
123+
...Loop4to5,
124124
name: 'Interaction observer',
125125
render: (args) => (
126126
<div data-testid="test-container">
127-
<LoopVideo {...args} />
127+
<SelfHostedVideo {...args} />
128128
<div style={{ height: '100vh' }}></div>
129129
<p data-testid="page-end">End of page</p>
130130
</div>

0 commit comments

Comments
 (0)