Skip to content

Commit 910d079

Browse files
improve inline card grid - remove duplication of buttons
1 parent 058df59 commit 910d079

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

dotcom-rendering/src/components/ProductCardInline.tsx

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,20 @@ export type InlineProductCardProps = {
3535
const baseCard = css`
3636
padding: ${space[2]}px ${space[3]}px ${space[3]}px;
3737
display: grid;
38-
grid-template-columns: 1fr 1fr;
38+
grid-template:
39+
'image info'
40+
'buttons buttons'
41+
'custom-attributes custom-attributes' / 1fr 1fr;
3942
column-gap: 10px;
4043
row-gap: ${space[4]}px;
4144
max-width: 100%;
42-
img {
43-
width: 100%;
44-
height: auto;
45-
}
4645
${from.mobileLandscape} {
46+
grid-template:
47+
'image info' auto
48+
'image buttons' 1fr
49+
'custom-attributes custom-attributes' / 1fr 1fr;
4750
column-gap: 20px;
51+
row-gap: ${space[2]}px;
4852
}
4953
`;
5054

@@ -68,6 +72,7 @@ const productCard = css`
6872
`;
6973

7074
const productInfoContainer = css`
75+
grid-area: info;
7176
display: flex;
7277
flex-direction: column;
7378
gap: ${space[1]}px;
@@ -99,36 +104,35 @@ const productNameStyle = css`
99104
}
100105
`;
101106

102-
const mobileButtonWrapper = css`
103-
grid-column: 1 / span 2;
104-
display: grid;
105-
row-gap: ${space[1]}px;
106-
${from.mobileLandscape} {
107-
display: none;
108-
}
109-
`;
110-
111-
const desktopButtonWrapper = css`
112-
display: none;
113-
${from.mobileLandscape} {
114-
display: grid;
115-
row-gap: ${space[1]}px;
116-
}
107+
const buttonWrapper = css`
108+
grid-area: buttons;
109+
display: flex;
110+
flex-direction: column;
111+
gap: ${space[1]}px;
117112
`;
118113

119114
const customAttributesContainer = css`
120-
grid-column: 1 / span 2;
115+
grid-area: custom-attributes;
121116
border-top: 1px solid ${palette('--product-card-border-neutral')};
122117
padding-top: ${space[2]}px;
123118
display: grid;
124119
gap: ${space[3]}px;
125120
126121
${from.mobileLandscape} {
122+
margin-top: ${space[2]}px;
127123
grid-template-columns: 1fr 1fr;
128124
gap: ${space[5]}px;
129125
}
130126
`;
131127

128+
const imageGridArea = css`
129+
grid-area: image;
130+
img {
131+
width: 100%;
132+
height: auto;
133+
}
134+
`;
135+
132136
const customAttributeItem = css`
133137
${textSans15};
134138
${from.phablet} {
@@ -164,11 +168,13 @@ export const ProductCardInline = ({
164168
shouldShowLeftColCard && !isCardOnly && hideFromWide,
165169
]}
166170
>
167-
<ProductCardImage
168-
format={format}
169-
image={image}
170-
url={productCtas[0]?.url}
171-
/>
171+
<div css={imageGridArea}>
172+
<ProductCardImage
173+
format={format}
174+
image={image}
175+
url={productCtas[0]?.url}
176+
/>
177+
</div>
172178
<div css={productInfoContainer}>
173179
<div css={primaryHeading}>{brandName}</div>
174180
<div css={productNameStyle}>{productName}</div>
@@ -183,17 +189,11 @@ export const ProductCardInline = ({
183189
)}
184190
</div>
185191
)}
186-
<div css={desktopButtonWrapper}>
187-
<ProductCardButtons
188-
productCtas={productCtas}
189-
dataComponent={'inline-product-card-buttons-desktop'}
190-
/>
191-
</div>
192192
</div>
193-
<div css={mobileButtonWrapper}>
193+
<div css={buttonWrapper}>
194194
<ProductCardButtons
195195
productCtas={productCtas}
196-
dataComponent={'inline-product-card-buttons-mobile'}
196+
dataComponent={'inline-product-card-buttons'}
197197
/>
198198
</div>
199199
{!isCardOnly && customAttributes.length > 0 && (

0 commit comments

Comments
 (0)