@@ -5,6 +5,7 @@ import { withComponents } from "@reactioncommerce/components-context";
5
5
import { addTypographyStyles , applyTheme , CustomPropTypes } from "../../../utils" ;
6
6
7
7
const Item = styled . div `
8
+ position: relative;
8
9
align-items: flex-start;
9
10
border-bottom-color: ${ applyTheme ( "CartItem.borderBottomColor" ) } ;
10
11
border-bottom-style: solid;
@@ -79,17 +80,39 @@ const ItemContentQuantityInput = styled.div`
79
80
` ;
80
81
81
82
const ItemContentPrice = styled . div `
82
- bottom: 0;
83
- flex: 0 1 auto;
84
- position: absolute;
83
+ position: ${ ( props ) => ( props . isMiniCart ? "absolute" : "initial" ) } ;
84
+ bottom: ${ applyTheme ( "CartItem.paddingBottom" ) } ;
85
85
right: 0;
86
-
86
+ text-align: right;
87
+ @media (max-width: 768px) {
88
+ position: absolute;
89
+ }
87
90
@media (min-width: 768px) {
88
91
margin-left: 1.5rem;
89
- position: ${ ( { isMiniCart } ) => ( isMiniCart ? "absolute" : "relative" ) } ;
90
92
}
91
93
` ;
92
94
95
+ const ItemContentSubtotal = styled . div `
96
+ position: ${ ( props ) => ( props . isMiniCart ? "initial" : "absolute" ) } ;
97
+ margin-top: ${ ( props ) => ( props . isMiniCart ? applyTheme ( "CartItem.subtotalDisplaySpacingAbove" ) ( props ) : "0" ) } ;
98
+ bottom: ${ applyTheme ( "CartItem.paddingBottom" ) } ;
99
+ right: 0;
100
+ text-align: right;
101
+ @media (max-width: 768px) {
102
+ position: initial;
103
+ margin-top: ${ applyTheme ( "CartItem.subtotalDisplaySpacingAbove" ) } ;
104
+ }
105
+ ` ;
106
+
107
+ const ItemContentSubtotalTitle = styled . div `
108
+ ${ addTypographyStyles ( "ItemContentSubtotalTitle" , "labelText" ) } ;
109
+ white-space: pre;
110
+ ` ;
111
+
112
+ const ItemContentSubtotalDisplay = styled . div `
113
+ ${ addTypographyStyles ( "ItemContentSubtotalDisplay" , "bodyTextSemiBold" ) } ;
114
+ ` ;
115
+
93
116
const ItemRemoveButton = styled . button `
94
117
${ addTypographyStyles ( "CartItemRemoveButton" , "labelText" ) }
95
118
align-self: flex-start;
@@ -219,6 +242,12 @@ class CartItem extends Component {
219
242
/**
220
243
* Chosen items title
221
244
*/
245
+ subtotal : PropTypes . shape ( {
246
+ /**
247
+ * The display subtotal
248
+ */
249
+ displayAmount : PropTypes . string
250
+ } ) ,
222
251
title : PropTypes . string ,
223
252
/**
224
253
* Quantity of chosen item in cart
@@ -293,10 +322,12 @@ class CartItem extends Component {
293
322
title,
294
323
quantity,
295
324
isLowQuantity,
296
- price : { displayAmount : displayPrice }
325
+ price : { displayAmount : displayPrice } ,
326
+ subtotal
297
327
}
298
328
} = this . props ;
299
329
330
+ const { displayAmount : displaySubtotal } = subtotal || { } ;
300
331
const { displayAmount : displayCompareAtPrice } = compareAtPrice || { } ;
301
332
302
333
const {
@@ -339,15 +370,22 @@ class CartItem extends Component {
339
370
340
371
{ ! isReadOnly && < ItemRemoveButton onClick = { this . handleRemoveItemFromCart } > Remove</ ItemRemoveButton > }
341
372
</ ItemContentDetail >
342
-
343
- < ItemContentPrice isMiniCart = { isMiniCart } >
344
- < Price
345
- displayPrice = { displayPrice }
346
- displayCompareAtPrice = { displayCompareAtPrice }
347
- hasPriceBottom = { isMiniCart }
348
- />
349
- </ ItemContentPrice >
350
373
</ ItemContent >
374
+ < ItemContentPrice isMiniCart = { isMiniCart } >
375
+ < Price
376
+ displayPrice = { displayPrice }
377
+ displayCompareAtPrice = { displayCompareAtPrice }
378
+ hasPriceBottom = { isMiniCart }
379
+ />
380
+ { quantity !== 1 ?
381
+ < ItemContentSubtotal isMiniCart = { isMiniCart } >
382
+ < ItemContentSubtotalTitle > Total ({ quantity } ):</ ItemContentSubtotalTitle >
383
+ < ItemContentSubtotalDisplay > { displaySubtotal } </ ItemContentSubtotalDisplay >
384
+ </ ItemContentSubtotal >
385
+ :
386
+ null
387
+ }
388
+ </ ItemContentPrice >
351
389
</ Item >
352
390
) ;
353
391
}
0 commit comments