Skip to content

Commit f14e17f

Browse files
authored
Merge branch 'main' into md/labs-galleries-dcr
2 parents 0dc0e8c + cc66632 commit f14e17f

File tree

67 files changed

+1432
-578
lines changed

Some content is hidden

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

67 files changed

+1432
-578
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ updates:
1010
schedule:
1111
interval: 'daily'
1212
ignore:
13-
# The version of the aws-cdk[-lib] & constructs dependencies should match
14-
# exactly the version specified by @guardian/cdk
15-
- dependency-name: 'aws-cdk'
16-
- dependency-name: 'aws-cdk-lib'
17-
- dependency-name: 'constructs'
1813
# The `check-node-versions` script enforces that this package is kept in
1914
# sync with our Node major version, so we want dependabot to ignore major
2015
# version updates, but still allow smaller updates.
@@ -29,6 +24,12 @@ updates:
2924
babel:
3025
patterns:
3126
- '*babel*'
27+
cdk:
28+
patterns:
29+
- '@guardian/cdk'
30+
- 'aws-cdk'
31+
- 'aws-cdk-lib'
32+
- 'constructs'
3233
eslint:
3334
patterns:
3435
- '*eslint*'

dotcom-rendering/.storybook/mocks/bridgetApi.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ export const getListenToArticleClient: BridgetApi<
102102
isAvailable: async () => true,
103103
isPlaying: async () => false,
104104
});
105+
106+
export const getNativeABTestingClient: BridgetApi<
107+
'getNativeABTestingClient'
108+
> = () => ({
109+
getParticipations: async () =>
110+
new Map(Object.entries({ 'test-id': 'variant' })),
111+
});
112+
105113
export const ensure_all_exports_are_present = {
106114
getUserClient,
107115
getAcquisitionsClient,
@@ -119,6 +127,7 @@ export const ensure_all_exports_are_present = {
119127
getInteractionClient,
120128
getInteractivesClient,
121129
getListenToArticleClient,
130+
getNativeABTestingClient,
122131
} satisfies {
123132
[Method in keyof BridgeModule]: BridgetApi<Method>;
124133
};

dotcom-rendering/fixtures/manual/trails.ts

Lines changed: 17 additions & 0 deletions
Large diffs are not rendered by default.

dotcom-rendering/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"@emotion/server": "11.11.0",
2929
"@guardian/ab-core": "8.0.0",
3030
"@guardian/braze-components": "22.2.0",
31-
"@guardian/bridget": "8.6.0",
31+
"@guardian/bridget": "8.7.0",
3232
"@guardian/browserslist-config": "6.1.0",
3333
"@guardian/cdk": "61.4.0",
3434
"@guardian/commercial-core": "27.1.0",
@@ -46,8 +46,7 @@
4646
"@guardian/support-dotcom-components": "7.7.0",
4747
"@guardian/tsconfig": "0.2.0",
4848
"@playwright/test": "1.52.0",
49-
"@sentry/browser": "7.75.1",
50-
"@sentry/integrations": "7.75.1",
49+
"@sentry/browser": "10.3.0",
5150
"@storybook/addon-essentials": "8.6.14",
5251
"@storybook/addon-interactions": "8.6.14",
5352
"@storybook/addon-webpack5-compiler-swc": "3.0.0",

dotcom-rendering/playwright/tests/affiliate-links.e2e.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test.describe('Affiliate links', () => {
2121
await expect(disclaimerLocator).toContainText('affiliate link');
2222
});
2323

24-
test('skimlinks should have the attribute rel="sponsored"', async ({
24+
test('skimlinks should have the attribute rel="sponsored noreferrer noopener"', async ({
2525
page,
2626
}) => {
2727
await loadPage({
@@ -34,7 +34,7 @@ test.describe('Affiliate links', () => {
3434
const skimlinkLocator = page.locator(skimlinkSelector).first();
3535
const skimlinkRelAttribute =
3636
await skimlinkLocator.getAttribute('rel');
37-
expect(skimlinkRelAttribute).toBe('sponsored');
37+
expect(skimlinkRelAttribute).toBe('sponsored noreferrer noopener');
3838
});
3939

4040
test('skimlinks should contain the xcust URL parameter', async ({

dotcom-rendering/src/client/sentryLoader/sentry.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as Sentry from '@sentry/browser';
22
import type { BrowserOptions } from '@sentry/browser';
3-
import { CaptureConsole } from '@sentry/integrations';
43
import { BUILD_VARIANT, dcrJavascriptBundle } from '../../../webpack/bundles';
54
import type { ReportError } from '../../types/sentry';
65

@@ -44,7 +43,7 @@ Sentry.init({
4443
allowUrls,
4544
dsn: dcrSentryDsn,
4645
environment: stage || 'DEV',
47-
integrations: [new CaptureConsole({ levels: ['error'] })],
46+
integrations: [Sentry.captureConsoleIntegration({ levels: ['error'] })],
4847
maxBreadcrumbs: 50,
4948
// sampleRate: // We use Math.random in init.ts to sample errors
5049
});

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const CalloutBlockComponent = ({
5151
const id = formId.toString();
5252

5353
return (
54-
<>
54+
<div data-gu-name="callout">
5555
{!isNonCollapsible ? (
5656
<aside>
5757
<ExpandingWrapper
@@ -116,6 +116,6 @@ export const CalloutBlockComponent = ({
116116
pageId={pageId}
117117
/>
118118
)}
119-
</>
119+
</div>
120120
);
121121
};

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const basicCardProps: CardProps = {
4848
discussionApiUrl: 'https://discussion.theguardian.com/discussion-api/',
4949
showVideo: true,
5050
absoluteServerTimes: true,
51+
headlinePosition: 'inner',
5152
};
5253

5354
const aBasicLink = {

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

Lines changed: 31 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
} from '../../lib/articleFormat';
1414
import { isMediaCard } from '../../lib/cardHelpers';
1515
import { isWithinTwelveHours, secondsToDuration } from '../../lib/formatTime';
16+
import { appendLinkNameMedia } from '../../lib/getDataLinkName';
1617
import { getZIndex } from '../../lib/getZIndex';
1718
import { DISCUSSION_ID_DATA_ATTRIBUTE } from '../../lib/useCommentCount';
1819
import { BETA_CONTAINERS } from '../../model/enhanceCollections';
@@ -128,7 +129,6 @@ export type Props = {
128129
liveUpdatesAlignment?: Alignment;
129130
liveUpdatesPosition?: Position;
130131
onwardsSource?: OnwardsSource;
131-
pauseOffscreenVideo?: boolean;
132132
showVideo?: boolean;
133133
isTagPage?: boolean;
134134
/** Allows the consumer to set an aspect ratio on the image of 5:3, 5:4, 4:5 or 1:1 */
@@ -147,6 +147,10 @@ export type Props = {
147147
trailTextSize?: TrailTextSize;
148148
/** A kicker image is seperate to the main media and renders as part of the kicker */
149149
showKickerImage?: boolean;
150+
/** Determines if the headline should be positioned within the content or outside the content */
151+
headlinePosition?: 'inner' | 'outer';
152+
isInLoopingVideoTestVariant?: boolean;
153+
isInLoopingVideoTestControl?: boolean;
150154
};
151155

152156
const starWrapper = (cardHasImage: boolean) => css`
@@ -250,6 +254,7 @@ const getMedia = ({
250254
mainMedia,
251255
canPlayInline,
252256
isBetaContainer,
257+
isInLoopingVideoTestControl,
253258
}: {
254259
imageUrl?: string;
255260
imageAltText?: string;
@@ -259,16 +264,21 @@ const getMedia = ({
259264
mainMedia?: MainMedia;
260265
canPlayInline?: boolean;
261266
isBetaContainer: boolean;
267+
isInLoopingVideoTestControl: boolean;
262268
}) => {
263-
if (mainMedia?.type === 'LoopVideo' && canPlayInline) {
269+
if (
270+
mainMedia?.type === 'LoopVideo' &&
271+
!isInLoopingVideoTestControl &&
272+
canPlayInline
273+
) {
264274
return {
265275
type: 'loop-video',
266276
mainMedia,
267277
} as const;
268278
}
269279
if (mainMedia?.type === 'Video' && canPlayInline) {
270280
return {
271-
type: 'video',
281+
type: 'youtube-video',
272282
mainMedia,
273283
} as const;
274284
}
@@ -318,36 +328,6 @@ const decideSublinkPosition = (
318328
return alignment === 'vertical' ? 'inner' : 'outer';
319329
};
320330

321-
const getHeadlinePosition = ({
322-
isFlexSplash,
323-
containerType,
324-
showLivePlayable,
325-
isMediaCardOrNewsletter,
326-
}: {
327-
containerType?: DCRContainerType;
328-
isFlexSplash?: boolean;
329-
showLivePlayable: boolean;
330-
isMediaCardOrNewsletter: boolean;
331-
}) => {
332-
if (isMediaCardOrNewsletter) {
333-
return 'inner';
334-
}
335-
336-
if (containerType === 'flexible/special' && isFlexSplash) {
337-
return 'outer';
338-
}
339-
340-
if (
341-
containerType === 'flexible/general' &&
342-
isFlexSplash &&
343-
showLivePlayable
344-
) {
345-
return 'outer';
346-
}
347-
348-
return 'inner';
349-
};
350-
351331
const liveBulletStyles = css`
352332
width: 9px;
353333
height: 9px;
@@ -400,7 +380,6 @@ export const Card = ({
400380
liveUpdatesAlignment = 'vertical',
401381
liveUpdatesPosition = 'inner',
402382
onwardsSource,
403-
pauseOffscreenVideo = false,
404383
showVideo = true,
405384
absoluteServerTimes,
406385
isTagPage = false,
@@ -412,6 +391,9 @@ export const Card = ({
412391
showTopBarMobile = true,
413392
trailTextSize,
414393
showKickerImage = false,
394+
headlinePosition = 'inner',
395+
isInLoopingVideoTestVariant = false,
396+
isInLoopingVideoTestControl = false,
415397
}: Props) => {
416398
const hasSublinks = supportingContent && supportingContent.length > 0;
417399
const sublinkPosition = decideSublinkPosition(
@@ -564,8 +546,14 @@ export const Card = ({
564546
mainMedia,
565547
canPlayInline,
566548
isBetaContainer,
549+
isInLoopingVideoTestControl,
567550
});
568551

552+
const resolvedDataLinkName =
553+
media && dataLinkName
554+
? appendLinkNameMedia(dataLinkName, media.type)
555+
: dataLinkName;
556+
569557
/**
570558
* For opinion type cards with avatars (which aren't onwards content)
571559
* we render the footer in a different location
@@ -605,13 +593,6 @@ export const Card = ({
605593
return { mobile: 'medium' };
606594
};
607595

608-
const headlinePosition = getHeadlinePosition({
609-
containerType,
610-
isFlexSplash,
611-
showLivePlayable,
612-
isMediaCardOrNewsletter,
613-
});
614-
615596
const hideTrailTextUntil = () => {
616597
if (isFlexibleContainer) {
617598
return undefined;
@@ -757,7 +738,7 @@ export const Card = ({
757738
<CardLink
758739
linkTo={linkTo}
759740
headlineText={headlineText}
760-
dataLinkName={dataLinkName}
741+
dataLinkName={resolvedDataLinkName}
761742
isExternalLink={isExternalLink}
762743
/>
763744
{headlinePosition === 'outer' && (
@@ -895,10 +876,14 @@ export const Card = ({
895876
fallbackImageLoading={imageLoading}
896877
fallbackImageAlt={media.imageAltText}
897878
fallbackImageAspectRatio="5:4"
879+
linkTo={linkTo}
880+
isInLoopingVideoTestVariant={
881+
isInLoopingVideoTestVariant
882+
}
898883
/>
899884
</Island>
900885
)}
901-
{media.type === 'video' && (
886+
{media.type === 'youtube-video' && (
902887
<>
903888
{showVideo ? (
904889
<div
@@ -943,9 +928,6 @@ export const Card = ({
943928
hideCaption={true}
944929
stickyVideos={false}
945930
kickerText={kickerText}
946-
pauseOffscreenVideo={
947-
pauseOffscreenVideo
948-
}
949931
/*
950932
* TODO: IMPROVE THIS MAPPING
951933
*
@@ -1011,6 +993,9 @@ export const Card = ({
1011993
loading={imageLoading}
1012994
roundedCorners={isOnwardContent}
1013995
aspectRatio={aspectRatio}
996+
isInLoopingVideoTestControl={
997+
isInLoopingVideoTestControl
998+
}
1014999
/>
10151000
{isVideoMainMedia && mainMedia.duration > 0 && (
10161001
<div

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { css } from '@emotion/react';
22
import { isUndefined } from '@guardian/libs';
33
import { from, space } from '@guardian/source/foundations';
4-
import type { CardImageType } from '../../../types/layout';
4+
import type { CardMediaType } from '../../../types/layout';
55
import type { ImagePositionType } from './ImageWrapper';
66

77
export type GapSize = 'none' | 'tiny' | 'small' | 'medium' | 'large';
@@ -11,7 +11,7 @@ export type GapSizes = { row: GapSize; column: GapSize };
1111
type Props = {
1212
children: React.ReactNode;
1313
cardBackgroundColour: string;
14-
imageType: CardImageType | undefined;
14+
imageType: CardMediaType | undefined;
1515
imagePositionOnDesktop: ImagePositionType;
1616
imagePositionOnMobile: ImagePositionType;
1717
minWidthInPixels?: number;

0 commit comments

Comments
 (0)