Skip to content

Commit fb89de0

Browse files
authored
Merge branch 'main' into ih/configure-ab-metrics
2 parents abbfb48 + c7cf083 commit fb89de0

File tree

9 files changed

+211
-197
lines changed

9 files changed

+211
-197
lines changed

dotcom-rendering/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"@guardian/eslint-config-typescript": "9.0.1",
3939
"@guardian/identity-auth": "6.0.1",
4040
"@guardian/identity-auth-frontend": "8.1.0",
41-
"@guardian/libs": "25.2.0",
41+
"@guardian/libs": "25.3.0",
4242
"@guardian/ophan-tracker-js": "2.3.2",
4343
"@guardian/react-crossword": "6.3.0",
4444
"@guardian/shimport": "1.0.2",

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/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>

dotcom-rendering/src/components/marketing/banners/designableBanner/DesignableBanner.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ const DesignableBanner: ReactComponent<BannerRenderProps> = ({
479479
}
480480
choices={choiceCards}
481481
id={'banner'}
482+
submitComponentEvent={submitComponentEvent}
482483
/>
483484
)}
484485
<div css={styles.ctaContainer(isCollapsed)}>

dotcom-rendering/src/components/marketing/epics/ctas/ContributionsEpicCtasContainer.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export const ContributionsEpicCtasContainer: ReactComponent<Props> = ({
5555
setSelectedChoiceCard={setSelectedChoiceCard}
5656
choices={choiceCards}
5757
id={'epic'}
58+
submitComponentEvent={submitComponentEvent}
5859
/>
5960
)}
6061
<ContributionsEpicButtons

0 commit comments

Comments
 (0)