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-01-15 11:32:54 +00:00
import { __ , sprintf } from '@wordpress/i18n' ;
import { speak } from '@wordpress/a11y' ;
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 classNames from 'classnames' ;
2022-01-11 11:09:59 +00:00
import { useCallback , useLayoutEffect } from '@wordpress/element' ;
2020-01-15 11:32:54 +00:00
import { DOWN , UP } from '@wordpress/keycodes' ;
2022-01-11 11:09:59 +00:00
import { useDebouncedCallback } from 'use-debounce' ;
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
/ * *
* Internal dependencies
* /
import './style.scss' ;
2021-04-23 09:15:17 +00:00
2021-12-15 16:03:02 +00:00
export interface QuantitySelectorProps {
/ * *
* Component wrapper classname
*
* @default 'wc-block-components-quantity-selector'
* /
2021-04-23 09:15:17 +00:00
className? : string ;
2021-12-15 16:03:02 +00:00
/ * *
* Current quantity
* /
2021-04-23 09:15:17 +00:00
quantity? : number ;
2021-12-15 16:03:02 +00:00
/ * *
* Minimum quantity
* /
2021-04-23 09:15:17 +00:00
minimum? : number ;
2021-12-15 16:03:02 +00:00
/ * *
* Maximum quantity
* /
2021-04-23 09:15:17 +00:00
maximum : number ;
2022-01-11 11:09:59 +00:00
/ * *
* Input step attribute .
* /
step? : number ;
2021-12-15 16:03:02 +00:00
/ * *
* Event handler triggered when the quantity is changed
* /
2021-04-23 09:15:17 +00:00
onChange : ( newQuantity : number ) = > void ;
2021-12-15 16:03:02 +00:00
/ * *
* Name of the item the quantity selector refers to
*
* Used for a11y purposes
* /
2021-04-23 09:15:17 +00:00
itemName? : string ;
2021-12-15 16:03:02 +00:00
/ * *
* Whether the component should be interactable or not
* /
2021-04-23 09:15:17 +00:00
disabled : boolean ;
}
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
const QuantitySelector = ( {
className ,
quantity = 1 ,
2020-03-03 01:08:19 +00:00
minimum = 1 ,
maximum ,
2021-12-15 16:03:02 +00:00
onChange = ( ) = > void 0 ,
2022-01-11 11:09:59 +00:00
step = 1 ,
2020-01-15 11:32:54 +00:00
itemName = '' ,
2020-02-27 20:52:18 +00:00
disabled ,
2021-04-23 09:15:17 +00:00
} : QuantitySelectorProps ) : JSX . Element = > {
2020-06-17 09:53:42 +00:00
const classes = classNames (
'wc-block-components-quantity-selector' ,
className
) ;
2020-01-15 11:32:54 +00:00
2020-03-03 01:08:19 +00:00
const hasMaximum = typeof maximum !== 'undefined' ;
2022-01-11 11:09:59 +00:00
const canDecrease = quantity - step >= minimum ;
const canIncrease = ! hasMaximum || quantity + step <= maximum ;
/ * *
* The goal of this function is to normalize what was inserted ,
* but after the customer has stopped typing .
* /
const normalizeQuantity = useCallback (
( initialValue : number ) = > {
// We copy the starting value.
let value = initialValue ;
// We check if we have a maximum value, and select the lowest between what was inserted and the maximum.
if ( hasMaximum ) {
value = Math . min (
value ,
// the maximum possible value in step increments.
Math . floor ( maximum / step ) * step
) ;
}
// Select the biggest between what's inserted, the the minimum value in steps.
value = Math . max ( value , Math . ceil ( minimum / step ) * step ) ;
// We round off the value to our steps.
value = Math . floor ( value / step ) * step ;
// Only commit if the value has changed
if ( value !== initialValue ) {
onChange ( value ) ;
}
} ,
[ hasMaximum , maximum , minimum , onChange , step ]
) ;
/ *
* It ' s important to wait before normalizing or we end up with
* a frustrating experience , for example , if the minimum is 2 and
* the customer is trying to type "10" , premature normalizing would
* always kick in at "1" and turn that into 2 .
* /
const debouncedNormalizeQuantity = useDebouncedCallback (
normalizeQuantity ,
// This value is deliberately smaller than what's in useStoreCartItemQuantity so we don't end up with two requests.
300
) ;
/ * *
* Normalize qty on mount before render .
* /
useLayoutEffect ( ( ) = > {
normalizeQuantity ( quantity ) ;
} , [ quantity , normalizeQuantity ] ) ;
2020-01-15 11:32:54 +00:00
/ * *
* Handles keyboard up and down keys to change quantity value .
*
* @param { Object } event event data .
* /
const quantityInputOnKeyDown = useCallback (
( event ) = > {
const isArrowDown =
typeof event . key !== undefined
? event . key === 'ArrowDown'
: event . keyCode === DOWN ;
const isArrowUp =
typeof event . key !== undefined
? event . key === 'ArrowUp'
: event . keyCode === UP ;
2020-03-03 01:08:19 +00:00
if ( isArrowDown && canDecrease ) {
2020-01-15 11:32:54 +00:00
event . preventDefault ( ) ;
2022-01-11 11:09:59 +00:00
onChange ( quantity - step ) ;
2020-01-15 11:32:54 +00:00
}
2020-03-03 01:08:19 +00:00
if ( isArrowUp && canIncrease ) {
2020-01-15 11:32:54 +00:00
event . preventDefault ( ) ;
2022-01-11 11:09:59 +00:00
onChange ( quantity + step ) ;
2020-01-15 11:32:54 +00:00
}
} ,
2022-01-11 11:09:59 +00:00
[ quantity , onChange , canIncrease , canDecrease , step ]
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-01-15 11:32:54 +00:00
< div className = { classes } >
< input
2020-06-17 09:53:42 +00:00
className = "wc-block-components-quantity-selector__input"
2020-02-27 20:52:18 +00:00
disabled = { disabled }
2020-01-15 11:32:54 +00:00
type = "number"
2022-01-11 11:09:59 +00:00
step = { step }
min = { minimum }
max = { maximum }
2020-01-15 11:32:54 +00:00
value = { quantity }
onKeyDown = { quantityInputOnKeyDown }
onChange = { ( event ) = > {
2022-01-11 11:09:59 +00:00
// Inputs values are strings, we parse them here.
let value = parseInt ( event . target . value , 10 ) ;
// parseInt would throw NaN for anything not a number,
// so we revert value to the quantity value.
value = isNaN ( value ) ? quantity : value ;
2020-03-03 01:08:19 +00:00
if ( value !== quantity ) {
2022-01-11 11:09:59 +00:00
// we commit this value immediately.
2020-03-03 01:08:19 +00:00
onChange ( value ) ;
2022-01-11 11:09:59 +00:00
// but once the customer has stopped typing, we make sure his value is respecting the bounds (maximum value, minimum value, step value), and commit the normalized value.
debouncedNormalizeQuantity ( value ) ;
2020-03-03 01:08:19 +00:00
}
2020-01-15 11:32:54 +00:00
} }
aria - label = { sprintf (
2021-02-19 11:58:44 +00:00
/* translators: %s refers to the item name in the cart. */
2020-01-15 11:32:54 +00:00
__ (
'Quantity of %s in your cart.' ,
'woo-gutenberg-products-block'
) ,
itemName
) }
/ >
< button
aria - label = { __ (
'Reduce quantity' ,
'woo-gutenberg-products-block'
) }
2020-06-17 09:53:42 +00:00
className = "wc-block-components-quantity-selector__button wc-block-components-quantity-selector__button--minus"
2020-03-03 01:08:19 +00:00
disabled = { disabled || ! canDecrease }
2020-01-15 11:32:54 +00:00
onClick = { ( ) = > {
2022-01-11 11:09:59 +00:00
const newQuantity = quantity - step ;
2020-03-03 01:08:19 +00:00
onChange ( newQuantity ) ;
2020-01-15 11:32:54 +00:00
speak (
sprintf (
2021-02-19 11:58:44 +00:00
/* translators: %s refers to the item name in the cart. */
2020-01-15 11:32:54 +00:00
__ (
'Quantity reduced to %s.' ,
'woo-gutenberg-products-block'
) ,
newQuantity
)
) ;
2022-01-11 11:09:59 +00:00
normalizeQuantity ( newQuantity ) ;
2020-01-15 11:32:54 +00:00
} }
>
& # 65293 ;
< / button >
< button
aria - label = { __ (
'Increase quantity' ,
'woo-gutenberg-products-block'
) }
2020-03-03 01:08:19 +00:00
disabled = { disabled || ! canIncrease }
2020-06-17 09:53:42 +00:00
className = "wc-block-components-quantity-selector__button wc-block-components-quantity-selector__button--plus"
2020-01-15 11:32:54 +00:00
onClick = { ( ) = > {
2022-01-11 11:09:59 +00:00
const newQuantity = quantity + step ;
2020-03-03 01:08:19 +00:00
onChange ( newQuantity ) ;
2020-01-15 11:32:54 +00:00
speak (
sprintf (
2021-02-19 11:58:44 +00:00
/* translators: %s refers to the item name in the cart. */
2020-01-15 11:32:54 +00:00
__ (
'Quantity increased to %s.' ,
'woo-gutenberg-products-block'
) ,
newQuantity
)
) ;
2022-01-11 11:09:59 +00:00
normalizeQuantity ( newQuantity ) ;
2020-01-15 11:32:54 +00:00
} }
>
& # 65291 ;
< / button >
< / div >
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 QuantitySelector ;