Skip to content

Commit e52111d

Browse files
authored
Render an rotated overlay if its an immersive feature card (#13610)
1 parent cb4e6ef commit e52111d

File tree

2 files changed

+53
-19
lines changed

2 files changed

+53
-19
lines changed

dotcom-rendering/src/components/FeatureCard.tsx

Lines changed: 52 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { css } from '@emotion/react';
2-
import { space } from '@guardian/source/foundations';
2+
import { from, space } from '@guardian/source/foundations';
33
import { SvgMediaControlsPlay } from '@guardian/source/react-components';
44
import { ArticleDesign, type ArticleFormat } from '../lib/articleFormat';
55
import { secondsToDuration } from '../lib/formatTime';
@@ -86,6 +86,21 @@ const contentStyles = css`
8686
flex-direction: column;
8787
`;
8888

89+
const overlayContainerStyles = css`
90+
position: absolute;
91+
bottom: 0;
92+
left: 0;
93+
width: 100%;
94+
`;
95+
96+
const immersiveOverlayContainerStyles = css`
97+
${from.tablet} {
98+
height: 100%;
99+
top: 0;
100+
width: 25%;
101+
}
102+
`;
103+
89104
/**
90105
* Image mask gradient has additional colour stops to emulate a non-linear
91106
* ease in / ease out curve to make the transition smoother. Values were
@@ -94,14 +109,10 @@ const contentStyles = css`
94109
* reduced.) The following article has more detail on non-linear gradients:
95110
* https://css-tricks.com/easing-linear-gradients/
96111
*/
97-
const overlayStyles = css`
98-
display: flex;
99-
flex-direction: column;
100-
text-align: start;
101-
gap: ${space[1]}px;
102-
padding: 64px ${space[2]}px ${space[2]}px;
112+
113+
const overlayMaskGradientStyles = (angle: string) => css`
103114
mask-image: linear-gradient(
104-
180deg,
115+
${angle},
105116
transparent 0px,
106117
rgba(0, 0, 0, 0.0381) 8px,
107118
rgba(0, 0, 0, 0.1464) 16px,
@@ -112,14 +123,31 @@ const overlayStyles = css`
112123
rgba(0, 0, 0, 0.9619) 56px,
113124
rgb(0, 0, 0) 64px
114125
);
126+
`;
127+
const overlayStyles = css`
128+
display: flex;
129+
flex-direction: column;
130+
text-align: start;
131+
gap: ${space[1]}px;
132+
padding: 64px ${space[2]}px ${space[2]}px;
115133
backdrop-filter: blur(12px) brightness(0.5);
134+
${overlayMaskGradientStyles('180deg')};
116135
117136
/* Ensure the waveform is behind the other elements, e.g. headline, pill */
118137
> * {
119138
z-index: 1;
120139
}
121140
`;
122141

142+
const immersiveOverlayStyles = css`
143+
${from.tablet} {
144+
height: 100%;
145+
padding: ${space[2]}px 64px ${space[2]}px ${space[2]}px;
146+
backdrop-filter: blur(12px) brightness(0.5);
147+
${overlayMaskGradientStyles('270deg')}
148+
}
149+
`;
150+
123151
const podcastImageContainerStyles = css`
124152
position: relative;
125153
/* Needs to display above of the image mask overlay */
@@ -247,7 +275,7 @@ export type Props = {
247275
* An immersive feature card variant. It dictates that the card has a full width background image on all breakpoints. It also dictates the the card change aspect ratio to 5:3 on desktop and 4:5 on mobile.
248276
*
249277
*/
250-
// isImmersive?: boolean;
278+
isImmersive?: boolean;
251279
};
252280

253281
export const FeatureCard = ({
@@ -283,7 +311,8 @@ export const FeatureCard = ({
283311
starRating,
284312
showQuotes,
285313
collectionId,
286-
isNewsletter = false, // isImmersive = false,
314+
isNewsletter = false,
315+
isImmersive = false,
287316
}: Props) => {
288317
const hasSublinks = supportingContent && supportingContent.length > 0;
289318

@@ -319,7 +348,7 @@ export const FeatureCard = ({
319348
isExternalLink={isExternalLink}
320349
/>
321350
)}
322-
<div css={contentStyles}>
351+
<div css={[contentStyles]}>
323352
{showYoutubeVideo && (
324353
<div
325354
data-chromatic="ignore"
@@ -446,12 +475,11 @@ export const FeatureCard = ({
446475
<div className="image-overlay" />
447476

448477
<div
449-
css={css`
450-
position: absolute;
451-
bottom: 0;
452-
left: 0;
453-
width: 100%;
454-
`}
478+
css={[
479+
overlayContainerStyles,
480+
isImmersive &&
481+
immersiveOverlayContainerStyles,
482+
]}
455483
>
456484
{mainMedia?.type === 'Audio' &&
457485
!!mainMedia.podcastImage?.src && (
@@ -480,7 +508,13 @@ export const FeatureCard = ({
480508
</div>
481509
</div>
482510
)}
483-
<div css={overlayStyles}>
511+
<div
512+
css={[
513+
overlayStyles,
514+
isImmersive &&
515+
immersiveOverlayStyles,
516+
]}
517+
>
484518
{/**
485519
* Without the wrapping div the headline and byline would have space
486520
* inserted between them due to being direct children of the flex container

dotcom-rendering/src/components/FlexibleGeneral.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ export const SplashCardLayout = ({
231231
imageSize="feature-immersive"
232232
headlineSizes={{ desktop: 'small' }}
233233
supportingContent={card.supportingContent}
234-
// isImmersive={true}
234+
isImmersive={true}
235235
/>
236236
</LI>
237237
</UL>

0 commit comments

Comments
 (0)