WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions src/client/components/MainBodyText.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import React, { PropsWithChildren } from 'react';
import { css, SerializedStyles } from '@emotion/react';
import { textSans15, textSansBold15 } from '@guardian/source/foundations';
import {
textSans15,
textSans17,
textSansBold15,
textSansBold17,
} from '@guardian/source/foundations';

interface Props {
cssOverrides?: SerializedStyles;
isIframed?: boolean;
}

export const mainBodyTextStyles = css`
Expand All @@ -26,9 +32,37 @@ export const mainBodyTextStyles = css`
}
`;

export const iframeMainBodyTextStyles = css`
${textSans17};
color: var(--color-text);
margin: 0;

strong {
${textSansBold17};
color: var(--color-strong-text);
}

a {
${textSansBold17};
color: var(--color-link);

strong {
color: var(--color-link);
}
}
`;

export const MainBodyText = ({
children,
cssOverrides,
isIframed = false,
}: PropsWithChildren<Props>) => (
<p css={[mainBodyTextStyles, cssOverrides]}>{children}</p>
<p
css={[
isIframed ? iframeMainBodyTextStyles : mainBodyTextStyles,
cssOverrides,
]}
>
{children}
</p>
);
2 changes: 2 additions & 0 deletions src/client/components/MainForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
import locations from '@/shared/lib/locations';
import { GatewayErrorSummary } from '@/client/components/GatewayErrorSummary';
import { NoScript } from './NoScript';
import { CONTAINER_GAP } from '../models/Style';

type TermsStyle = 'primary' | 'secondary';

Expand Down Expand Up @@ -382,6 +383,7 @@ export const MainForm = ({
)}
{recaptchaEnabled && (
<RecaptchaWrapper
overrideGapCounteract={isIframed ? CONTAINER_GAP : undefined}
recaptchaSiteKey={recaptchaSiteKey}
setRecaptchaState={setRecaptchaState}
/>
Expand Down
20 changes: 13 additions & 7 deletions src/client/layouts/MinimalLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import MinimalHeader from '@/client/components/MinimalHeader';
import {
from,
headlineBold28,
headlineMedium24,
headlineMedium28,
remSpace,
} from '@guardian/source/foundations';
Expand All @@ -30,7 +31,6 @@ interface MinimalLayoutProps {
children?: React.ReactNode;
wide?: boolean;
pageHeader: string;
subduedHeadingStyle?: boolean;
leadText?: React.ReactNode;
imageId?: DecorativeImageId;
successOverride?: string;
Expand Down Expand Up @@ -66,17 +66,23 @@ const iframeThemeWrapperStyles = css`
gap: ${remSpace[2]};
`;

const pageHeaderStyles = (subduedHeadingStyle: boolean) => css`
const pageHeaderStyles = (amIIframed: boolean) => css`
color: var(--color-heading);
${subduedHeadingStyle ? headlineMedium28 : headlineBold28};
${amIIframed
? `
${headlineMedium24};
${from.mobileLandscape} {
${headlineMedium28};
}
`
: headlineBold28};
margin: 0;
`;

export const MinimalLayout = ({
children,
wide = false,
pageHeader,
subduedHeadingStyle = false,
leadText,
imageId,
successOverride,
Expand All @@ -99,7 +105,7 @@ export const MinimalLayout = ({
return <Theme />;
};

const amIIframed = overrideTheme?.includes('iframe');
const amIIframed = !!overrideTheme?.includes('iframe');

const ConditionalIframeThemeWrapper = ({
children,
Expand All @@ -121,11 +127,11 @@ export const MinimalLayout = ({
<ConditionalIframeThemeWrapper>
{pageHeader && (
<header>
<h1 css={pageHeaderStyles(subduedHeadingStyle)}>{pageHeader}</h1>
<h1 css={pageHeaderStyles(amIIframed)}>{pageHeader}</h1>
</header>
)}
{leadText && typeof leadText === 'string' ? (
<MainBodyText>{leadText}</MainBodyText>
<MainBodyText isIframed={amIIframed}>{leadText}</MainBodyText>
) : (
leadText
)}
Expand Down
21 changes: 16 additions & 5 deletions src/client/lib/hooks/useRecaptcha.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ export const RecaptchaWrapper: React.FC<{
setRecaptchaState: React.Dispatch<
React.SetStateAction<UseRecaptchaReturnValue | undefined>
>;
}> = ({ recaptchaSiteKey, setRecaptchaState }) => {
overrideGapCounteract?: number | string;
}> = ({ recaptchaSiteKey, setRecaptchaState, overrideGapCounteract }) => {
const { error, executeCaptcha, expired, requestCount, token, widgetId } =
useRecaptcha(recaptchaSiteKey, 'recaptcha');
React.useEffect(() => {
Expand All @@ -208,26 +209,36 @@ export const RecaptchaWrapper: React.FC<{
token,
widgetId,
]);
return <RecaptchaElement id="recaptcha" />;
return (
<RecaptchaElement
id="recaptcha"
gapCountractValue={overrideGapCounteract ?? SECTION_GAP}
/>
);
};

/**
* Provides a standardised way to bind Recaptcha to your page.
*/
interface RecaptchaElementProps extends React.HTMLProps<HTMLDivElement> {
gapCountractValue: number | string;
}

const RecaptchaElement = React.forwardRef<
HTMLDivElement,
React.HTMLProps<HTMLDivElement>
RecaptchaElementProps
>(function RecaptchaElement(props, ref) {
const { gapCountractValue, ...otherProps } = props;
return (
<div
ref={ref}
className="g-recaptcha"
{...props}
{...otherProps}
// TODO: This is a fix for when the reCAPTCHA badge is not visible in the DOM.
// In these cases, the wrapper is still visible, which means it gets affected
// by the `gap` spacing applied to its parent flex container in `MainForm`.
// We set a negative margin here to counteract what looks like an overly large gap.
css={{ marginTop: `-${SECTION_GAP}` }}
css={{ marginTop: `-${gapCountractValue}` }}
></div>
);
});
1 change: 0 additions & 1 deletion src/client/pages/IframedPasscodeEmailSent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ export const IframedPasscodeEmailSent = ({
}
pageHeader={text.title}
shortRequestId={shortRequestId}
subduedHeadingStyle={true}
overrideTheme="iframe-light"
>
{email ? (
Expand Down
1 change: 0 additions & 1 deletion src/client/pages/IframedRegisterWithEmail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export const IframedRegisterWithEmail = ({
shortRequestId={shortRequestId}
errorContext={getErrorContext(pageError)}
errorOverride={pageError}
subduedHeadingStyle={true}
overrideTheme="iframe-light"
>
<MainForm
Expand Down
1 change: 0 additions & 1 deletion src/client/pages/IframedSignIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ export const IframedSignIn = ({
pageHeader="Sign in to your account"
leadText="This unlocks your premium experience, online and in the app."
shortRequestId={shortRequestId}
subduedHeadingStyle={true}
overrideTheme="iframe-light"
>
{/* AuthProviderButtons component with show boolean */}
Expand Down