Skip to content

Commit 11ea4ec

Browse files
move product card buttons to separate file
1 parent 5be17b4 commit 11ea4ec

File tree

3 files changed

+40
-36
lines changed

3 files changed

+40
-36
lines changed

dotcom-rendering/src/components/InlineProductCard.tsx

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import {
1414
import type { ArticleFormat } from '../lib/articleFormat';
1515
import { palette } from '../palette';
1616
import type { ProductImage } from '../types/content';
17+
import { ProductCardButtons } from './ProductCardButtons';
1718
import { ProductCardImage } from './ProductCardImage';
1819
import type { ProductCardCta } from './ProductElement';
19-
import { ProductLinkButton } from './ProductLinkButton';
2020

2121
export type CustomAttributes = {
2222
name: string;
@@ -213,37 +213,3 @@ export const InlineProductCard = ({
213213
</div>
214214
);
215215
};
216-
217-
export const ProductCardButtons = ({
218-
productCtas,
219-
dataComponent,
220-
}: {
221-
productCtas: ProductCardCta[];
222-
dataComponent?: string;
223-
}) => {
224-
return (
225-
<>
226-
{productCtas.map((productCta, index) => (
227-
<ProductLinkButton
228-
key={productCta.label}
229-
label={productCta.label}
230-
url={productCta.url}
231-
priority={index === 0 ? 'primary' : 'tertiary'}
232-
cssOverrides={
233-
index === 0
234-
? css`
235-
width: 100%;
236-
`
237-
: css`
238-
width: 100%;
239-
margin-top: ${space[1]}px;
240-
`
241-
}
242-
data-component={`${
243-
dataComponent ?? 'product-card-button'
244-
}-${index}`}
245-
/>
246-
))}
247-
</>
248-
);
249-
};

dotcom-rendering/src/components/LeftColProductCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
import type { ArticleFormat } from '../lib/articleFormat';
1111
import { palette } from '../palette';
1212
import type { ProductImage } from '../types/content';
13-
import { ProductCardButtons } from './InlineProductCard';
13+
import { ProductCardButtons } from './ProductCardButtons';
1414
import { ProductCardImage } from './ProductCardImage';
1515
import type { ProductCardCta } from './ProductElement';
1616

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { css } from '@emotion/react';
2+
import { space } from '@guardian/source/foundations';
3+
import type { ProductCardCta } from './ProductElement';
4+
import { ProductLinkButton } from './ProductLinkButton';
5+
6+
export const ProductCardButtons = ({
7+
productCtas,
8+
dataComponent,
9+
}: {
10+
productCtas: ProductCardCta[];
11+
dataComponent?: string;
12+
}) => {
13+
return (
14+
<>
15+
{productCtas.map((productCta, index) => (
16+
<ProductLinkButton
17+
key={productCta.label}
18+
label={productCta.label}
19+
url={productCta.url}
20+
priority={index === 0 ? 'primary' : 'tertiary'}
21+
cssOverrides={
22+
index === 0
23+
? css`
24+
width: 100%;
25+
`
26+
: css`
27+
width: 100%;
28+
margin-top: ${space[1]}px;
29+
`
30+
}
31+
data-component={`${
32+
dataComponent ?? 'product-card-button'
33+
}-${index}`}
34+
/>
35+
))}
36+
</>
37+
);
38+
};

0 commit comments

Comments
 (0)