Skip to content

Commit 49428e6

Browse files
committed
Merge main into add-gallery-body-component
2 parents aff885e + d7815ac commit 49428e6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+992
-185
lines changed

dotcom-rendering/cdk/lib/__snapshots__/renderingStack.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ exports[`The RenderingCDKStack matches the snapshot 1`] = `
10611061
},
10621062
{
10631063
"Key": "access_logs.s3.prefix",
1064-
"Value": "ELBLogs/frontend/article-rendering/PROD",
1064+
"Value": "application-load-balancer/PROD/frontend/article-rendering",
10651065
},
10661066
{
10671067
"Key": "idle_timeout.timeout_seconds",

dotcom-rendering/cdk/lib/renderingStack.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ export class RenderingCDKStack extends CDKStack {
210210
},
211211
accessLogging: {
212212
enabled: true,
213-
prefix: `ELBLogs/${guStack}/${guApp}/${stage}`,
213+
// This is the prefix pattern DevX assume so that the logs can be shown on the Availability dashboard.
214+
prefix: `application-load-balancer/${stage}/${guStack}/${guApp}`,
214215
},
215216
applicationLogging: {
216217
enabled: true,

dotcom-rendering/src/components/ArticleHeadline.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,11 @@ const zIndex = css`
247247
z-index: 1;
248248
`;
249249

250-
const ageWarningMargins = (format: ArticleFormat) =>
251-
format.display === ArticleDisplay.Immersive
250+
const ageWarningMargins = (format: ArticleFormat) => {
251+
if (format.design === ArticleDesign.Gallery) {
252+
return '';
253+
}
254+
return format.display === ArticleDisplay.Immersive
252255
? css`
253256
margin-left: 0px;
254257
margin-bottom: 0px;
@@ -275,6 +278,7 @@ const ageWarningMargins = (format: ArticleFormat) =>
275278
margin-top: 0;
276279
}
277280
`;
281+
};
278282

279283
const backgroundStyles = css`
280284
background-color: ${themePalette('--age-warning-wrapper-background')};

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/FetchOnwardsData.importable.tsx

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type Props = {
1919
discussionApiUrl: string;
2020
absoluteServerTimes: boolean;
2121
renderingTarget: RenderingTarget;
22+
isAdFreeUser: boolean;
2223
};
2324

