@@ -32,21 +32,37 @@ export type InlineProductCardProps = {
3232 lowestPrice ?: string ;
3333} ;
3434
35- const baseCard = css `
36- padding : ${ space [ 2 ] } px ${ space [ 3 ] } px ${ space [ 3 ] } px;
37- display : grid;
35+ const defaultGrid = css `
3836 grid-template :
3937 'image info'
4038 'buttons buttons'
4139 'custom-attributes custom-attributes' / 1fr 1fr ;
42- column-gap : 10px ;
43- row-gap : ${ space [ 4 ] } px;
44- max-width : 100% ;
4540 ${ from . mobileLandscape } {
4641 grid-template :
4742 'image info' auto
4843 'image buttons' 1fr
4944 'custom-attributes custom-attributes' / 1fr 1fr ;
45+ }
46+ ` ;
47+
48+ const noCustomAttributesGrid = css `
49+ grid-template :
50+ 'image info'
51+ 'buttons buttons' / 1fr 1fr ;
52+ ${ from . mobileLandscape } {
53+ grid-template :
54+ 'image info' auto
55+ 'image buttons' 1fr / 1fr 1fr ;
56+ }
57+ ` ;
58+
59+ const baseCard = css `
60+ padding : ${ space [ 2 ] } px ${ space [ 3 ] } px ${ space [ 3 ] } px;
61+ display : grid;
62+ column-gap : 10px ;
63+ row-gap : ${ space [ 4 ] } px;
64+ max-width : 100% ;
65+ ${ from . mobileLandscape } {
5066 column-gap : 20px ;
5167 row-gap : ${ space [ 2 ] } px;
5268 }
@@ -161,51 +177,56 @@ export const ProductCardInline = ({
161177 isCardOnly = false ,
162178 shouldShowLeftColCard = false ,
163179 lowestPrice,
164- } : InlineProductCardProps ) => (
165- < div
166- css = { [
167- isCardOnly ? productCard : showcaseCard ,
168- shouldShowLeftColCard && ! isCardOnly && hideFromWide ,
169- ] }
170- >
171- < div css = { imageGridArea } >
172- < ProductCardImage
173- format = { format }
174- image = { image }
175- url = { productCtas [ 0 ] ?. url }
176- />
177- </ div >
178- < div css = { productInfoContainer } >
179- < div css = { primaryHeading } > { brandName } </ div >
180- < div css = { productNameStyle } > { productName } </ div >
181- { ! ! lowestPrice && (
182- < div css = { productNameStyle } >
183- { productCtas . length > 1 ? (
184- < >
185- from < strong > { lowestPrice } </ strong >
186- </ >
187- ) : (
188- < strong > { lowestPrice } </ strong >
189- ) }
180+ } : InlineProductCardProps ) => {
181+ const hasCustomAttributes = customAttributes . length > 0 && ! isCardOnly ;
182+
183+ return (
184+ < div
185+ css = { [
186+ isCardOnly ? productCard : showcaseCard ,
187+ shouldShowLeftColCard && ! isCardOnly && hideFromWide ,
188+ hasCustomAttributes ? defaultGrid : noCustomAttributesGrid ,
189+ ] }
190+ >
191+ < div css = { imageGridArea } >
192+ < ProductCardImage
193+ format = { format }
194+ image = { image }
195+ url = { productCtas [ 0 ] ?. url }
196+ />
197+ </ div >
198+ < div css = { productInfoContainer } >
199+ < div css = { primaryHeading } > { brandName } </ div >
200+ < div css = { productNameStyle } > { productName } </ div >
201+ { ! ! lowestPrice && (
202+ < div css = { productNameStyle } >
203+ { productCtas . length > 1 ? (
204+ < >
205+ from < strong > { lowestPrice } </ strong >
206+ </ >
207+ ) : (
208+ < strong > { lowestPrice } </ strong >
209+ ) }
210+ </ div >
211+ ) }
212+ </ div >
213+ < div css = { buttonWrapper } >
214+ < ProductCardButtons
215+ productCtas = { productCtas }
216+ dataComponent = { 'inline-product-card-buttons' }
217+ />
218+ </ div >
219+ { hasCustomAttributes && (
220+ < div css = { customAttributesContainer } >
221+ { customAttributes . map ( ( customAttribute ) => (
222+ < CustomAttribute
223+ key = { customAttribute . name }
224+ name = { customAttribute . name }
225+ value = { customAttribute . value }
226+ />
227+ ) ) }
190228 </ div >
191229 ) }
192230 </ div >
193- < div css = { buttonWrapper } >
194- < ProductCardButtons
195- productCtas = { productCtas }
196- dataComponent = { 'inline-product-card-buttons' }
197- />
198- </ div >
199- { ! isCardOnly && customAttributes . length > 0 && (
200- < div css = { customAttributesContainer } >
201- { customAttributes . map ( ( customAttribute ) => (
202- < CustomAttribute
203- key = { customAttribute . name }
204- name = { customAttribute . name }
205- value = { customAttribute . value }
206- />
207- ) ) }
208- </ div >
209- ) }
210- </ div >
211- ) ;
231+ ) ;
232+ } ;
0 commit comments