Skip to content

Commit 208ea14

Browse files
cleanup
1 parent 55e9d0e commit 208ea14

File tree

2 files changed

+54
-52
lines changed

2 files changed

+54
-52
lines changed

dotcom-rendering/src/components/InlineProductCard.tsx

Lines changed: 52 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { palette } from '../palette';
1414
import { Caption } from './Caption';
1515
import { Picture } from './Picture';
1616
import { ProductLinkButton } from './ProductLinkButton';
17-
import { stripHtmlFromString } from './TextBlockComponent';
1817

1918
export type Statistics = {
2019
name: string;
@@ -29,10 +28,10 @@ export type InlineProductCardProps = {
2928
altText: string;
3029
credit: string;
3130
displayCredit: boolean;
32-
primaryCTA: string;
31+
primaryCta: string;
3332
primaryUrl: string;
3433
primaryPrice: string;
35-
secondaryCTA?: string;
34+
secondaryCta?: string;
3635
secondaryUrl?: string;
3736
statistics: Statistics[];
3837
isCardOnly: boolean;
@@ -111,26 +110,16 @@ const priceStyle = css`
111110
`;
112111

113112
const mobileButtonWrapper = css`
114-
display: flex;
115-
flex-direction: column;
116-
gap: ${space[1]}px;
117-
width: 100%;
118113
grid-column: 1 / span 2;
119-
margin-top: ${space[1]}px;
120-
121114
${from.mobileLandscape} {
122115
display: none;
123116
}
124117
`;
125118

126119
const desktopButtonWrapper = css`
127120
display: none;
128-
129121
${from.mobileLandscape} {
130-
display: flex;
131-
flex-direction: column;
132-
gap: ${space[1]}px;
133-
margin-top: 8px;
122+
display: inline;
134123
}
135124
`;
136125

@@ -172,10 +161,10 @@ export const InlineProductCard = ({
172161
altText,
173162
credit,
174163
displayCredit,
175-
primaryCTA,
164+
primaryCta,
176165
primaryUrl,
177166
primaryPrice,
178-
secondaryCTA,
167+
secondaryCta,
179168
secondaryUrl,
180169
statistics,
181170
isCardOnly = false,
@@ -208,45 +197,21 @@ export const InlineProductCard = ({
208197
<div css={productNameStyle}>{productName}</div>
209198
<div css={priceStyle}>{primaryPrice}</div>
210199
<div css={desktopButtonWrapper}>
211-
<ProductLinkButton
212-
dataComponent="inline-product-card-primary-button"
213-
label={stripHtmlFromString(primaryCTA)}
214-
url={primaryUrl}
215-
cssOverrides={css`
216-
width: 100%;
217-
`}
200+
<ProductCardButtons
201+
primaryCta={primaryCta}
202+
primaryUrl={primaryUrl}
203+
secondaryCta={secondaryCta}
204+
secondaryUrl={secondaryUrl}
218205
/>
219-
{!!secondaryCTA && !!secondaryUrl && (
220-
<ProductLinkButton
221-
dataComponent="inline-product-card-secondary-button"
222-
label={stripHtmlFromString(secondaryCTA)}
223-
url={secondaryUrl}
224-
priority="tertiary"
225-
cssOverrides={css`
226-
width: 100%;
227-
`}
228-
/>
229-
)}
230206
</div>
231207
</div>
232208
<div css={mobileButtonWrapper}>
233-
<ProductLinkButton
234-
label={stripHtmlFromString(primaryCTA)}
235-
url={primaryUrl}
236-
cssOverrides={css`
237-
width: 100%;
238-
`}
209+
<ProductCardButtons
210+
primaryCta={primaryCta}
211+
primaryUrl={primaryUrl}
212+
secondaryUrl={secondaryUrl}
213+
secondaryCta={secondaryCta}
239214
/>
240-
{!!secondaryCTA && !!secondaryUrl && (
241-
<ProductLinkButton
242-
label={stripHtmlFromString(secondaryCTA)}
243-
url={secondaryUrl}
244-
priority="tertiary"
245-
cssOverrides={css`
246-
width: 100%;
247-
`}
248-
/>
249-
)}
250215
</div>
251216
{!isCardOnly && statistics.length > 0 && (
252217
<div css={statisticsContainer}>
@@ -262,3 +227,40 @@ export const InlineProductCard = ({
262227
</div>
263228
);
264229
};
230+
231+
const ProductCardButtons = ({
232+
primaryCta,
233+
primaryUrl,
234+
secondaryCta,
235+
secondaryUrl,
236+
}: {
237+
primaryCta: string;
238+
primaryUrl: string;
239+
secondaryCta?: string;
240+
secondaryUrl?: string;
241+
}) => {
242+
return (
243+
<>
244+
<ProductLinkButton
245+
dataComponent="inline-product-card-primary-button"
246+
label={primaryCta}
247+
url={primaryUrl}
248+
cssOverrides={css`
249+
width: 100%;
250+
`}
251+
/>
252+
{!!secondaryCta && !!secondaryUrl && (
253+
<ProductLinkButton
254+
dataComponent="inline-product-card-secondary-button"
255+
label={secondaryCta}
256+
url={secondaryUrl}
257+
priority="tertiary"
258+
cssOverrides={css`
259+
width: 100%;
260+
margin-top: ${space[1]}px;
261+
`}
262+
/>
263+
)}
264+
</>
265+
);
266+
};

dotcom-rendering/src/components/ProductElement.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ export const ProductElement = ({
8585
image={product.image.url}
8686
primaryUrl={product.primaryProductUrl}
8787
primaryPrice={product.primaryPrice}
88-
primaryCTA={product.primaryCta}
89-
secondaryCTA={product.secondaryCta}
88+
primaryCta={product.primaryCta}
89+
secondaryCta={product.secondaryCta}
9090
secondaryUrl={product.secondaryProductUrl}
9191
altText={product.altText}
9292
credit={product.credit}

0 commit comments

Comments
 (0)