2425
type OnwardsResponse = {
@@ -32,6 +33,20 @@ const minHeight = css`
3233
min-height: 300px;
3334
`;
3435

36+
const isTrailPaidContent = (trailType: FETrailType) =>
37+
trailType.branding?.brandingType?.name === 'paid-content';
38+
39+
const buildTrails = (
40+
trails: FETrailType[],
41+
trailLimit: number,
42+
isAdFreeUser: boolean,
43+
): TrailType[] => {
44+
return trails
45+
.filter((trailType) => !(isTrailPaidContent(trailType) && isAdFreeUser))
46+
.slice(0, trailLimit)
47+
.map(decideTrail);
48+
};
49+
3550
export const FetchOnwardsData = ({
3651
url,
3752
limit,
@@ -40,16 +55,10 @@ export const FetchOnwardsData = ({
4055
discussionApiUrl,
4156
absoluteServerTimes,
4257
renderingTarget,
58+
isAdFreeUser,
4359
}: Props) => {
4460
const { data, error } = useApi<OnwardsResponse>(url);
4561

46-
const buildTrails = (
47-
trails: FETrailType[],
48-
trailLimit: number,
49-
): TrailType[] => {
50-
return trails.slice(0, trailLimit).map(decideTrail);
51-
};
52-
5362
if (error) {
5463
// Send the error to Sentry and then prevent the element from rendering
5564
window.guardian.modules.sentry.reportError(error, 'onwards-lower');
@@ -76,7 +85,7 @@ export const FetchOnwardsData = ({
7685
<div css={minHeight}>
7786
<Carousel
7887
heading={data.heading || data.displayname} // Sometimes the api returns heading as 'displayName'
79-
trails={buildTrails(data.trails, limit)}
88+
trails={buildTrails(data.trails, limit, isAdFreeUser)}
8089
description={data.description}
8190
onwardsSource={onwardsSource}
8291
format={format}

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/FlexibleSpecial.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ const meta = {
101101
absoluteServerTimes: true,
102102
imageLoading: 'eager',
103103
aspectRatio: '5:4',
104-
frontSectionTitle: 'Flexible general',
104+
frontSectionTitle: 'Flexible special',
105105
},
106106
render: ({ frontSectionTitle, ...args }) => (
107107
<FrontSection

dotcom-rendering/src/components/FlexibleSpecial.tsx

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ import type {
99
DCRFrontCard,
1010
DCRGroupedTrails,
1111
} from '../types/front';
12-
import type {
13-
ImagePositionType,
14-
ImageSizeType,
15-
} from './Card/components/ImageWrapper';
12+
import type { ImagePositionType } from './Card/components/ImageWrapper';
1613
import { LI } from './Card/components/LI';
1714
import type { TrailTextSize } from './Card/components/TrailText';
1815
import { UL } from './Card/components/UL';
@@ -36,7 +33,6 @@ type BoostProperties = {
3633
headlineSizes: ResponsiveFontSize;
3734
imagePositionOnDesktop: ImagePositionType;
3835
imagePositionOnMobile: ImagePositionType;
39-
imageSize: ImageSizeType;
4036
supportingContentAlignment: Alignment;
4137
liveUpdatesAlignment: Alignment;
4238
trailTextSize: TrailTextSize;
@@ -51,23 +47,18 @@ const determineCardProperties = (
5147
supportingContentLength: number,
5248
mediaCard: boolean,
5349
imageSuppressed: boolean,
54-
hasLivePlayable: boolean,
5550
): BoostProperties => {
5651
switch (boostLevel) {
5752
// The default boost level is equal to no boost. It is the same as the default card layout.
5853
case 'default':
5954
return {
6055
headlineSizes: {
61-
desktop:
62-
imageSuppressed || hasLivePlayable
63-
? 'xxlarge'
64-
: 'xlarge',
56+
desktop: imageSuppressed ? 'xxlarge' : 'xlarge',
6557
tablet: 'large',
6658
mobile: 'medium',
6759
},
6860
imagePositionOnDesktop: 'right',
6961
imagePositionOnMobile: mediaCard ? 'top' : 'bottom',
70-
imageSize: 'large',
7162
supportingContentAlignment:
7263
supportingContentLength >= 3 ? 'horizontal' : 'vertical',
7364
liveUpdatesAlignment: 'vertical',
@@ -76,16 +67,12 @@ const determineCardProperties = (
7667
case 'boost':
7768
return {
7869
headlineSizes: {
79-
desktop:
80-
imageSuppressed || hasLivePlayable
81-
? 'xxxlarge'
82-
: 'xxlarge',
70+
desktop: imageSuppressed ? 'xxxlarge' : 'xxlarge',
8371
tablet: 'xlarge',
8472
mobile: 'large',
8573
},
8674
imagePositionOnDesktop: 'right',
8775
imagePositionOnMobile: mediaCard ? 'top' : 'bottom',
88-
imageSize: 'jumbo',
8976
supportingContentAlignment:
9077
supportingContentLength >= 3 ? 'horizontal' : 'vertical',
9178
liveUpdatesAlignment: 'vertical',
@@ -94,16 +81,12 @@ const determineCardProperties = (
9481
case 'megaboost':
9582
return {
9683
headlineSizes: {
97-
desktop:
98-
imageSuppressed || hasLivePlayable
99-
? 'xxxlarge'
100-
: 'xxlarge',
84+
desktop: imageSuppressed ? 'xxxlarge' : 'xxlarge',
10185
tablet: 'xlarge',
10286
mobile: 'xlarge',
10387
},
10488
imagePositionOnDesktop: mediaCard ? 'top' : 'bottom',
10589
imagePositionOnMobile: mediaCard ? 'top' : 'bottom',
106-
imageSize: 'jumbo',
10790
supportingContentAlignment: 'horizontal',
10891
liveUpdatesAlignment: 'horizontal',
10992
trailTextSize: 'large',
@@ -117,7 +100,6 @@ const determineCardProperties = (
117100
},
118101
imagePositionOnDesktop: mediaCard ? 'top' : 'bottom',
119102
imagePositionOnMobile: mediaCard ? 'top' : 'bottom',
120-
imageSize: 'jumbo',
121103
supportingContentAlignment: 'horizontal',
122104
liveUpdatesAlignment: 'horizontal',
123105
trailTextSize: 'large',
@@ -155,7 +137,6 @@ export const OneCardLayout = ({
155137
headlineSizes,
156138
imagePositionOnDesktop,
157139
imagePositionOnMobile,
158-
imageSize,
159140
supportingContentAlignment,
160141
liveUpdatesAlignment,
161142
trailTextSize,
@@ -164,7 +145,6 @@ export const OneCardLayout = ({
164145
card.supportingContent?.length ?? 0,
165146
isMediaCard(card.format),
166147
!card.image,
167-
card.showLivePlayable,
168148
);
169149

170150
return (
@@ -179,7 +159,7 @@ export const OneCardLayout = ({
179159
headlineSizes={headlineSizes}
180160
imagePositionOnDesktop={imagePositionOnDesktop}
181161
imagePositionOnMobile={imagePositionOnMobile}
182-
imageSize={imageSize}
162+
imageSize={'jumbo'}
183163
trailText={card.trailText}
184164
supportingContent={card.supportingContent}
185165
supportingContentAlignment={supportingContentAlignment}

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ export const InteractiveBlockComponent = ({
325325
const wrapperRef = useRef<HTMLDivElement>(null);
326326
const placeholderLinkRef = useRef<HTMLAnchorElement>(null);
327327
const [loaded, setLoaded] = useState(false);
328-
const { darkModeAvailable } = useConfig();
328+
const { darkModeAvailable, renderingTarget } = useConfig();
329329

330330
// Define some one-time flags
331331
const isDatawrapperGraphic =
@@ -352,13 +352,6 @@ export const InteractiveBlockComponent = ({
352352
useOnce(() => {
353353
// We've brought the behavior from boot.js into this file to avoid loading 2 extra scripts
354354

355-
// Define additional one-time flags - these depend on window/document objects
356-
const isRunningInWebEnvironment =
357-
!document.querySelector('.ios') &&
358-
!document.querySelector('.android')
359-
? true
360-
: false;
361-
362355
const prefersDarkScheme = window.matchMedia(
363356
'(prefers-color-scheme: dark)',
364357
).matches;
@@ -382,7 +375,7 @@ export const InteractiveBlockComponent = ({
382375
}
383376

384377
// Fix darkmode for web environment
385-
if (isRunningInWebEnvironment && !requiresDarkMode) {
378+
if (renderingTarget === 'Web' && !requiresDarkMode) {
386379
if (isDatawrapperGraphic || isUploaderEmbedPath) {
387380
// Add the 'dark=false' search param
388381
if (graphicUrl.search.length) {

dotcom-rendering/src/components/Lazy.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const Lazy = ({ children, margin, disableFlexStyles }: Props) => {
3030
// being loaded as part of a Chromatic story or not so that
3131
// we can prevent lazy loading our storybook snapshots that we
3232
// use for visual regression
33-
const renderChildren = hasBeenSeen || Lazy.disabled;
33+
const renderChildren = !!hasBeenSeen || Lazy.disabled;
3434
return (
3535
<div ref={setRef} css={!disableFlexStyles && flexGrowStyles}>
3636
{renderChildren && <>{children}</>}

0 commit comments

Comments
 (0)