Skip to content

Commit a6c675e

Browse files
committed
Fix feature podcast blur, immersive podcast styles
1 parent f9d2ae4 commit a6c675e

File tree

1 file changed

+125
-48
lines changed

1 file changed

+125
-48
lines changed

dotcom-rendering/src/components/FeatureCard.tsx

Lines changed: 125 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { css } from '@emotion/react';
2-
import { from, space } from '@guardian/source/foundations';
2+
import { from, space, until } 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';
@@ -107,9 +107,10 @@ const overlayContainerStyles = css`
107107

108108
const immersiveOverlayContainerStyles = css`
109109
${from.tablet} {
110-
height: 100%;
111110
top: 0;
112-
width: 25%;
111+
height: 100%;
112+
width: 220px;
113+
z-index: 1;
113114
}
114115
`;
115116

@@ -146,7 +147,7 @@ const overlayStyles = css`
146147
${overlayMaskGradientStyles('180deg')};
147148
148149
/* Ensure the waveform is behind the other elements, e.g. headline, pill */
149-
> * {
150+
> :not(.waveform) {
150151
z-index: 1;
151152
}
152153
`;
@@ -171,6 +172,20 @@ const podcastImageStyles = css`
171172
width: 80px;
172173
`;
173174

175+
const nonImmersivePodcastImageStyles = css`
176+
position: absolute;
177+
/**
178+
* Displays 8px above the text.
179+
* desired space above text (8px) - padding-top of text container (64px) = -56px
180+
*/
181+
bottom: -${space[14]}px;
182+
left: ${space[2]}px;
183+
184+
${from.tablet} {
185+
display: none;
186+
}
187+
`;
188+
174189
const starRatingWrapper = css`
175190
background-color: ${palette('--star-rating-background')};
176191
color: ${palette('--star-rating-fill')};
@@ -353,7 +368,7 @@ export const FeatureCard = ({
353368
isExternalLink={isExternalLink}
354369
/>
355370
)}
356-
<div css={[contentStyles]}>
371+
<div css={contentStyles}>
357372
{showYoutubeVideo && (
358373
<div
359374
data-chromatic="ignore"
@@ -488,45 +503,45 @@ export const FeatureCard = ({
488503
immersiveOverlayContainerStyles,
489504
]}
490505
>
506+
{mainMedia?.type === 'Audio' &&
507+
!!mainMedia.podcastImage?.src && (
508+
<div
509+
css={
510+
podcastImageContainerStyles
511+
}
512+
>
513+
<div
514+
css={[
515+
podcastImageStyles,
516+
nonImmersivePodcastImageStyles,
517+
]}
518+
>
519+
<CardPicture
520+
mainImage={
521+
mainMedia
522+
.podcastImage
523+
.src
524+
}
525+
imageSize="podcast"
526+
alt={
527+
mainMedia
528+
.podcastImage
529+
.altText ?? ''
530+
}
531+
loading="lazy"
532+
roundedCorners={false}
533+
aspectRatio="1:1"
534+
/>
535+
</div>
536+
</div>
537+
)}
491538
<div
492539
css={[
493540
overlayStyles,
494541
isImmersive &&
495542
immersiveOverlayStyles,
496543
]}
497544
>
498-
{mainMedia?.type === 'Audio' &&
499-
!!mainMedia.podcastImage?.src && (
500-
<div
501-
css={
502-
podcastImageContainerStyles
503-
}
504-
>
505-
<div
506-
css={podcastImageStyles}
507-
>
508-
<CardPicture
509-
mainImage={
510-
mainMedia
511-
.podcastImage
512-
.src
513-
}
514-
imageSize="podcast"
515-
alt={
516-
mainMedia
517-
.podcastImage
518-
.altText ??
519-
''
520-
}
521-
loading="lazy"
522-
roundedCorners={
523-
false
524-
}
525-
aspectRatio="1:1"
526-
/>
527-
</div>
528-
</div>
529-
)}
530545
{/**
531546
* Without the wrapping div the headline and byline would have space
532547
* inserted between them due to being direct children of the flex container
@@ -585,17 +600,46 @@ export const FeatureCard = ({
585600
</div>
586601
)}
587602

588-
{mainMedia?.type === 'Audio' && (
589-
<div css={waveformStyles}>
590-
<WaveForm
591-
seed={mainMedia.duration}
592-
height={64}
593-
// Just enough to cover the full width of the feature card in it's largest form
594-
bars={233}
595-
barWidth={2}
596-
/>
597-
</div>
598-
)}
603+
{isImmersive &&
604+
mainMedia?.type === 'Audio' &&
605+
!!mainMedia.podcastImage?.src && (
606+
<div
607+
css={
608+
podcastImageContainerStyles
609+
}
610+
>
611+
<div
612+
css={[
613+
podcastImageStyles,
614+
css`
615+
${until.tablet} {
616+
display: none;
617+
}
618+
`,
619+
]}
620+
>
621+
<CardPicture
622+
mainImage={
623+
mainMedia
624+
.podcastImage
625+
.src
626+
}
627+
imageSize="podcast"
628+
alt={
629+
mainMedia
630+
.podcastImage
631+
.altText ??
632+
''
633+
}
634+
loading="lazy"
635+
roundedCorners={
636+
false
637+
}
638+
aspectRatio="1:1"
639+
/>
640+
</div>
641+
</div>
642+
)}
599643

600644
<CardFooter
601645
format={format}
@@ -644,6 +688,24 @@ export const FeatureCard = ({
644688
mainMedia={mainMedia}
645689
isNewsletter={isNewsletter}
646690
/>
691+
692+
{!isImmersive &&
693+
mainMedia?.type === 'Audio' && (
694+
<div
695+
css={waveformStyles}
696+
className="waveform"
697+
>
698+
<WaveForm
699+
seed={
700+
mainMedia.duration
701+
}
702+
height={64}
703+
// Just enough to cover the full width of the feature card in it's largest form
704+
bars={233}
705+
barWidth={2}
706+
/>
707+
</div>
708+
)}
647709
</div>
648710
{/* On video article cards, the duration is displayed in the footer */}
649711
{!isVideoArticle &&
@@ -663,6 +725,21 @@ export const FeatureCard = ({
663725
</div>
664726
) : null}
665727
</div>
728+
729+
{isImmersive && mainMedia?.type === 'Audio' && (
730+
<div
731+
css={waveformStyles}
732+
className="waveform"
733+
>
734+
<WaveForm
735+
seed={mainMedia.duration}
736+
height={64}
737+
// Just enough to cover the full width of the feature card in it's largest form
738+
bars={314}
739+
barWidth={2}
740+
/>
741+
</div>
742+
)}
666743
</div>
667744
)}
668745
</div>

0 commit comments

Comments
 (0)