Skip to content

Commit 4aaea22

Browse files
Update NewsletterSignupCard styling for better responsiveness on small devices
1 parent 1fe7ad1 commit 4aaea22

2 files changed

Lines changed: 63 additions & 29 deletions

File tree

dotcom-rendering/src/components/NewsletterSignupCard.tsx

Lines changed: 53 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
headlineMedium20,
55
space,
66
textSans14,
7-
textSans15,
7+
textSansBold15,
88
} from '@guardian/source/foundations';
99
import { SvgNewsletterFilled } from '@guardian/source/react-components';
1010
import { palette as themePalette } from '../palette';
@@ -54,24 +54,44 @@ const titleStyles = css`
5454

5555
const frequencyTagStyles = css`
5656
display: flex;
57+
flex-wrap: wrap;
5758
align-items: center;
59+
gap: ${space[1]}px;
5860
color: ${themePalette('--newsletter-card-frequency-tag')};
59-
${textSans15};
60-
margin-left: -1px;
61-
margin-top: -1px;
62-
margin-bottom: ${space[1]}px;
61+
${textSansBold15};
62+
margin-bottom: ${space[2]}px;
63+
`;
64+
65+
const frequencyLabelStyles = css`
66+
white-space: nowrap;
67+
`;
68+
69+
const badgeStyles = css`
70+
display: flex;
71+
align-items: center;
72+
justify-content: center;
73+
flex-shrink: 0;
74+
width: 20px;
75+
height: 20px;
76+
border-radius: 50%;
77+
background-color: ${themePalette('--newsletter-card-badge-background')};
6378
6479
svg {
65-
fill: currentColor;
66-
height: 20px;
67-
width: 20px;
80+
fill: ${themePalette('--newsletter-card-badge-icon')};
81+
height: 14px;
82+
width: 14px;
6883
}
6984
`;
7085

86+
const innerDividerStyles = css`
87+
border: none;
88+
border-top: 1px solid ${themePalette('--newsletter-card-divider')};
89+
margin: 0 0 ${space[2]}px;
90+
`;
91+
7192
const descriptionStyles = css`
7293
${textSans14};
7394
line-height: 1.15;
74-
margin-bottom: ${space[2]}px;
7595
clear: both;
7696
color: ${themePalette('--newsletter-card-description')};
7797
`;
@@ -92,27 +112,33 @@ const illustrationStyles = css`
92112
const NewsletterSignupHeader = (
93113
props: Omit<NewsletterSignupCardProps, 'children'>,
94114
) => (
95-
<div css={headerStyles}>
96-
<div css={titleAndMetaStyles}>
97-
<div css={frequencyTagStyles}>
115+
<>
116+
<div css={frequencyTagStyles}>
117+
<span css={badgeStyles}>
98118
<SvgNewsletterFilled />
99-
Free newsletter | {props.frequency}
119+
</span>
120+
<span css={frequencyLabelStyles}>Free newsletter |</span>
121+
<span css={frequencyLabelStyles}>{props.frequency}</span>
122+
</div>
123+
<hr css={innerDividerStyles} />
124+
<div css={headerStyles}>
125+
<div css={titleAndMetaStyles}>
126+
<p css={titleStyles}>
127+
Sign up to <span>{props.name}</span>
128+
</p>
129+
<p css={descriptionStyles}>{props.description}</p>
100130
</div>
101-
<p css={titleStyles}>
102-
Sign up to <span>{props.name}</span>
103-
</p>
104-
<p css={descriptionStyles}>{props.description}</p>
131+
{!!props.illustrationSquare && (
132+
<img
133+
css={illustrationStyles}
134+
src={props.illustrationSquare}
135+
alt=""
136+
loading="lazy"
137+
decoding="async"
138+
/>
139+
)}
105140
</div>
106-
{!!props.illustrationSquare && (
107-
<img
108-
css={illustrationStyles}
109-
src={props.illustrationSquare}
110-
alt=""
111-
loading="lazy"
112-
decoding="async"
113-
/>
114-
)}
115-
</div>
141+
</>
116142
);
117143

118144
export const NewsletterSignupCard = ({

dotcom-rendering/src/paletteDeclarations.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7965,6 +7965,14 @@ const paletteColours = {
79657965
light: () => '#F3F7FF',
79667966
dark: () => sourcePalette.brand[100],
79677967
},
7968+
'--newsletter-card-badge-background': {
7969+
light: () => sourcePalette.brand[400],
7970+
dark: () => sourcePalette.brand[600],
7971+
},
7972+
'--newsletter-card-badge-icon': {
7973+
light: () => sourcePalette.neutral[100],
7974+
dark: () => sourcePalette.neutral[100],
7975+
},
79687976
'--newsletter-card-description': {
79697977
light: () => sourcePalette.neutral[20],
79707978
dark: () => sourcePalette.neutral[86],
@@ -7974,8 +7982,8 @@ const paletteColours = {
79747982
dark: () => sourcePalette.neutral[46],
79757983
},
79767984
'--newsletter-card-frequency-tag': {
7977-
light: () => sourcePalette.neutral[38],
7978-
dark: () => sourcePalette.neutral[73],
7985+
light: () => sourcePalette.brand[400],
7986+
dark: () => sourcePalette.neutral[100],
79797987
},
79807988
'--newsletter-card-title': {
79817989
light: () => sourcePalette.neutral[7],

0 commit comments

Comments
 (0)