Cart block: line-items front end initial work (https://github.com/woocommerce/woocommerce-blocks/pull/1333)
* render block on front end, add `Shopping cart` heading (baby steps)
* fake data for editing full cart + show line count in header
* add note about core/html using `is-active` class for toggle state
* reinstate work-in-progress full cart component (lost in rebase)
* reinstate full cart from master
* component for full cart title & item count + margin tweaks:
- add margin between main cart & sidebar
- add margin after cart block
* add cart items sample data + factor sample product image to module
* use sample cart data for item count
* basic table of cart line items (no styling)
* prettification
* show images for cart line items + initial table styling
* cart quantity selector component (work in progress)
* use state for cart product quantity, allow incr/decr from UI (WIP)
* replace WIP custom quantity control with number edit (temporary)
* correctly format cart line item total price
* align cart item columns with headings + indent image on desktop
* tweak css for cart line item padding on mobile so it's more explicit
* show cart line item full price if discounted
* add placeholder for cart remove item link
* switch cart table to flex layout (was table)…
This will allow us to move things around for mobile/responsive layout.
* only show cart items table header on desktop
* more cart items styling - row borders, appropriate padding +
+ move image width to variable
+ fix class name plurality for row (item not items)
* use standard $gap instead of 1em for padding/margins
* responsive (mobile) layout for cart line items:
- shift line $ total to bottom right
- stack quantity selector in product info column
* remove extraneous cart table padding on mobile
* comment about unused styles for quantity selector component
* add follow up issue for todo
* remove inappropriate href
* render srcset & sizes for cart line item product image
* remove todo comment
* switch back to table markup for cart items (in progress):
- table is more semantic, associates headers with columns
* cart line items column widths - product column is larger (60%)
* reinstate table row borders
* bottom-align line item price on mobile
* cart contents heading should be H2 + prettify
* remove unused QuantitySelector code/styles, rename main class in line with BEM
* defaults for QuantitySelector props
* variable/property name tidies - match conventions/API
* fix bug: line total price is only bottom-align on small screen
* move QuantitySelector to root of components, intended to be generally useful
* use lineItem directly for cart, specify shape in PropTypes
* rename cart components to align with "line item" rather than "product"
* rejig class names to better align with new component names & BEM style
* show cart item image correct size:
- use single column for product image and info, with flex container
- specify image width (rem instead of px)
* fix safari issue - cart product images displaying vertically stretched
* shift product name left margin from image, to account for no-image case
* experiment: bump bundlewatch size limit for cart temporarily:
- our fake data inline image is heavy
- when we switch to real API we will no longer need it
* fix issue introduced when moving margin from image to details div:
- product details needs margin on left (not right)
* fix react props issues:
- explicitly destructure image props for srcSet (vs srcset)
- use API key field for line item key instead of id, fix duplicate test id
- CartLineItemsTable takes an array of lineItems (incorrect PropTypes)
* remove redundant divs + use conventional `null` (when no full price)
* override editor styles to ensure cart product image is correct size
* move cart items editor style override to editor.css
* add an explicit readable heading for cart heading to match visual layout
2020-01-09 22:50:14 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2020-04-07 11:03:22 +00:00
|
|
|
import classnames from 'classnames';
|
2020-03-13 15:49:33 +00:00
|
|
|
import { __ } from '@wordpress/i18n';
|
Cart block: line-items front end initial work (https://github.com/woocommerce/woocommerce-blocks/pull/1333)
* render block on front end, add `Shopping cart` heading (baby steps)
* fake data for editing full cart + show line count in header
* add note about core/html using `is-active` class for toggle state
* reinstate work-in-progress full cart component (lost in rebase)
* reinstate full cart from master
* component for full cart title & item count + margin tweaks:
- add margin between main cart & sidebar
- add margin after cart block
* add cart items sample data + factor sample product image to module
* use sample cart data for item count
* basic table of cart line items (no styling)
* prettification
* show images for cart line items + initial table styling
* cart quantity selector component (work in progress)
* use state for cart product quantity, allow incr/decr from UI (WIP)
* replace WIP custom quantity control with number edit (temporary)
* correctly format cart line item total price
* align cart item columns with headings + indent image on desktop
* tweak css for cart line item padding on mobile so it's more explicit
* show cart line item full price if discounted
* add placeholder for cart remove item link
* switch cart table to flex layout (was table)…
This will allow us to move things around for mobile/responsive layout.
* only show cart items table header on desktop
* more cart items styling - row borders, appropriate padding +
+ move image width to variable
+ fix class name plurality for row (item not items)
* use standard $gap instead of 1em for padding/margins
* responsive (mobile) layout for cart line items:
- shift line $ total to bottom right
- stack quantity selector in product info column
* remove extraneous cart table padding on mobile
* comment about unused styles for quantity selector component
* add follow up issue for todo
* remove inappropriate href
* render srcset & sizes for cart line item product image
* remove todo comment
* switch back to table markup for cart items (in progress):
- table is more semantic, associates headers with columns
* cart line items column widths - product column is larger (60%)
* reinstate table row borders
* bottom-align line item price on mobile
* cart contents heading should be H2 + prettify
* remove unused QuantitySelector code/styles, rename main class in line with BEM
* defaults for QuantitySelector props
* variable/property name tidies - match conventions/API
* fix bug: line total price is only bottom-align on small screen
* move QuantitySelector to root of components, intended to be generally useful
* use lineItem directly for cart, specify shape in PropTypes
* rename cart components to align with "line item" rather than "product"
* rejig class names to better align with new component names & BEM style
* show cart item image correct size:
- use single column for product image and info, with flex container
- specify image width (rem instead of px)
* fix safari issue - cart product images displaying vertically stretched
* shift product name left margin from image, to account for no-image case
* experiment: bump bundlewatch size limit for cart temporarily:
- our fake data inline image is heavy
- when we switch to real API we will no longer need it
* fix issue introduced when moving margin from image to details div:
- product details needs margin on left (not right)
* fix react props issues:
- explicitly destructure image props for srcSet (vs srcset)
- use API key field for line item key instead of id, fix duplicate test id
- CartLineItemsTable takes an array of lineItems (incorrect PropTypes)
* remove redundant divs + use conventional `null` (when no full price)
* override editor styles to ensure cart product image is correct size
* move cart items editor style override to editor.css
* add an explicit readable heading for cart heading to match visual layout
2020-01-09 22:50:14 +00:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import QuantitySelector from '@woocommerce/base-components/quantity-selector';
|
2020-09-14 10:56:10 +00:00
|
|
|
import ProductPrice from '@woocommerce/base-components/product-price';
|
2020-03-13 15:49:33 +00:00
|
|
|
import { getCurrency } from '@woocommerce/base-utils';
|
2020-03-09 12:24:56 +00:00
|
|
|
import { useStoreCartItemQuantity } from '@woocommerce/base-hooks';
|
2020-01-31 18:20:33 +00:00
|
|
|
import { Icon, trash } from '@woocommerce/icons';
|
2020-03-13 15:49:33 +00:00
|
|
|
import {
|
2020-07-14 15:25:53 +00:00
|
|
|
ProductBackorderBadge,
|
2020-03-13 15:49:33 +00:00
|
|
|
ProductImage,
|
|
|
|
ProductLowStockBadge,
|
|
|
|
ProductMetadata,
|
|
|
|
ProductName,
|
|
|
|
ProductSaleBadge,
|
|
|
|
} from '@woocommerce/base-components/cart-checkout';
|
2020-03-17 15:34:33 +00:00
|
|
|
import Dinero from 'dinero.js';
|
2020-01-13 23:07:52 +00:00
|
|
|
|
2020-03-10 11:43:57 +00:00
|
|
|
/**
|
|
|
|
* @typedef {import('@woocommerce/type-defs/cart').CartItem} CartItem
|
|
|
|
*/
|
|
|
|
|
2020-03-17 15:34:33 +00:00
|
|
|
/**
|
|
|
|
* Convert a Dinero object with precision to store currency minor unit.
|
|
|
|
*
|
|
|
|
* @param {Dinero} priceObject Price object to convert.
|
|
|
|
* @param {Object} currency Currency data.
|
|
|
|
* @return {number} Amount with new minor unit precision.
|
|
|
|
*/
|
|
|
|
const getAmountFromRawPrice = ( priceObject, currency ) => {
|
|
|
|
return priceObject.convertPrecision( currency.minorUnit ).getAmount();
|
|
|
|
};
|
|
|
|
|
2020-02-26 15:49:07 +00:00
|
|
|
/**
|
|
|
|
* Cart line item table row component.
|
2020-06-10 18:21:34 +00:00
|
|
|
*
|
|
|
|
* @param {Object} props
|
|
|
|
* @param {CartItem|Object} props.lineItem
|
2020-02-26 15:49:07 +00:00
|
|
|
*/
|
2020-06-10 18:21:34 +00:00
|
|
|
const CartLineItemRow = ( { lineItem = {} } ) => {
|
2020-01-14 20:50:32 +00:00
|
|
|
const {
|
2020-03-17 15:34:33 +00:00
|
|
|
name = '',
|
2020-05-06 10:30:15 +00:00
|
|
|
short_description: shortDescription = '',
|
|
|
|
description: fullDescription = '',
|
2020-03-10 15:14:05 +00:00
|
|
|
low_stock_remaining: lowStockRemaining = null,
|
2020-07-14 15:25:53 +00:00
|
|
|
show_backorder_badge: showBackorderBadge = false,
|
2020-04-20 13:10:39 +00:00
|
|
|
quantity_limit: quantityLimit = 99,
|
2020-03-17 15:34:33 +00:00
|
|
|
permalink = '',
|
|
|
|
images = [],
|
|
|
|
variation = [],
|
|
|
|
prices = {
|
|
|
|
currency_code: 'USD',
|
|
|
|
currency_minor_unit: 2,
|
|
|
|
currency_symbol: '$',
|
|
|
|
currency_prefix: '$',
|
|
|
|
currency_suffix: '',
|
|
|
|
currency_decimal_separator: '.',
|
|
|
|
currency_thousand_separator: ',',
|
|
|
|
price: '0',
|
|
|
|
regular_price: '0',
|
|
|
|
sale_price: '0',
|
|
|
|
price_range: null,
|
|
|
|
raw_prices: {
|
|
|
|
precision: 6,
|
|
|
|
price: '0',
|
|
|
|
regular_price: '0',
|
|
|
|
sale_price: '0',
|
|
|
|
},
|
|
|
|
},
|
2020-01-14 20:50:32 +00:00
|
|
|
} = lineItem;
|
Cart block: line-items front end initial work (https://github.com/woocommerce/woocommerce-blocks/pull/1333)
* render block on front end, add `Shopping cart` heading (baby steps)
* fake data for editing full cart + show line count in header
* add note about core/html using `is-active` class for toggle state
* reinstate work-in-progress full cart component (lost in rebase)
* reinstate full cart from master
* component for full cart title & item count + margin tweaks:
- add margin between main cart & sidebar
- add margin after cart block
* add cart items sample data + factor sample product image to module
* use sample cart data for item count
* basic table of cart line items (no styling)
* prettification
* show images for cart line items + initial table styling
* cart quantity selector component (work in progress)
* use state for cart product quantity, allow incr/decr from UI (WIP)
* replace WIP custom quantity control with number edit (temporary)
* correctly format cart line item total price
* align cart item columns with headings + indent image on desktop
* tweak css for cart line item padding on mobile so it's more explicit
* show cart line item full price if discounted
* add placeholder for cart remove item link
* switch cart table to flex layout (was table)…
This will allow us to move things around for mobile/responsive layout.
* only show cart items table header on desktop
* more cart items styling - row borders, appropriate padding +
+ move image width to variable
+ fix class name plurality for row (item not items)
* use standard $gap instead of 1em for padding/margins
* responsive (mobile) layout for cart line items:
- shift line $ total to bottom right
- stack quantity selector in product info column
* remove extraneous cart table padding on mobile
* comment about unused styles for quantity selector component
* add follow up issue for todo
* remove inappropriate href
* render srcset & sizes for cart line item product image
* remove todo comment
* switch back to table markup for cart items (in progress):
- table is more semantic, associates headers with columns
* cart line items column widths - product column is larger (60%)
* reinstate table row borders
* bottom-align line item price on mobile
* cart contents heading should be H2 + prettify
* remove unused QuantitySelector code/styles, rename main class in line with BEM
* defaults for QuantitySelector props
* variable/property name tidies - match conventions/API
* fix bug: line total price is only bottom-align on small screen
* move QuantitySelector to root of components, intended to be generally useful
* use lineItem directly for cart, specify shape in PropTypes
* rename cart components to align with "line item" rather than "product"
* rejig class names to better align with new component names & BEM style
* show cart item image correct size:
- use single column for product image and info, with flex container
- specify image width (rem instead of px)
* fix safari issue - cart product images displaying vertically stretched
* shift product name left margin from image, to account for no-image case
* experiment: bump bundlewatch size limit for cart temporarily:
- our fake data inline image is heavy
- when we switch to real API we will no longer need it
* fix issue introduced when moving margin from image to details div:
- product details needs margin on left (not right)
* fix react props issues:
- explicitly destructure image props for srcSet (vs srcset)
- use API key field for line item key instead of id, fix duplicate test id
- CartLineItemsTable takes an array of lineItems (incorrect PropTypes)
* remove redundant divs + use conventional `null` (when no full price)
* override editor styles to ensure cart product image is correct size
* move cart items editor style override to editor.css
* add an explicit readable heading for cart heading to match visual layout
2020-01-09 22:50:14 +00:00
|
|
|
|
2020-03-03 01:08:19 +00:00
|
|
|
const {
|
2020-03-09 02:09:47 +00:00
|
|
|
quantity,
|
2020-03-03 01:08:19 +00:00
|
|
|
changeQuantity,
|
|
|
|
removeItem,
|
2020-04-07 11:03:22 +00:00
|
|
|
isPendingDelete,
|
2020-03-10 11:43:57 +00:00
|
|
|
} = useStoreCartItemQuantity( lineItem );
|
2020-02-28 02:05:10 +00:00
|
|
|
|
2020-03-10 11:43:57 +00:00
|
|
|
const currency = getCurrency( prices );
|
2020-03-17 15:34:33 +00:00
|
|
|
const regularAmount = Dinero( {
|
|
|
|
amount: parseInt( prices.raw_prices.regular_price, 10 ),
|
|
|
|
precision: parseInt( prices.raw_prices.precision, 10 ),
|
|
|
|
} ).multiply( quantity );
|
|
|
|
const purchaseAmount = Dinero( {
|
|
|
|
amount: parseInt( prices.raw_prices.price, 10 ),
|
|
|
|
precision: parseInt( prices.raw_prices.precision, 10 ),
|
|
|
|
} ).multiply( quantity );
|
|
|
|
const saleAmount = regularAmount.subtract( purchaseAmount );
|
2020-03-30 12:43:42 +00:00
|
|
|
const firstImage = images.length ? images[ 0 ] : {};
|
2020-03-09 02:09:47 +00:00
|
|
|
|
Cart block: line-items front end initial work (https://github.com/woocommerce/woocommerce-blocks/pull/1333)
* render block on front end, add `Shopping cart` heading (baby steps)
* fake data for editing full cart + show line count in header
* add note about core/html using `is-active` class for toggle state
* reinstate work-in-progress full cart component (lost in rebase)
* reinstate full cart from master
* component for full cart title & item count + margin tweaks:
- add margin between main cart & sidebar
- add margin after cart block
* add cart items sample data + factor sample product image to module
* use sample cart data for item count
* basic table of cart line items (no styling)
* prettification
* show images for cart line items + initial table styling
* cart quantity selector component (work in progress)
* use state for cart product quantity, allow incr/decr from UI (WIP)
* replace WIP custom quantity control with number edit (temporary)
* correctly format cart line item total price
* align cart item columns with headings + indent image on desktop
* tweak css for cart line item padding on mobile so it's more explicit
* show cart line item full price if discounted
* add placeholder for cart remove item link
* switch cart table to flex layout (was table)…
This will allow us to move things around for mobile/responsive layout.
* only show cart items table header on desktop
* more cart items styling - row borders, appropriate padding +
+ move image width to variable
+ fix class name plurality for row (item not items)
* use standard $gap instead of 1em for padding/margins
* responsive (mobile) layout for cart line items:
- shift line $ total to bottom right
- stack quantity selector in product info column
* remove extraneous cart table padding on mobile
* comment about unused styles for quantity selector component
* add follow up issue for todo
* remove inappropriate href
* render srcset & sizes for cart line item product image
* remove todo comment
* switch back to table markup for cart items (in progress):
- table is more semantic, associates headers with columns
* cart line items column widths - product column is larger (60%)
* reinstate table row borders
* bottom-align line item price on mobile
* cart contents heading should be H2 + prettify
* remove unused QuantitySelector code/styles, rename main class in line with BEM
* defaults for QuantitySelector props
* variable/property name tidies - match conventions/API
* fix bug: line total price is only bottom-align on small screen
* move QuantitySelector to root of components, intended to be generally useful
* use lineItem directly for cart, specify shape in PropTypes
* rename cart components to align with "line item" rather than "product"
* rejig class names to better align with new component names & BEM style
* show cart item image correct size:
- use single column for product image and info, with flex container
- specify image width (rem instead of px)
* fix safari issue - cart product images displaying vertically stretched
* shift product name left margin from image, to account for no-image case
* experiment: bump bundlewatch size limit for cart temporarily:
- our fake data inline image is heavy
- when we switch to real API we will no longer need it
* fix issue introduced when moving margin from image to details div:
- product details needs margin on left (not right)
* fix react props issues:
- explicitly destructure image props for srcSet (vs srcset)
- use API key field for line item key instead of id, fix duplicate test id
- CartLineItemsTable takes an array of lineItems (incorrect PropTypes)
* remove redundant divs + use conventional `null` (when no full price)
* override editor styles to ensure cart product image is correct size
* move cart items editor style override to editor.css
* add an explicit readable heading for cart heading to match visual layout
2020-01-09 22:50:14 +00:00
|
|
|
return (
|
2020-04-07 11:03:22 +00:00
|
|
|
<tr
|
|
|
|
className={ classnames( 'wc-block-cart-items__row', {
|
|
|
|
'is-disabled': isPendingDelete,
|
|
|
|
} ) }
|
|
|
|
>
|
2020-03-30 12:43:42 +00:00
|
|
|
{ /* If the image has no alt text, this link is unnecessary and can be hidden. */ }
|
|
|
|
<td
|
|
|
|
className="wc-block-cart-item__image"
|
|
|
|
aria-hidden={ ! firstImage.alt }
|
|
|
|
>
|
|
|
|
{ /* We don't need to make it focusable, because product name has the same link. */ }
|
|
|
|
<a href={ permalink } tabIndex={ -1 }>
|
|
|
|
<ProductImage image={ firstImage } />
|
2020-02-24 12:39:43 +00:00
|
|
|
</a>
|
2020-01-20 16:43:22 +00:00
|
|
|
</td>
|
Cart block: line-items front end initial work (https://github.com/woocommerce/woocommerce-blocks/pull/1333)
* render block on front end, add `Shopping cart` heading (baby steps)
* fake data for editing full cart + show line count in header
* add note about core/html using `is-active` class for toggle state
* reinstate work-in-progress full cart component (lost in rebase)
* reinstate full cart from master
* component for full cart title & item count + margin tweaks:
- add margin between main cart & sidebar
- add margin after cart block
* add cart items sample data + factor sample product image to module
* use sample cart data for item count
* basic table of cart line items (no styling)
* prettification
* show images for cart line items + initial table styling
* cart quantity selector component (work in progress)
* use state for cart product quantity, allow incr/decr from UI (WIP)
* replace WIP custom quantity control with number edit (temporary)
* correctly format cart line item total price
* align cart item columns with headings + indent image on desktop
* tweak css for cart line item padding on mobile so it's more explicit
* show cart line item full price if discounted
* add placeholder for cart remove item link
* switch cart table to flex layout (was table)…
This will allow us to move things around for mobile/responsive layout.
* only show cart items table header on desktop
* more cart items styling - row borders, appropriate padding +
+ move image width to variable
+ fix class name plurality for row (item not items)
* use standard $gap instead of 1em for padding/margins
* responsive (mobile) layout for cart line items:
- shift line $ total to bottom right
- stack quantity selector in product info column
* remove extraneous cart table padding on mobile
* comment about unused styles for quantity selector component
* add follow up issue for todo
* remove inappropriate href
* render srcset & sizes for cart line item product image
* remove todo comment
* switch back to table markup for cart items (in progress):
- table is more semantic, associates headers with columns
* cart line items column widths - product column is larger (60%)
* reinstate table row borders
* bottom-align line item price on mobile
* cart contents heading should be H2 + prettify
* remove unused QuantitySelector code/styles, rename main class in line with BEM
* defaults for QuantitySelector props
* variable/property name tidies - match conventions/API
* fix bug: line total price is only bottom-align on small screen
* move QuantitySelector to root of components, intended to be generally useful
* use lineItem directly for cart, specify shape in PropTypes
* rename cart components to align with "line item" rather than "product"
* rejig class names to better align with new component names & BEM style
* show cart item image correct size:
- use single column for product image and info, with flex container
- specify image width (rem instead of px)
* fix safari issue - cart product images displaying vertically stretched
* shift product name left margin from image, to account for no-image case
* experiment: bump bundlewatch size limit for cart temporarily:
- our fake data inline image is heavy
- when we switch to real API we will no longer need it
* fix issue introduced when moving margin from image to details div:
- product details needs margin on left (not right)
* fix react props issues:
- explicitly destructure image props for srcSet (vs srcset)
- use API key field for line item key instead of id, fix duplicate test id
- CartLineItemsTable takes an array of lineItems (incorrect PropTypes)
* remove redundant divs + use conventional `null` (when no full price)
* override editor styles to ensure cart product image is correct size
* move cart items editor style override to editor.css
* add an explicit readable heading for cart heading to match visual layout
2020-01-09 22:50:14 +00:00
|
|
|
<td className="wc-block-cart-item__product">
|
2020-04-07 11:03:22 +00:00
|
|
|
<ProductName
|
|
|
|
permalink={ permalink }
|
|
|
|
name={ name }
|
|
|
|
disabled={ isPendingDelete }
|
|
|
|
/>
|
2020-07-14 15:25:53 +00:00
|
|
|
{ showBackorderBadge ? (
|
|
|
|
<ProductBackorderBadge />
|
|
|
|
) : (
|
2020-07-21 15:41:14 +00:00
|
|
|
!! lowStockRemaining && (
|
2020-07-14 15:25:53 +00:00
|
|
|
<ProductLowStockBadge
|
|
|
|
lowStockRemaining={ lowStockRemaining }
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
) }
|
2020-05-06 10:30:15 +00:00
|
|
|
<ProductMetadata
|
|
|
|
shortDescription={ shortDescription }
|
|
|
|
fullDescription={ fullDescription }
|
|
|
|
variation={ variation }
|
|
|
|
/>
|
Cart block: line-items front end initial work (https://github.com/woocommerce/woocommerce-blocks/pull/1333)
* render block on front end, add `Shopping cart` heading (baby steps)
* fake data for editing full cart + show line count in header
* add note about core/html using `is-active` class for toggle state
* reinstate work-in-progress full cart component (lost in rebase)
* reinstate full cart from master
* component for full cart title & item count + margin tweaks:
- add margin between main cart & sidebar
- add margin after cart block
* add cart items sample data + factor sample product image to module
* use sample cart data for item count
* basic table of cart line items (no styling)
* prettification
* show images for cart line items + initial table styling
* cart quantity selector component (work in progress)
* use state for cart product quantity, allow incr/decr from UI (WIP)
* replace WIP custom quantity control with number edit (temporary)
* correctly format cart line item total price
* align cart item columns with headings + indent image on desktop
* tweak css for cart line item padding on mobile so it's more explicit
* show cart line item full price if discounted
* add placeholder for cart remove item link
* switch cart table to flex layout (was table)…
This will allow us to move things around for mobile/responsive layout.
* only show cart items table header on desktop
* more cart items styling - row borders, appropriate padding +
+ move image width to variable
+ fix class name plurality for row (item not items)
* use standard $gap instead of 1em for padding/margins
* responsive (mobile) layout for cart line items:
- shift line $ total to bottom right
- stack quantity selector in product info column
* remove extraneous cart table padding on mobile
* comment about unused styles for quantity selector component
* add follow up issue for todo
* remove inappropriate href
* render srcset & sizes for cart line item product image
* remove todo comment
* switch back to table markup for cart items (in progress):
- table is more semantic, associates headers with columns
* cart line items column widths - product column is larger (60%)
* reinstate table row borders
* bottom-align line item price on mobile
* cart contents heading should be H2 + prettify
* remove unused QuantitySelector code/styles, rename main class in line with BEM
* defaults for QuantitySelector props
* variable/property name tidies - match conventions/API
* fix bug: line total price is only bottom-align on small screen
* move QuantitySelector to root of components, intended to be generally useful
* use lineItem directly for cart, specify shape in PropTypes
* rename cart components to align with "line item" rather than "product"
* rejig class names to better align with new component names & BEM style
* show cart item image correct size:
- use single column for product image and info, with flex container
- specify image width (rem instead of px)
* fix safari issue - cart product images displaying vertically stretched
* shift product name left margin from image, to account for no-image case
* experiment: bump bundlewatch size limit for cart temporarily:
- our fake data inline image is heavy
- when we switch to real API we will no longer need it
* fix issue introduced when moving margin from image to details div:
- product details needs margin on left (not right)
* fix react props issues:
- explicitly destructure image props for srcSet (vs srcset)
- use API key field for line item key instead of id, fix duplicate test id
- CartLineItemsTable takes an array of lineItems (incorrect PropTypes)
* remove redundant divs + use conventional `null` (when no full price)
* override editor styles to ensure cart product image is correct size
* move cart items editor style override to editor.css
* add an explicit readable heading for cart heading to match visual layout
2020-01-09 22:50:14 +00:00
|
|
|
</td>
|
|
|
|
<td className="wc-block-cart-item__quantity">
|
2020-02-26 15:49:07 +00:00
|
|
|
<QuantitySelector
|
2020-04-07 11:03:22 +00:00
|
|
|
disabled={ isPendingDelete }
|
2020-03-03 01:08:19 +00:00
|
|
|
quantity={ quantity }
|
2020-04-20 13:10:39 +00:00
|
|
|
maximum={ quantityLimit }
|
2020-03-03 01:08:19 +00:00
|
|
|
onChange={ changeQuantity }
|
2020-02-26 15:49:07 +00:00
|
|
|
itemName={ name }
|
|
|
|
/>
|
2020-02-28 02:05:10 +00:00
|
|
|
<button
|
|
|
|
className="wc-block-cart-item__remove-link"
|
|
|
|
onClick={ removeItem }
|
2020-04-07 11:03:22 +00:00
|
|
|
disabled={ isPendingDelete }
|
2020-02-28 02:05:10 +00:00
|
|
|
>
|
2020-01-20 16:43:22 +00:00
|
|
|
{ __( 'Remove item', 'woo-gutenberg-products-block' ) }
|
|
|
|
</button>
|
2020-02-28 02:05:10 +00:00
|
|
|
<button
|
|
|
|
className="wc-block-cart-item__remove-icon"
|
|
|
|
onClick={ removeItem }
|
|
|
|
>
|
2020-04-24 13:11:14 +00:00
|
|
|
<span className="screen-reader-text">
|
|
|
|
{ __( 'Remove item', 'woo-gutenberg-products-block' ) }
|
|
|
|
</span>
|
2020-01-31 18:20:33 +00:00
|
|
|
<Icon srcElement={ trash } />
|
2020-01-17 13:46:56 +00:00
|
|
|
</button>
|
2020-01-20 16:43:22 +00:00
|
|
|
</td>
|
|
|
|
<td className="wc-block-cart-item__total">
|
2020-03-13 15:49:33 +00:00
|
|
|
<ProductPrice
|
2020-02-26 15:49:07 +00:00
|
|
|
currency={ currency }
|
2020-09-14 10:56:10 +00:00
|
|
|
regularPrice={ getAmountFromRawPrice(
|
2020-03-17 15:34:33 +00:00
|
|
|
regularAmount,
|
|
|
|
currency
|
|
|
|
) }
|
2020-09-14 10:56:10 +00:00
|
|
|
price={ getAmountFromRawPrice( purchaseAmount, currency ) }
|
2020-02-26 15:49:07 +00:00
|
|
|
/>
|
2020-03-13 15:49:33 +00:00
|
|
|
<ProductSaleBadge
|
|
|
|
currency={ currency }
|
2020-03-17 15:34:33 +00:00
|
|
|
saleAmount={ getAmountFromRawPrice( saleAmount, currency ) }
|
2020-03-13 15:49:33 +00:00
|
|
|
/>
|
Cart block: line-items front end initial work (https://github.com/woocommerce/woocommerce-blocks/pull/1333)
* render block on front end, add `Shopping cart` heading (baby steps)
* fake data for editing full cart + show line count in header
* add note about core/html using `is-active` class for toggle state
* reinstate work-in-progress full cart component (lost in rebase)
* reinstate full cart from master
* component for full cart title & item count + margin tweaks:
- add margin between main cart & sidebar
- add margin after cart block
* add cart items sample data + factor sample product image to module
* use sample cart data for item count
* basic table of cart line items (no styling)
* prettification
* show images for cart line items + initial table styling
* cart quantity selector component (work in progress)
* use state for cart product quantity, allow incr/decr from UI (WIP)
* replace WIP custom quantity control with number edit (temporary)
* correctly format cart line item total price
* align cart item columns with headings + indent image on desktop
* tweak css for cart line item padding on mobile so it's more explicit
* show cart line item full price if discounted
* add placeholder for cart remove item link
* switch cart table to flex layout (was table)…
This will allow us to move things around for mobile/responsive layout.
* only show cart items table header on desktop
* more cart items styling - row borders, appropriate padding +
+ move image width to variable
+ fix class name plurality for row (item not items)
* use standard $gap instead of 1em for padding/margins
* responsive (mobile) layout for cart line items:
- shift line $ total to bottom right
- stack quantity selector in product info column
* remove extraneous cart table padding on mobile
* comment about unused styles for quantity selector component
* add follow up issue for todo
* remove inappropriate href
* render srcset & sizes for cart line item product image
* remove todo comment
* switch back to table markup for cart items (in progress):
- table is more semantic, associates headers with columns
* cart line items column widths - product column is larger (60%)
* reinstate table row borders
* bottom-align line item price on mobile
* cart contents heading should be H2 + prettify
* remove unused QuantitySelector code/styles, rename main class in line with BEM
* defaults for QuantitySelector props
* variable/property name tidies - match conventions/API
* fix bug: line total price is only bottom-align on small screen
* move QuantitySelector to root of components, intended to be generally useful
* use lineItem directly for cart, specify shape in PropTypes
* rename cart components to align with "line item" rather than "product"
* rejig class names to better align with new component names & BEM style
* show cart item image correct size:
- use single column for product image and info, with flex container
- specify image width (rem instead of px)
* fix safari issue - cart product images displaying vertically stretched
* shift product name left margin from image, to account for no-image case
* experiment: bump bundlewatch size limit for cart temporarily:
- our fake data inline image is heavy
- when we switch to real API we will no longer need it
* fix issue introduced when moving margin from image to details div:
- product details needs margin on left (not right)
* fix react props issues:
- explicitly destructure image props for srcSet (vs srcset)
- use API key field for line item key instead of id, fix duplicate test id
- CartLineItemsTable takes an array of lineItems (incorrect PropTypes)
* remove redundant divs + use conventional `null` (when no full price)
* override editor styles to ensure cart product image is correct size
* move cart items editor style override to editor.css
* add an explicit readable heading for cart heading to match visual layout
2020-01-09 22:50:14 +00:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
CartLineItemRow.propTypes = {
|
2020-03-17 15:34:33 +00:00
|
|
|
lineItem: PropTypes.object,
|
Cart block: line-items front end initial work (https://github.com/woocommerce/woocommerce-blocks/pull/1333)
* render block on front end, add `Shopping cart` heading (baby steps)
* fake data for editing full cart + show line count in header
* add note about core/html using `is-active` class for toggle state
* reinstate work-in-progress full cart component (lost in rebase)
* reinstate full cart from master
* component for full cart title & item count + margin tweaks:
- add margin between main cart & sidebar
- add margin after cart block
* add cart items sample data + factor sample product image to module
* use sample cart data for item count
* basic table of cart line items (no styling)
* prettification
* show images for cart line items + initial table styling
* cart quantity selector component (work in progress)
* use state for cart product quantity, allow incr/decr from UI (WIP)
* replace WIP custom quantity control with number edit (temporary)
* correctly format cart line item total price
* align cart item columns with headings + indent image on desktop
* tweak css for cart line item padding on mobile so it's more explicit
* show cart line item full price if discounted
* add placeholder for cart remove item link
* switch cart table to flex layout (was table)…
This will allow us to move things around for mobile/responsive layout.
* only show cart items table header on desktop
* more cart items styling - row borders, appropriate padding +
+ move image width to variable
+ fix class name plurality for row (item not items)
* use standard $gap instead of 1em for padding/margins
* responsive (mobile) layout for cart line items:
- shift line $ total to bottom right
- stack quantity selector in product info column
* remove extraneous cart table padding on mobile
* comment about unused styles for quantity selector component
* add follow up issue for todo
* remove inappropriate href
* render srcset & sizes for cart line item product image
* remove todo comment
* switch back to table markup for cart items (in progress):
- table is more semantic, associates headers with columns
* cart line items column widths - product column is larger (60%)
* reinstate table row borders
* bottom-align line item price on mobile
* cart contents heading should be H2 + prettify
* remove unused QuantitySelector code/styles, rename main class in line with BEM
* defaults for QuantitySelector props
* variable/property name tidies - match conventions/API
* fix bug: line total price is only bottom-align on small screen
* move QuantitySelector to root of components, intended to be generally useful
* use lineItem directly for cart, specify shape in PropTypes
* rename cart components to align with "line item" rather than "product"
* rejig class names to better align with new component names & BEM style
* show cart item image correct size:
- use single column for product image and info, with flex container
- specify image width (rem instead of px)
* fix safari issue - cart product images displaying vertically stretched
* shift product name left margin from image, to account for no-image case
* experiment: bump bundlewatch size limit for cart temporarily:
- our fake data inline image is heavy
- when we switch to real API we will no longer need it
* fix issue introduced when moving margin from image to details div:
- product details needs margin on left (not right)
* fix react props issues:
- explicitly destructure image props for srcSet (vs srcset)
- use API key field for line item key instead of id, fix duplicate test id
- CartLineItemsTable takes an array of lineItems (incorrect PropTypes)
* remove redundant divs + use conventional `null` (when no full price)
* override editor styles to ensure cart product image is correct size
* move cart items editor style override to editor.css
* add an explicit readable heading for cart heading to match visual layout
2020-01-09 22:50:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default CartLineItemRow;
|