diff options
| author | Wes Bos <wesbos@gmail.com> | 2018-02-15 16:59:58 -0500 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2018-02-15 16:59:58 -0500 |
| commit | 8f2c595eca30e2d7138c8e8d6685774a8f44e55d (patch) | |
| tree | 3408b9c8eb3b0ea43cb72e13e0bd6393ab5bac61 /frontend/components/CartItem.js | |
| parent | a09b01abf7c03e6b7e43f2175e5a34501808821b (diff) | |
omg
Diffstat (limited to 'frontend/components/CartItem.js')
| -rw-r--r-- | frontend/components/CartItem.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/frontend/components/CartItem.js b/frontend/components/CartItem.js new file mode 100644 index 0000000..83c948e --- /dev/null +++ b/frontend/components/CartItem.js @@ -0,0 +1,39 @@ +import formatMoney from '../lib/formatMoney'; +import RemoveFromCart from './RemoveFromCart'; +import styled from 'styled-components'; + +const CartItemStyles = styled.li` + padding: 1rem 0; + border-bottom: 1px solid ${props => props.theme.lightgrey}; + display: grid; + align-items: center; + grid-template-columns: auto 1fr auto; + img { + margin-right: 10px; + } + h3 { + margin: 0; + } + p { + margin: 0; + } +`; + +const CartItem = ({ cartItem }) => ( + <CartItemStyles key={cartItem.id}> + <img width="100" src={cartItem.item.image} alt={cartItem.item.title} /> + <div className="cart-item-details"> + <h3>{cartItem.item.title}</h3> + <p> + {formatMoney(cartItem.quantity * cartItem.item.price)} + {' — '} + <em> + {cartItem.quantity} × {formatMoney(cartItem.item.price)} each + </em> + </p> + </div> + <RemoveFromCart id={cartItem.id} /> + </CartItemStyles> +); + +export default CartItem; |
