Skip to content

Commit b5448a5

Browse files
author
Juarez Mota
committed
Merge branch 'jm/feat-2-step-dismissible-banner-v2' of github.com:guardian/dotcom-rendering into jm/feat-2-step-dismissible-banner-v2
2 parents 34e0e9d + 3f38c5c commit b5448a5

14 files changed

+92
-88
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export const CommentCount = ({ discussionApiUrl, shortUrlId }: Props) => {
9494
css={containerStyles}
9595
data-testid="comment-counts"
9696
value={`${long} comments on this article`}
97+
data-gu-name="comment-count"
9798
>
9899
<a
99100
href="#comments"

dotcom-rendering/src/components/Contributor.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export const Contributor = ({ byline, tags, format, source }: Props) => (
9393
aria-label="Contributor info"
9494
data-component="meta-byline"
9595
data-link-name="byline"
96+
data-gu-name="byline"
9697
>
9798
{format.design !== ArticleDesign.Interview && (
9899
<div

dotcom-rendering/src/components/Dateline.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ export const Dateline = ({
5353
};
5454
if (secondaryDateline && !secondaryDateline.includes(primaryDateline)) {
5555
return (
56-
<details css={datelineStyles} style={mobileColour}>
56+
<details
57+
css={datelineStyles}
58+
style={mobileColour}
59+
data-gu-name="dateline"
60+
>
5761
<summary css={primaryStyles}>
5862
<span css={hoverUnderline}>{primaryDateline}</span>
5963
</summary>
@@ -62,7 +66,7 @@ export const Dateline = ({
6266
);
6367
}
6468
return (
65-
<div css={datelineStyles} style={mobileColour}>
69+
<div css={datelineStyles} style={mobileColour} data-gu-name="dateline">
6670
{primaryDateline}
6771
</div>
6872
);

dotcom-rendering/src/components/DecideContainer.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type Props = {
4747
frontId?: string;
4848
collectionId: number;
4949
containerLevel?: DCRContainerLevel;
50+
isInOpinionNoAvatarVariant?: boolean;
5051
};
5152

5253
export const DecideContainer = ({
@@ -62,6 +63,7 @@ export const DecideContainer = ({
6263
frontId,
6364
collectionId,
6465
containerLevel,
66+
isInOpinionNoAvatarVariant,
6567
}: Props) => {
6668
switch (containerType) {
6769
case 'dynamic/fast':
@@ -257,6 +259,7 @@ export const DecideContainer = ({
257259
aspectRatio={aspectRatio}
258260
containerLevel={containerLevel}
259261
collectionId={collectionId}
262+
isInOpinionNoAvatarVariant={isInOpinionNoAvatarVariant}
260263
/>
261264
);
262265
case 'scrollable/small':
@@ -286,6 +289,7 @@ export const DecideContainer = ({
286289
absoluteServerTimes={absoluteServerTimes}
287290
aspectRatio={aspectRatio}
288291
sectionId={sectionId}
292+
isInOpinionNoAvatarVariant={isInOpinionNoAvatarVariant}
289293
/>
290294
</Island>
291295
);

dotcom-rendering/src/components/FlexibleGeneral.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type Props = {
3232
aspectRatio: AspectRatio;
3333
containerLevel?: DCRContainerLevel;
3434
collectionId: number;
35+
isInOpinionNoAvatarVariant?: boolean;
3536
};
3637

3738
type RowLayout = 'oneCardHalfWidth' | 'oneCardFullWidth' | 'twoCard';
@@ -581,6 +582,7 @@ export const FlexibleGeneral = ({
581582
aspectRatio,
582583
containerLevel = 'Primary',
583584
collectionId,
585+
isInOpinionNoAvatarVariant,
584586
}: Props) => {
585587
const splash = [...groupedTrails.splash].slice(0, 1).map((snap) => ({
586588
...snap,
@@ -592,6 +594,9 @@ export const FlexibleGeneral = ({
592594
.map((standard, i) => ({
593595
...standard,
594596
uniqueId: `collection-${collectionId}-standard-${i}`,
597+
avatarUrl: isInOpinionNoAvatarVariant
598+
? undefined
599+
: standard.avatarUrl,
595600
}));
596601

597602
const groupedCards = decideCardPositions(cards);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ export const FollowWrapper = ({ id, displayName }: Props) => {
172172
}
173173
}
174174
`}
175+
data-gu-name="follow"
175176
>
176177
{showFollowTagButton && (
177178
<FollowTagButton

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,18 @@ export const InteractiveAtomMessenger = ({ id }: Props) => {
6262
if (!iframe) return;
6363
if (!container) return;
6464

65+
let timeout: ReturnType<typeof requestAnimationFrame> | null = null;
66+
6567
const scrollListener = () => {
66-
const rect = container.getBoundingClientRect();
67-
if (rect.top > 0) return setScroll(0);
68-
if (rect.top < -rect.height) return setScroll(1);
69-
setScroll(-rect.top);
68+
if (timeout != null) {
69+
cancelAnimationFrame(timeout);
70+
}
71+
timeout = requestAnimationFrame(() => {
72+
const rect = container.getBoundingClientRect();
73+
if (rect.top > 0) return setScroll(0);
74+
if (rect.top < -rect.height) return setScroll(1);
75+
setScroll(-rect.top);
76+
});
7077
};
7178

7279
const messageListener = (event: MessageEvent<unknown>) => {
@@ -89,10 +96,11 @@ export const InteractiveAtomMessenger = ({ id }: Props) => {
8996
}
9097
};
9198

92-
window.addEventListener('scroll', scrollListener);
99+
window.addEventListener('scroll', scrollListener, { passive: true });
93100
window.addEventListener('message', messageListener);
94101

95102
return () => {
103+
if (timeout != null) cancelAnimationFrame(timeout);
96104
window.removeEventListener('scroll', scrollListener);
97105
window.removeEventListener('message', messageListener);
98106
};

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ export const LiveblogNotifications = ({ id, displayName }: Props) => {
9696
}
9797
}
9898
`}
99+
data-gu-name="liveblog-notifications"
99100
>
100101
<FollowNotificationsButton
101102
isFollowing={isFollowingNotifications ?? false}

dotcom-rendering/src/components/ManyNewslettersForm.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ export interface FormProps {
3737
const CARD_CONTAINER_WIDTH = 240;
3838
const CARD_CONTAINER_PADDING = 10;
3939

40-
const formFrameStyle = css`
40+
const formFrameStyle = (visibleRecaptcha: boolean) => css`
41+
background-color: ${visibleRecaptcha
42+
? palette.neutral[100]
43+
: 'transparent'};
4144
border: ${palette.brand[400]} 2px dashed;
4245
border-radius: 12px;
4346
padding: ${space[2]}px;
@@ -53,17 +56,17 @@ const formFrameStyle = css`
5356
}
5457
`;
5558

56-
const formFieldsStyle = css`
59+
const formFieldsStyle = (visibleRecaptcha: boolean) => css`
5760
display: flex;
5861
flex-direction: column;
5962
align-items: stretch;
6063
padding-bottom: ${space[1]}px;
6164
6265
${from.desktop} {
6366
flex-basis: ${2 * CARD_CONTAINER_WIDTH - CARD_CONTAINER_PADDING * 2}px;
64-
flex-direction: row;
67+
flex-direction: ${visibleRecaptcha ? 'column' : 'row'};
6568
flex-shrink: 0;
66-
align-items: last baseline;
69+
align-items: ${visibleRecaptcha ? 'stretch' : 'last baseline'};
6770
}
6871
`;
6972

@@ -85,13 +88,14 @@ const formAsideStyle = (hideOnMobile: boolean) => css`
8588
}
8689
`;
8790

88-
const signUpButtonStyle = css`
91+
const signUpButtonStyle = (visibleRecaptcha: boolean) => css`
8992
justify-content: center;
9093
background-color: ${palette.neutral[0]};
9194
border-color: ${palette.neutral[0]};
9295
9396
${from.desktop} {
94-
flex-basis: 110px;
97+
margin-right: ${visibleRecaptcha ? space[2] : 0}px;
98+
flex-basis: ${visibleRecaptcha ? 'unset' : '110px'};
9599
}
96100
97101
&:hover {
@@ -139,7 +143,7 @@ export const ManyNewslettersForm = ({
139143
<form
140144
aria-label="sign-up confirmation form"
141145
aria-live="polite"
142-
css={formFrameStyle}
146+
css={formFrameStyle(visibleRecaptcha)}
143147
onSubmit={(submitEvent) => {
144148
submitEvent.preventDefault();
145149
}}
@@ -159,7 +163,7 @@ export const ManyNewslettersForm = ({
159163
</InlineSkipToWrapper>
160164
</aside>
161165

162-
<div css={formFieldsStyle}>
166+
<div css={formFieldsStyle(visibleRecaptcha)}>
163167
{status !== 'Success' ? (
164168
<>
165169
<ManyNewslettersFormFields
@@ -181,7 +185,7 @@ export const ManyNewslettersForm = ({
181185
onClick={() => {
182186
void handleSubmitButton();
183187
}}
184-
cssOverrides={signUpButtonStyle}
188+
cssOverrides={signUpButtonStyle(visibleRecaptcha)}
185189
>
186190
Sign up
187191
</Button>

dotcom-rendering/src/components/ManyNewslettersFormFields.tsx

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ const inputWrapperStyle = css`
1919
}
2020
`;
2121

22-
const inputAndOptInWrapperStyle = css`
22+
const inputAndOptInWrapperStyle = (visibleRecaptcha: boolean) => css`
2323
${from.desktop} {
24-
flex-basis: 296px;
24+
flex-basis: ${visibleRecaptcha ? 'unset' : '296px'};
2525
margin-right: ${space[2]}px;
2626
}
2727
`;
@@ -33,6 +33,18 @@ const optInCheckboxTextSmall = css`
3333
}
3434
`;
3535

36+
const recaptchaContainerStyle = (showRecaptchaContainer: boolean) => css`
37+
margin-bottom: ${showRecaptchaContainer ? space[3] : 0}px;
38+
padding: ${showRecaptchaContainer ? space[2] : 0}px;
39+
background-color: ${showRecaptchaContainer
40+
? palette.neutral[93]
41+
: 'transparent'};
42+
43+
.grecaptcha-badge {
44+
visibility: hidden;
45+
}
46+
`;
47+
3648
export interface ManyNewslettersFormFieldsProps
3749
extends Omit<FormProps, 'handleSubmitButton' | 'newsletterCount'> {}
3850

@@ -44,7 +56,7 @@ export const ManyNewslettersFormFields: FC<ManyNewslettersFormFieldsProps> = ({
4456
setMarketingOptIn,
4557
useReCaptcha,
4658
captchaSiteKey,
47-
visibleRecaptcha,
59+
visibleRecaptcha = false,
4860
reCaptchaRef,
4961
handleCaptchaError,
5062
}) => {
@@ -61,7 +73,7 @@ export const ManyNewslettersFormFields: FC<ManyNewslettersFormFieldsProps> = ({
6173
: undefined;
6274

6375
return (
64-
<div css={inputAndOptInWrapperStyle}>
76+
<div css={inputAndOptInWrapperStyle(visibleRecaptcha)}>
6577
<span css={inputWrapperStyle}>
6678
<TextInput
6779
label="Enter your email"
@@ -96,11 +108,9 @@ export const ManyNewslettersFormFields: FC<ManyNewslettersFormFieldsProps> = ({
96108
)}
97109
{useReCaptcha && !!captchaSiteKey && (
98110
<div
99-
css={css`
100-
.grecaptcha-badge {
101-
visibility: hidden;
102-
}
103-
`}
111+
css={recaptchaContainerStyle(
112+
visibleRecaptcha && firstInteractionOccurred,
113+
)}
104114
>
105115
{(!visibleRecaptcha || firstInteractionOccurred) && (
106116
<ReactGoogleRecaptcha
@@ -110,6 +120,13 @@ export const ManyNewslettersFormFields: FC<ManyNewslettersFormFieldsProps> = ({
110120
size={visibleRecaptcha ? 'normal' : 'invisible'}
111121
/>
112122
)}
123+
{visibleRecaptcha && firstInteractionOccurred && (
124+
<span css={[textSans14]}>
125+
By ticking this box, you agree to let Google perform
126+
a security check to confirm you are a human. Please
127+
refer to their terms and privacy policies.
128+
</span>
129+
)}
113130
</div>
114131
)}
115132
</div>

0 commit comments

Comments
 (0)