Skip to content

Commit be0e5c3

Browse files
committed
roll out prefer variant of preferred source btn
1 parent fc48647 commit be0e5c3

5 files changed

Lines changed: 55 additions & 124 deletions

File tree

dotcom-rendering/src/components/ArticleMeta.web.tsx

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { css } from '@emotion/react';
22
import { between, from, space, until } from '@guardian/source/foundations';
33
import { StraightLines } from '@guardian/source-development-kitchen/react-components';
44
import type { CSSProperties } from 'react';
5-
import { preferredSourceExperiment } from '../experiments/preferredSource';
65
import type { FEArticle } from '../frontend/feArticle';
76
import { interactiveLegacyClasses } from '../layouts/lib/interactiveLegacyStyling';
87
import {
@@ -13,8 +12,8 @@ import {
1312
} from '../lib/articleFormat';
1413
import { getAudioData } from '../lib/audio-data';
1514
import { getSoleContributor } from '../lib/byline';
16-
import { useBetaAB } from '../lib/useAB';
1715
import { palette as themePalette } from '../palette';
16+
import { hasPreferredSourceButton } from '../preferredSource';
1817
import type { Branding as BrandingType } from '../types/branding';
1918
import type { FEElement } from '../types/content';
2019
import type { Podcast, TagType } from '../types/tag';
@@ -343,13 +342,8 @@ export const ArticleMeta = ({
343342
mainMediaElements,
344343
crossword,
345344
}: Props) => {
346-
const abTests = useBetaAB();
347345
const { renderingTarget } = useConfig();
348-
const preferredSource = preferredSourceExperiment(
349-
renderingTarget,
350-
format,
351-
abTests,
352-
);
346+
const preferredSource = hasPreferredSourceButton(renderingTarget, format);
353347
const soleContributor = getSoleContributor(tags, byline);
354348
const authorName = soleContributor?.title ?? 'Author Image';
355349

@@ -446,7 +440,7 @@ export const ArticleMeta = ({
446440
<div
447441
data-print-layout="hide"
448442
css={metaFlex}
449-
style={preferredSourceMetaFlex(preferredSource.hasButton)}
443+
style={preferredSourceMetaFlex(preferredSource)}
450444
>
451445
{renderingTarget === 'Web' && (
452446
<div
@@ -463,9 +457,7 @@ export const ArticleMeta = ({
463457
metaExtrasLiveBlog,
464458
),
465459
]}
466-
style={preferredSourceMetaExtras(
467-
preferredSource.hasButton,
468-
)}
460+
style={preferredSourceMetaExtras(preferredSource)}
469461
>
470462
<Island
471463
priority="feature"
@@ -518,9 +510,7 @@ export const ArticleMeta = ({
518510
</div>
519511
</div>
520512
</div>
521-
{preferredSource.hasButton ? (
522-
<PreferredSourceButton kind={preferredSource.kind} />
523-
) : null}
513+
{preferredSource ? <PreferredSourceButton /> : null}
524514
</div>
525515
</div>
526516
);

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

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ export default meta;
1212

1313
type Story = StoryObj<typeof meta>;
1414

15-
export const VariantA = {
16-
args: {
17-
kind: 'prefer',
18-
},
15+
export const Default = {
1916
parameters: {
2017
chromatic: {
2118
modes: {
@@ -24,16 +21,3 @@ export const VariantA = {
2421
},
2522
},
2623
} satisfies Story;
27-
28-
export const VariantB = {
29-
args: {
30-
kind: 'add',
31-
},
32-
parameters: {
33-
chromatic: {
34-
modes: {
35-
'vertical leftCol': allModes['vertical leftCol'],
36-
},
37-
},
38-
},
39-
} satisfies Story;

dotcom-rendering/src/components/PreferredSourceButton.tsx

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,16 @@ import {
66
textSans14Object,
77
} from '@guardian/source/foundations';
88
import { LinkButton, SvgGoogleBrand } from '@guardian/source/react-components';
9-
import type { ButtonKind } from '../experiments/preferredSource';
109
import { palette } from '../palette';
1110

12-
type Props = {
13-
kind: ButtonKind;
14-
};
15-
16-
export const PreferredSourceButton = ({ kind }: Props) => (
11+
export const PreferredSourceButton = () => (
1712
<LinkButton
1813
priority="tertiary"
1914
icon={<SvgGoogleBrand />}
2015
size="small"
2116
href="https://www.google.com/preferences/source?q=theguardian.com"
22-
data-component={`preferred-source-button-${kind}`}
23-
data-link-name={`preferred-source-button-${kind}`}
17+
data-component={`preferred-source-button-prefer`}
18+
data-link-name={`preferred-source-button-prefer`}
2419
cssOverrides={css({
2520
...textSans14Object,
2621
padding: '8px 12px 10px',
@@ -52,15 +47,6 @@ export const PreferredSourceButton = ({ kind }: Props) => (
5247
backgroundTertiaryHover: palette('--preferred-source-button-hover'),
5348
}}
5449
>
55-
{copy(kind)}
50+
{'Prefer the Guardian on Google'}
5651
</LinkButton>
5752
);
58-
59-
const copy = (kind: Props['kind']): string => {
60-
switch (kind) {
61-
case 'prefer':
62-
return 'Prefer the Guardian on Google';
63-
case 'add':
64-
return 'Add the Guardian on Google';
65-
}
66-
};

dotcom-rendering/src/experiments/preferredSource.ts

Lines changed: 0 additions & 74 deletions
This file was deleted.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import {
2+
ArticleDesign,
3+
type ArticleFormat,
4+
ArticleSpecial,
5+
} from './lib/articleFormat';
6+
import type { RenderingTarget } from './types/renderingTarget';
7+
8+
export const hasPreferredSourceButton = (
9+
renderingTarget: RenderingTarget,
10+
format: ArticleFormat,
11+
): boolean => {
12+
if (renderingTarget !== 'Web') {
13+
return false;
14+
}
15+
16+
switch (format.design) {
17+
case ArticleDesign.Analysis:
18+
case ArticleDesign.Audio:
19+
case ArticleDesign.Comment:
20+
case ArticleDesign.DeadBlog:
21+
case ArticleDesign.Editorial:
22+
case ArticleDesign.FullPageInteractive:
23+
case ArticleDesign.Gallery:
24+
case ArticleDesign.Interactive:
25+
case ArticleDesign.Letter:
26+
case ArticleDesign.LiveBlog:
27+
case ArticleDesign.NewsletterSignup:
28+
case ArticleDesign.Picture:
29+
case ArticleDesign.Video:
30+
return false;
31+
default:
32+
break;
33+
}
34+
35+
switch (format.theme) {
36+
case ArticleSpecial.Labs:
37+
case ArticleSpecial.SpecialReport:
38+
case ArticleSpecial.SpecialReportAlt:
39+
return false;
40+
default:
41+
break;
42+
}
43+
44+
return true;
45+
};

0 commit comments

Comments
 (0)