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

Commit 6c8bb58

Browse files
author
Richard Bangay
committed
add optional container to the header and lead text of the MinimalLayout component when used inside an iframe to reflect the different spacing in the designs
1 parent 50e76e6 commit 6c8bb58

File tree

1 file changed

+30
-11
lines changed

1 file changed

+30
-11
lines changed

src/client/layouts/MinimalLayout.tsx

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, { ReactElement, ReactNode } from 'react';
22
import { css } from '@emotion/react';
33
import MinimalHeader from '@/client/components/MinimalHeader';
44
import {
@@ -63,6 +63,12 @@ const mainStylesStretch = css`
6363
gap: ${CONTAINER_GAP};
6464
`;
6565

66+
const iframeThemeWrapperStyles = css`
67+
display: flex;
68+
flex-direction: column;
69+
gap: ${remSpace[2]};
70+
`;
71+
6672
const pageHeaderStyles = (subduedHeadingStyle: boolean) => css`
6773
color: var(--color-heading);
6874
${subduedHeadingStyle ? headlineMedium28 : headlineBold28};
@@ -97,22 +103,35 @@ export const MinimalLayout = ({
97103
return <Theme />;
98104
};
99105

106+
const ConditionalIframeThemeWrapper = ({
107+
children,
108+
}: {
109+
children: ReactNode | ReactElement;
110+
}) =>
111+
overrideTheme?.includes('iframe') ? (
112+
<section css={iframeThemeWrapperStyles}>{children}</section>
113+
) : (
114+
children
115+
);
116+
100117
return (
101118
<>
102119
{getTheme()}
103120
{showGuardianHeader && <MinimalHeader />}
104121
<main css={showGuardianHeader ? mainStyles(wide) : mainStylesStretch}>
105122
{imageId && <MinimalLayoutImage id={imageId} />}
106-
{pageHeader && (
107-
<header>
108-
<h1 css={pageHeaderStyles(subduedHeadingStyle)}>{pageHeader}</h1>
109-
</header>
110-
)}
111-
{leadText && typeof leadText === 'string' ? (
112-
<MainBodyText>{leadText}</MainBodyText>
113-
) : (
114-
leadText
115-
)}
123+
<ConditionalIframeThemeWrapper>
124+
{pageHeader && (
125+
<header>
126+
<h1 css={pageHeaderStyles(subduedHeadingStyle)}>{pageHeader}</h1>
127+
</header>
128+
)}
129+
{leadText && typeof leadText === 'string' ? (
130+
<MainBodyText>{leadText}</MainBodyText>
131+
) : (
132+
leadText
133+
)}
134+
</ConditionalIframeThemeWrapper>
116135
<section css={mainSectionStyles}>
117136
{errorMessage && (
118137
<GatewayErrorSummary

0 commit comments

Comments
 (0)