Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions dotcom-rendering/src/components/SelfHostedVideo.island.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ type Props = {
isExternalLink: boolean;
};
isInLoopClickTestVariant?: boolean;
isInArticle?: boolean;
};

export const SelfHostedVideo = ({
Expand Down Expand Up @@ -351,6 +352,7 @@ export const SelfHostedVideo = ({
restrictHeightOnDesktop = false,
cardLink,
isInLoopClickTestVariant,
isInArticle = false,
}: Props) => {
const adapted = useShouldAdapt();
const { renderingTarget } = useConfig();
Expand Down Expand Up @@ -1071,13 +1073,22 @@ export const SelfHostedVideo = ({
}
}

const videoStyleFormat = videoStyle.toLocaleLowerCase();

return (
<figure
css={
isInArticle
? css`
margin-bottom: ${space[3]}px;
`
: undefined
}
ref={videoContainerRef}
className={`video-container ${videoStyle.toLocaleLowerCase()} ${
className={`video-container ${videoStyleFormat} ${
role === 'immersive' ? 'element-video-immersive' : ''
}`}
data-component="gu-video-loop"
data-component={`gu-video-${videoStyleFormat}`}
>
<div
ref={setNode}
Expand Down
70 changes: 30 additions & 40 deletions dotcom-rendering/src/components/SelfHostedVideoInArticle.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { css } from '@emotion/react';
import { space } from '@guardian/source/foundations';
import type { FEAspectRatio } from '../frontend/feFront';
import { isInteractive } from '../layouts/lib/interactiveLegacyStyling';
import type { ArticleFormat } from '../lib/articleFormat';
Expand All @@ -13,10 +11,6 @@ import type { VideoPlayerFormat } from '../types/mainMedia';
import { Island } from './Island';
import { SelfHostedVideo } from './SelfHostedVideo.island';

const containerStyles = css`
margin-bottom: ${space[3]}px;
`;

type SelfHostedVideoInArticleProps = {
element: MediaAtomBlockElement;
format: ArticleFormat;
Expand Down Expand Up @@ -49,39 +43,35 @@ export const SelfHostedVideoInArticle = ({
}

return (
<div css={containerStyles}>
<Island priority="critical" defer={{ until: 'visible' }}>
<SelfHostedVideo
atomId={element.id}
fallbackImage={posterImageUrl}
fallbackImageAlt={caption}
fallbackImageAspectRatio={
(firstVideoSource?.aspectRatio ??
'5:4') as FEAspectRatio
}
fallbackImageLoading="lazy"
fallbackImageSize="small"
aspectRatio={aspectRatio}
linkTo="Article-embed-MediaAtomBlockElement"
posterImage={posterImageUrl}
posterImageAspectRatio={
firstVideoSource?.aspectRatio ?? '5:4'
}
sources={sources}
subtitleSize="medium"
subtitleSource={getSubtitleAsset(element.assets)}
videoStyle={videoStyle}
uniqueId={element.id}
caption={caption}
format={format}
isMainMedia={isMainMedia}
role={role}
preventAutoplay={videoStyle === 'Default'}
restrictHeightOnDesktop={
isVerticalVideo && !isInteractive(format.design)
}
/>
</Island>
</div>
<Island priority="critical" defer={{ until: 'visible' }}>
<SelfHostedVideo
atomId={element.id}
fallbackImage={posterImageUrl}
fallbackImageAlt={caption}
fallbackImageAspectRatio={
(firstVideoSource?.aspectRatio ?? '5:4') as FEAspectRatio
}
fallbackImageLoading="lazy"
fallbackImageSize="small"
aspectRatio={aspectRatio}
linkTo="Article-embed-MediaAtomBlockElement"
posterImage={posterImageUrl}
posterImageAspectRatio={firstVideoSource?.aspectRatio ?? '5:4'}
sources={sources}
subtitleSize="medium"
subtitleSource={getSubtitleAsset(element.assets)}
videoStyle={videoStyle}
uniqueId={element.id}
caption={caption}
format={format}
isMainMedia={isMainMedia}
role={role}
preventAutoplay={videoStyle === 'Default'}
restrictHeightOnDesktop={
isVerticalVideo && !isInteractive(format.design)
}
isInArticle={true}
/>
</Island>
);
};
Loading