Commit Graph

1011 Commits

Author SHA1 Message Date
Albert Juhé Lluveras b5497147d5 Fix long product names regression (https://github.com/woocommerce/woocommerce-blocks/pull/2391) 2020-05-04 17:15:32 +02:00
Darren Ethier 88e397154d Add Todo Probot config (https://github.com/woocommerce/woocommerce-blocks/pull/2384)
* Add todo bot config

* tweak todo comment to test
2020-05-02 15:56:33 -04:00
Darren Ethier 1e917f5a54 Ensure stripe payment request "canMakePayment" configuration uses site country. (https://github.com/woocommerce/woocommerce-blocks/pull/2372)
* export baseLocation for `@woocommerce/settings`

* implement country code from site base location instead of cart shipping country
2020-05-01 07:24:28 -04:00
Mike Jolley bf8cff6f50 Rename the discount section when discount total is zero (https://github.com/woocommerce/woocommerce-blocks/pull/2367)
* Rename the discount section when discount total is zero

* Cleanup variable naming
2020-05-01 10:59:27 +01:00
Mike Jolley a3ca37bade Change when innerblocks are rendered (https://github.com/woocommerce/woocommerce-blocks/pull/2366) 2020-05-01 10:33:55 +01:00
Mike Jolley 5a39df880f Fix summary styles and margins/padding woocommerce/woocommerce-blocks#2340 (https://github.com/woocommerce/woocommerce-blocks/pull/2368) 2020-05-01 10:31:09 +01:00
Rua Haszard be968c9103 only show checkout login prompt if store allows it (https://github.com/woocommerce/woocommerce-blocks/pull/2364) 2020-04-30 13:54:43 +01:00
Albert Juhé Lluveras 9e7623567e Make all font sizes accessible + add docs about font-size() mixin (https://github.com/woocommerce/woocommerce-blocks/pull/2291)
* Switch all font-sizes to use the mixin

* Add notice in coding-guidelines to use accessible font sizes

* Fix label alignment in forms with big font-sizes

* Fix Stripe input boxes font-size not being responsive

* Fix select overflowing in small font sizes

* Add rem function from woocommerce/woocommerce-blocks#2320

* Make the font-size() mixin set relative line-height values

* Convert several magic numbers to use the new mixins

* Update docs

* Update input/select paddings to use the rem mixin

* Add lineHeight comment

* Interpolate rem() mixin inside calc

* Make input padding use only relative units
2020-04-30 12:18:12 +02:00
Mike Jolley 1fd0fa79a9 Payment methods `placeOrderButtonLabel` config (https://github.com/woocommerce/woocommerce-blocks/pull/2362)
* Add payment method configs

* Remove submitLabel

* Enhance useCheckoutSubmit to handle button text

* copy paste error
2020-04-30 10:52:36 +01:00
Mike Jolley 6df5903e0f Checkout Block Order Summary Styles (https://github.com/woocommerce/woocommerce-blocks/pull/2355)
* Update checkout styles

* remove item prices from summary
2020-04-30 10:51:08 +01:00
Albert Juhé Lluveras 2593c711ad Fix payment method error notices issues (https://github.com/woocommerce/woocommerce-blocks/pull/2352)
* Prevent payment method errors appearing twice. Fixes woocommerce/woocommerce-blocks#2327

* Remove payment method errors on submit. Fixes woocommerce/woocommerce-blocks#2217

* Simplify useEffect dependencies

* Pass context name to removeNotice
2020-04-30 11:43:56 +02:00
Albert Juhé Lluveras fce0e2d71c Fix Cart block interaction in the editor (mobile) (https://github.com/woocommerce/woocommerce-blocks/pull/2354)
* Prevent SnackbarList from loading in the editor

* Fix snackbar styles leaking into the editor

* Prevent 'Proceed to Checkout' button being fixed to the bottom in the editor
2020-04-29 17:45:29 +02:00
Mike Jolley 8424934149 Update API status codes (https://github.com/woocommerce/woocommerce-blocks/pull/2353)
* Update HTTP status codes

* Catch JSON parsing errors.
2020-04-29 15:47:05 +01:00
Rua Haszard 7abe9dffb3 align cart main heading and totals sidebar heading: (https://github.com/woocommerce/woocommerce-blocks/pull/2346)
- set appropriate padding for main cart container
- card padding is currently provided by Gutenberg component (?)
- overriding padding on totals card to match main container
2020-04-29 13:35:42 +01:00
Mike Jolley 95809b30bb Update payment method config to include icons (https://github.com/woocommerce/woocommerce-blocks/pull/2267)
* Remove strong and cleanup existing configs

* Fix TS validation for blocks-registry

* Allow label to be string

* Split up button and icons for cart

* Make icons and payment methods available on cart page

* Fix payment method enqueuing

* Icon normalization and Stripe implementation

* PayPal Icon

* adjust spacing

* Fix string handling

* Remove paypal icon config

* Check for an object before creating icon

* Add payment icons to Stripe label

* Update common-icons.js

* Update Cart.php

* Update jest.config.json
2020-04-29 11:57:58 +01:00
Albert Juhé Lluveras 60cf16a334 Fix low stock badge not breaking in a new line (https://github.com/woocommerce/woocommerce-blocks/pull/2348) 2020-04-29 12:57:04 +02:00
Darren Ethier 58abb408c2 make sure we import from external not direct files (https://github.com/woocommerce/woocommerce-blocks/pull/2330) 2020-04-29 11:20:52 +01:00
Rua Haszard 1b596b94dc Quantity badge white separator + center tweak (https://github.com/woocommerce/woocommerce-blocks/pull/2347)
* add extra white border to quantity badge

* nudge checkout quantity badge so it's roughly centered with image corner
2020-04-29 10:22:12 +01:00
Mike Jolley ad93ddd891 Add PayPal Standard (https://github.com/woocommerce/woocommerce-blocks/pull/2288)
* Add paypal files

* Add PayPal Icon/resolve feedback
2020-04-28 11:13:48 +01:00
Seghir Nadir 476ae5dcd5 remove order note (https://github.com/woocommerce/woocommerce-blocks/pull/2318) 2020-04-28 11:07:05 +01:00
Seghir Nadir 797ded1efc Add notice errors to add to cart button and All products (https://github.com/woocommerce/woocommerce-blocks/pull/2278)
* expose errors when adding to cart

* clear notices

* make notice dismissible

* decode entities
2020-04-27 17:24:54 +01:00
Mike Jolley e85b6fe9a9 Inject block attributes rather than save them (https://github.com/woocommerce/woocommerce-blocks/pull/2273)
* Inject attributes rather than saving them

* Update snaps
2020-04-27 12:06:58 -04:00
Mike Jolley e5589727fc Support itemized taxes (https://github.com/woocommerce/woocommerce-blocks/pull/2276) 2020-04-24 14:44:44 +01:00
Mike Jolley 8bf58b4596 Trigger fragment refresh after editing cart item quantities (https://github.com/woocommerce/woocommerce-blocks/pull/2266)
* Make util to fire legacy events

* Update button to use util

* Trigger event when quantity changes

* Trigger event on removal

* Move comments to util
2020-04-24 14:41:32 +01:00
Mike Jolley 7f85c1bcc0 Migrate REST API usage to the Store API (https://github.com/woocommerce/woocommerce-blocks/pull/2282)
* Remove unused wc/blocks/cart endpoint

* remove unused withProducts hoc

* Remove getProducts util

* Use store API products endpoint in product blocks

* Remove product endpoint tests

* Remove controller

* Switch attributes endpoint to store api

* Refactor withAttributes to use store API

* Migrate tags and cats to store API

* MIgrate variations to store api

* Migrate reviews to store API

* Drop dedicated variation endpoint

* Move tests

* Move cart init

* Fix reviews

* Comment out broken tests

* Remove old class based with-attributes test
2020-04-24 14:36:47 +01:00
Albert Juhé Lluveras 72c7b38022 Add screen reader text to remove item icon (https://github.com/woocommerce/woocommerce-blocks/pull/2285) 2020-04-24 15:11:14 +02:00
Albert Juhé Lluveras 96e8ccf1a4 Cart & Checkout: Update styles to better match designs (https://github.com/woocommerce/woocommerce-blocks/pull/2283)
* Add ending dot to sentence

* Open links to products from Cart and Checkut blocks in new tabs

* Makes sure product names are broken if they overflow the container

* Use native find instead of lodash method

* Update styles to better match designs

* Revert "Open links to products from Cart and Checkut blocks in new tabs"

This reverts commit 9b64aa5f2e81bf0cf09d5640a3cfe1cc1085c046.

* Fix product name overflowing remove menu on mobile

* Remove @todo comments from form step CSS

* Make letter-spacinguse em instead of px

* IE11: Correctly align text in quantity selector

* Fix long product names overflowing in Checkout block on IE11
2020-04-24 13:23:25 +01:00
Seghir Nadir 7863a99de7 Abstract Page selector and fix some issues in sidebar. (https://github.com/woocommerce/woocommerce-blocks/pull/2270)
* abstract pageSelector to its own component and fix titles

* fix unwrapped context

* move control styles outside editor-wrapper

* restore condition to previous state

* move condition outisde

* rename condition

* keep pageSelect visible till next refresh

* remove comment
2020-04-22 17:44:12 +01:00
Mike Jolley 5a2ee88905 Fixes to totals recalculation and taxes (https://github.com/woocommerce/woocommerce-blocks/pull/2275)
* Hide tax totals row when taxes are disabled in core

* Trigger recalcs if hash changes

* move recalc until later on in rest call

* Unused class
2020-04-22 14:16:17 +01:00
Albert Juhé Lluveras 7fa4b76c52 Prevent All Products block from crashing when error has no json method (https://github.com/woocommerce/woocommerce-blocks/pull/2269) 2020-04-22 12:09:20 +02:00
Mike Jolley db145deb70 Decode billing address from server (https://github.com/woocommerce/woocommerce-blocks/pull/2268) 2020-04-21 15:24:04 +01:00
Mike Jolley 880d4e19b4 Decode entities in cart shipping data (https://github.com/woocommerce/woocommerce-blocks/pull/2265) 2020-04-21 14:43:49 +01:00
Mike Jolley d0d0cfc565 Checkout: Rename address2 attribute (https://github.com/woocommerce/woocommerce-blocks/pull/2264)
* Rename address2 attribute

* Update snap
2020-04-21 11:51:11 +01:00
Darren Ethier 493a826e44 modify emitters so it handles non object or invalid object responses correctly. (https://github.com/woocommerce/woocommerce-blocks/pull/2249)
With these changes:

- If an observer returns an object wthout a type property an error is thrown and the emitter is aborted with an error type response.
- For anything else returned from an observer, it’s discarded.

Tests are updated for the new expectations
2020-04-21 04:33:16 +02:00
Seghir Nadir a005649ab8 Move blocks to stable flag (https://github.com/woocommerce/woocommerce-blocks/pull/2261)
* remove feature flag

* catch blocks.ini error
2020-04-20 15:55:59 +01:00
Seghir Nadir 2e9b21ef8a Fix snackbar being too high and covering coupon section (https://github.com/woocommerce/woocommerce-blocks/pull/2255)
* fix snackbar issue

* fix some styles
2020-04-20 14:23:44 +01:00
Mike Jolley 248c552baf Add quantity limit at product level (https://github.com/woocommerce/woocommerce-blocks/pull/2256)
* Add quantity limit at product level

* Stock checks only needed when backorders are disabled

* Use remaining stock, not stock qty in messages etc

* Prevent duplicate validation from core
2020-04-20 14:10:39 +01:00
Albert Juhé Lluveras 1b2e8dd435 Do not scroll to top when payment methods have an error (https://github.com/woocommerce/woocommerce-blocks/pull/2247)
* Do not scroll to top when payment methods emit an error

* Simplify code and add check for hasValidationErrors
2020-04-20 11:11:32 +01:00
Darren Ethier 580015827a remove obsolete @todo 2020-04-17 17:00:43 -04:00
Mike Jolley 5b142b58ed Coupon and Cart Item Validation Fixes (https://github.com/woocommerce/woocommerce-blocks/pull/2245)
* Move validation calls to checkout API class

* Validate before payment

* Support additional error data

* Add coupon validation before payment, and hide hashes from user

* Implement validation and recalculation

* Abstract notice handler and implement legacy filters

* Handle generic cart item errors

* strip tags from coupon error messages woocommerce/woocommerce-blocks#2212

* Ensure item errors are surfaced when coupons are removed

* Fix wrong value passed to hook

* fix broken checkout when no payment method is there

* try fixing unit test errors

* if preview data has a receiveCart function use it, otherwise default to an anononymous function

* fix tests

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-04-17 21:18:54 +01:00
Darren Ethier 0a98037606 Add documentation for checkout flow and payment method integrations (https://github.com/woocommerce/woocommerce-blocks/pull/2246)
* add documentation for checkotu flow and payment method integrations

* Update docs/block-client-apis/README.md

Co-Authored-By: Mike Jolley <mike.jolley@me.com>

* Update docs/block-client-apis/README.md

Co-Authored-By: Mike Jolley <mike.jolley@me.com>

* Update docs/block-client-apis/checkout/checkout-api.md

Co-Authored-By: Mike Jolley <mike.jolley@me.com>

* standardize around capitalized API

* Remove extra dash.

Co-Authored-By: Mike Jolley <mike.jolley@me.com>

* Update docs/block-client-apis/checkout/checkout-api.md

Co-Authored-By: Mike Jolley <mike.jolley@me.com>

* Update docs/block-client-apis/checkout/checkout-api.md

Co-Authored-By: Mike Jolley <mike.jolley@me.com>

* Update docs/block-client-apis/checkout/checkout-api.md

Co-Authored-By: Mike Jolley <mike.jolley@me.com>

* remove 1st person narrative

* various other grammar fixes

* add table of contents to docs

Co-authored-by: Mike Jolley <mike.jolley@me.com>
2020-04-17 11:37:09 -04:00
Darren Ethier a8c2a015b4 use noticeContext properties for notice area (https://github.com/woocommerce/woocommerce-blocks/pull/2241) 2020-04-17 10:39:24 +01:00
Mike Jolley 990949b302 Improve "sold individually" validation (https://github.com/woocommerce/woocommerce-blocks/pull/2234)
* API - Block qty > 1 for sold individually products

* Add item validation for sold individually to block checkout

* Fix validation check

* Add client side limit if sold individually

* Prevent never ending loading on failed add to cart

* Change cart button for sold individually errors
2020-04-17 10:24:44 +01:00
Seghir Nadir 2dfb8365de create a notice instead of throwing an errors (https://github.com/woocommerce/woocommerce-blocks/pull/2203) 2020-04-16 16:08:23 +01:00
Mike Jolley 216a7fc1bf Capture legacy payment notices (https://github.com/woocommerce/woocommerce-blocks/pull/2238)
* Convert woo notices into exceptions when processing legacy payments

* Prevent console errors when a message is not returned in the response

* include top level message property to capture REST error messages

* include capturing rest error messages on afterProcessing action

* clear notices before exception

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-04-16 15:39:46 +01:00
Mike Jolley 21f75b61b0 Show feedback on buttons/checkout when processing (https://github.com/woocommerce/woocommerce-blocks/pull/2186)
* Allow buttons to show loading spinners

* Show spinner on cart checkout button press

* Disable fieldsets when processing

* Check icon when finished

* Style tweak to fix height

* Update events

* feedback

* Move button back
2020-04-15 17:09:15 +01:00
Darren Ethier 0501328902 Fix global validation error reporting and cheque payment method regressions (https://github.com/woocommerce/woocommerce-blocks/pull/2232)
* fix broken validation error handling after submit

* Add handling for when there are no observers for payment processing or all observers just return true.

* cheque no longer needs to hook into event emitter

* account for no data on complete status handling in reducer

* add handling for either no observers or all observers returning true for onAfterProcessingWithSuccess emitter
2020-04-15 11:43:03 -04:00
Albert Juhé Lluveras d5232c9903 Handle errors when loading payment methods (https://github.com/woocommerce/woocommerce-blocks/pull/2228)
* Handle errors when loading payment methods

* Use an error boundary

* Fix missing initial state in block error boundary

* Cleanup

* Only show internal user messages if it's admin or in editor

* Fixes

* Add friendly error message
2020-04-15 17:15:56 +02:00
Mike Jolley ceaae16d23 Fix entities in coupon validation error messages (https://github.com/woocommerce/woocommerce-blocks/pull/2179)
* decodeEntities in error messages

* Add unslash to coupon field

* Decode when receiving error
2020-04-15 09:59:01 +02:00
Rua Haszard ace2d2bd81 show preview "saved payment methods" in editor (https://github.com/woocommerce/woocommerce-blocks/pull/2151)
* factor out editor preview data for saved payment methods to previews

* add missing imports lost in rebase

* use editorcontext to provide preview data to payment method context

* remove unused `activePaymentMethod` prop in CheckoutProvider and PaymentMethodDataProvider

* don't set the preview saved card as the default

* fix js error with cart in editor - fix EditorContext, pass previewData:
- editor context preview prop has changed;
  - update cart to pass { previewCart } in previewData prop
- correctly destructure cart from previewData in useStoreCart hook
- correct typedefs
  - EditorProvider props.previewData - now just Object
  - similar for EditorDataContext
- correct default for activePaymentMethod state - empty string as before

* preselect 'use a new payment method' in checkout block editor preview

* update unit tests for changes to editor context
2020-04-15 12:05:01 +12:00
Darren Ethier 6069b9b90a Lazy load stripe.js and preserve payment method registration order. (https://github.com/woocommerce/woocommerce-blocks/pull/2214)
* remove stripe.js registration because it is lazy loaded via the library used.

* refactor payment method registration to preserve registration order.

* register payment method asset handles as dependency on editor script as well.
2020-04-14 18:44:31 -04:00
Darren Ethier 5850966894 Refactor checkout status and event emitters to support stripe intents and more complex payment methods. (https://github.com/woocommerce/woocommerce-blocks/pull/2189)
* initial mapping out of stripe payment intents

* rename checkout processing statuses to be clearer

* Add new status and refactor checkout complete behaviour.

* Make sure payment result data is included in checkout processing response

* add payment intent handling

Still testing

* make sure promise is returned

* include site url with endpoint

* modify setComplete status to optionally receive redirectUrl for changing in state at the same time as setting status

* fix typo in property retrieval

* add error handling for after checkout processing event

* add notices area for payment methods

* implement error handling for stripe intents

* hook into stripe error processing and include error in payment response

* clear notices so they don’t show in block and merge payment details

* add notice handling to payment context

* modify error processing in checkout processor

* handle errors with fallback in checkout state context

* hook into after processing for stripe cc error handling

* set checkout to idle status if before processing emitters result in error

* Add emit response type-defs and normalize expectations for observer responses

* improve doc block

* switch checkoutIsComplete check to checkoutAfterProcessing for payment complete status change

* remove unneeded event emitters and consolidate some logic

* fix idle status set logic
2020-04-14 12:52:23 -04:00
Albert Juhé Lluveras 923eef90ee Fix build styles incosistencies (https://github.com/woocommerce/woocommerce-blocks/pull/2208)
* Prevent select label/value breaking in two lines

* Make sure frontend and base styles are loaded in the same order

* Use link-button mixin for address button

* Refactor shipping rates control CSS to decrease specificity and overwrites

* Refactor sidebar panel CSS to decrease specificity and overwrites

* Fix link-button vertical-align
2020-04-14 13:43:10 +02:00
Seghir Nadir 32b80c40bb respect SHIPPING_ENABLED in Cart and Checkout blocks (https://github.com/woocommerce/woocommerce-blocks/pull/2202) 2020-04-14 08:01:59 +02:00
Darren Ethier 70f8b48165 implement editor previews for stripe cc and check payment methods (https://github.com/woocommerce/woocommerce-blocks/pull/2190) 2020-04-14 08:01:29 +02:00
Seghir Nadir a00d06b7f2 Use icons directly from stripe (https://github.com/woocommerce/woocommerce-blocks/pull/2188)
* use icons from stripe

* rename classes

* use object instead of array

* update jsdocs
2020-04-09 15:31:03 -04:00
Albert Juhé Lluveras c035a578a8 Fix currency format in On Sale badge (https://github.com/woocommerce/woocommerce-blocks/pull/2185)
* Fix currency format in On Sale badge

* Add back translators comment

* Use self-closing tag
2020-04-09 18:53:22 +02:00
Albert Juhé Lluveras 0663ac7f6f Prevent auto-scroll to invalid fields (https://github.com/woocommerce/woocommerce-blocks/pull/2184) 2020-04-09 18:42:53 +02:00
Darren Ethier e21883d69c Refactor logic for handling active payment method with express payment methods via checkout (https://github.com/woocommerce/woocommerce-blocks/pull/2170)
* remove logic server side for getting payment method from paymentdata

* ensure stripe accounts for payment request type payment methods

* make sure legacy payment method handling always runs last

* add processedPaymentMethodId to payment method data context state

* switch checkout processor to use new processedPaymentMethod id for submission

* implement returning paymentMethodId from payment-request-express

* include paymentMethodId in stripe cc success return value

* include paymentMethodId in cheque success return value

* add active payment method setting and handling via checkout

express payment methods still need to implement:

- onClick when their button is clicked
- onClose when the express payment interface is closed (cancelled etc).

* don’t expose setActivePaymentMethod on the payment method interface

* remove/fix artifacts from earlier iterations of the pull

* rename `id` property to `name` property for payment method registration

* Revert "include paymentMethodId in cheque success return value"

This reverts commit fe4ee8aced6d67bbd9033263ce61844349d18250.

* Revert "include paymentMethodId in stripe cc success return value"

This reverts commit 359a1f0089866110ec204182f8ffa14ab099c425.

* Revert "implement returning paymentMethodId from payment-request-express"

This reverts commit 117c68980b0876dee0acc78cec7754ccfe2a9bb1.

* Revert "switch checkout processor to use new processedPaymentMethod id for submission"

This reverts commit c38a05b63626dfc1336c7bb0e86417b798a803d6.

* Revert "add processedPaymentMethodId to payment method data context state"

This reverts commit 3d7923e7297f3c76efde536d26eaf68464ba9583.

* improve isSuccess response check and variable name

* implement paymentMethodId config option

* doh php ain’t javascript

* add missing dependency from rebase
2020-04-09 11:22:34 -04:00
Seghir Nadir 9e1adb7ea8 fix broken labels on twentyTwenty (https://github.com/woocommerce/woocommerce-blocks/pull/2181) 2020-04-09 15:26:16 +01:00
Albert Juhé Lluveras 93764f9f89 Check if cart needs payment before showing payment methods (https://github.com/woocommerce/woocommerce-blocks/pull/2177)
* Check if cart needs payment before showing payment methods

* Fix tests
2020-04-09 16:01:11 +02:00
Mike Jolley c02a7cb115 Update cart after conflicts (https://github.com/woocommerce/woocommerce-blocks/pull/2175)
* Return updated cart if there is a conflict (409 response) e.g. item no longer exists

* Receive updated carts

* Update tests and coupon handling

* Further rewording
2020-04-09 13:52:31 +01:00
Albert Juhé Lluveras fed597e5c8 Fix prices overflowing in some widths in the Order summary panel (https://github.com/woocommerce/woocommerce-blocks/pull/2178) 2020-04-09 13:50:00 +01:00
Darren Ethier 12b384374b Use cart data to provide country and currency_code for payment method registration config (https://github.com/woocommerce/woocommerce-blocks/pull/2169)
* use cart data to provide country and currency_code

* remove files that likely got added back in from a bad rebase.

* modify canMakePayment config property so it must be a function

* Feed cart data to registered payment methods `canMakePayment` function.

This can then be used by payment methods for determining whether to show the payment method or not.

* implement new canMakePayment signature for cheque

Now canMakePayment doesn’t need to be a promise (payment method registry will handle wrapping all values in a promise to treat them as promises.

* implement canMakePayment as a function
2020-04-09 07:44:29 -04:00
Darren Ethier d79f5ab271 Convert apple pay integration to payment request integration and finish implementation (https://github.com/woocommerce/woocommerce-blocks/pull/2127)
* add logic allowing payment method to be overridden via payment data in request

* hook in to trigger server side processing of stripe payment request

* improvements to shipping data context

- memoize event emitters
- split up emitted events (reduces how often events trigger)
- Include whether rate is being selected in exported data.

* expose `isSelectingRate` value to payment method interface

* fix typo in shipping emitters for emitter type

* include setting of shipping data in payment method success status call

- this also requires changing the nested order of providers in checkout provider

* fix priority logic for event emitters.

- lower priority is supposed to fire before higher priority.

* normalize postal code for comparisons

* move normalize functions into stripe-utils folder

* refactor stripePromise so that it provides a specific instance to each payment method.

This also provides it as a prop to the pm components.

* renadme apple pay express to payment request express

This adds full support for the stripe payment request api instead of just applePay (so GooglePay, MicrosoftPay and ApplePay are now supported).

Also adds numerous fixes to internal logic.

* add handling to skip core checkout validation logic if express payment method is handling payment

Express payment methods have their own internal validation so this removes the need for checkout validating fields. This is also necessary because checkout validation breaks the flow when making a payment using express payment methods because of the order of the flow for these methods.

* splitting out emmitter effects for checkout and improving logic

Splitting up effects limits the potential for firing off emitters more than needed.

* remove unnecessary ref definitions

* fix on cancel action erroring for payment request modal

* ensure unique stripe object for component and canPay

* set default total label if one isn’t configured on the server

* fix order of state changes

* simplify condition

* remove unnecessary dependency

* normalize to uppercase too

* simplify can make payment conditional

* update comment blocks
2020-04-08 12:36:04 -04:00
Darren Ethier bfdfa2f603 Move calculating state outside of checkout state (https://github.com/woocommerce/woocommerce-blocks/pull/2163)
* remove calculating as a checkout status (making it separate)

* include checkout is calculating for determining whether to flip payment status to process

* only change payment method state for status changes if needed

* fix reducer for shipping state

* include checkoutIsCalculating for determining whether to show validation errors in checkout block

* change where currentStatus is defined

* fix bug with saved payment method option
2020-04-08 11:46:34 -04:00
Albert Juhé Lluveras 10851a4e00 Handle errors in processOrder (https://github.com/woocommerce/woocommerce-blocks/pull/2156)
* Handle errors in processOrder

* Move scroll to top handler higher so error notices are visible

* Improve error messaging
2020-04-08 17:29:48 +02:00
Mike Jolley 4a8609737d Increase specificity of wc-block-totals__change-address-button (https://github.com/woocommerce/woocommerce-blocks/pull/2162) 2020-04-08 17:23:17 +02:00
Mike Jolley 55d0067426 Update previews and editor styles for cart and checkout blocks (https://github.com/woocommerce/woocommerce-blocks/pull/2160)
* Update cart block editor styles to more closely match frontend

* Checkout editor styles

* Add image assets for previews and correct totals

* Add new previews

* Cart Preview

* Checkout preview

* Remove optional chaining
2020-04-08 16:03:39 +01:00
Mike Jolley d73d9ca12e Refactor some of the shipping hooks/context usage (https://github.com/woocommerce/woocommerce-blocks/pull/2146)
* Counting helpers for shipping rates and packages

* Use new helpers

* Make shipping calculator use shipping context directly

* Totals should use current address

* Avoid useShippingRates

* Return rates and other items from useShippingRatse in useStoreCart instead

* Update tests

* Merge conflict

* Merge conflict
2020-04-08 12:20:41 +01:00
Albert Juhé Lluveras db4f7820c6 Use new util functions in ShippingRatesControl (https://github.com/woocommerce/woocommerce-blocks/pull/2153)
* Use new util functions in ShippingRatesControl

* Import from base-utils
2020-04-08 11:19:05 +01:00
Mike Jolley 0000cac384 Don't show "select" labels for shipping or payment method steps if there is only one option (https://github.com/woocommerce/woocommerce-blocks/pull/2133)
* Only show descriptions if shipping/payment methods > 1

* Hide descriptions if no description text is set

* Fix object length

* methods->options

* Counting helpers for shipping rates and packages

* Use new helpers
2020-04-08 10:00:31 +02:00
Rua Haszard 0b956e1a4f Revert "show a "preview" saved card in the editor (first cut!)"
This reverts commit f409908eda.

(Accidental push to master)
2020-04-08 12:12:00 +12:00
Rua Haszard f409908eda show a "preview" saved card in the editor (first cut!) 2020-04-08 12:04:23 +12:00
Seghir Nadir 736d437316 Get preview data from Editor Context / (https://github.com/woocommerce/woocommerce-blocks/pull/2134)
* move preview to editor data and alias it no nothing in frontend builds

* seperate context and provider

* pass previewData as a prop to provider

* address comments
2020-04-07 16:41:22 +01:00
Albert Juhé Lluveras 5bcdc8f84a CheckboxControl: stop using Gutenberg's CheckboxControl (https://github.com/woocommerce/woocommerce-blocks/pull/2137)
* CheckboxControl: stop using Gutenberg's CheckboxControl

* Simplify styles and make them work fine in the editor
2020-04-07 16:37:03 +01:00
Mike Jolley 8ae3e1d195 Show "save payment information" checkbox only if customer ID > 0 (https://github.com/woocommerce/woocommerce-blocks/pull/2138)
* Add customer ID to checkout API response

* Add customer ID to checkout context

* Show/hide remember payment checkbox based on checkout context

* Pass via payment interface instead

* Missing commas
2020-04-07 15:29:59 +01:00
Seghir Nadir 5160d9d794 Disable continue to checkout if Item quantity is being updated and immediately remove items. (https://github.com/woocommerce/woocommerce-blocks/pull/2106)
* disable continue to checkout if item is being removed

* rename isPending and selectors/actions to isPendingDelete

* switch itemPendingDelete params order

* change to watching quantity changes not removal

* yield RECEIVE_REMOVED_ITEM

* update types and add return to select

* update tests

* switch params back

* only delete item after response from server

* update tests

* handle errors and unrelated unmounts

* disable row if is loading
2020-04-07 12:03:22 +01:00
Rua Haszard 3f0dcf00bc Revert "Record a tracks event when merchant toggles cart shipping calculator: (https://github.com/woocommerce/woocommerce-blocks/pull/1975)" (https://github.com/woocommerce/woocommerce-blocks/pull/2136)
This reverts commit 7921c3e5ba.
2020-04-07 12:11:14 +02:00
Albert Juhé Lluveras 8c7d4805a4 Show validation errors again (https://github.com/woocommerce/woocommerce-blocks/pull/2124)
* Make validation errors appear

* Make validation errors appear all at once

* Simplify diff

* Expose shippingErrorStatus from shipping context

* Memoize currentErrorStatus

* Pass currentErrorStatus to observers

* Add missing type-def property

* Fix typo in constant name

* Refactor emitEvent so false responses don't return true

* Make onCheckoutProcessing observers return errorMessage and validationErrors properties
2020-04-06 16:36:19 -04:00
Seghir Nadir 0ca78dd654 Remove Keep me updated (https://github.com/woocommerce/woocommerce-blocks/pull/2057)
* remove checkbox of keep me updated

* remove double margin on useSameForBilling
2020-04-06 16:57:38 +01:00
Mike Jolley 5d2a630a07 Use mousedown event so view switches before blur event prevents the switch (https://github.com/woocommerce/woocommerce-blocks/pull/2129) 2020-04-06 16:36:03 +01:00
Mike Jolley cc3ed31feb Disable checkout form in the editor (https://github.com/woocommerce/woocommerce-blocks/pull/2128)
* Move no-shipping-placeholder to block - allow pointer events

* Allow payments placeholder to have pointer events

* Enable pointer events for children

* Wrap checkout with disabled
2020-04-06 16:35:09 +01:00
Darren Ethier 22ea154c6f Implement stripe server-side handling (stripe cc) (https://github.com/woocommerce/woocommerce-blocks/pull/2120)
* remove usage of paymentstatus dispatcher from apple pay

* add type-def for payment data response objects

* make sure shape of payment data for stripe cc is as server expects

* include payment data in checkout processor request

* fix bug that got reintroduced in rebase

* rename typedef
2020-04-06 08:44:00 -04:00
Darren Ethier d108e5ea96 Update stripe payment methods to work with new event emitters (https://github.com/woocommerce/woocommerce-blocks/pull/2115)
* Add interface for setting an express payment error notice.

* fix typedefs

* remove usage of paymentstatus dispatcher from stripe cc

* remove usage of paymentstatus dispatcher from apple pay

* remove any existing express payment notice on click

* revert buggy change with abort payment call

- also ensure that completePayment sets applePayProcessing to false
2020-04-06 08:18:35 -04:00
Mike Jolley 3ac335e1f9 Storefront compatibility for sticky proceed to checkout button on mobile (https://github.com/woocommerce/woocommerce-blocks/pull/1999)
* Storefront compatibility

* Remove storefront actions
2020-04-06 07:50:33 -04:00
Darren Ethier 4baa99cf65 Refactor payment method interface to remove payment status dispatcher (https://github.com/woocommerce/woocommerce-blocks/pull/2116)
* don’t expose payment method status dispatcher on payment method interface

* update apple-pay-express to use new currentPaymetnStatus object shape
2020-04-06 07:28:46 -04:00
Mike Jolley d637c28d62 Update add to cart to useStoreCart hook (https://github.com/woocommerce/woocommerce-blocks/pull/2103)
* Switch add to cart events to useStoreCart hook

* Add to cart endpoint

* Inject dependenct schemas

* Feedback, cart items are based on product schema

* Variable typo

* Move hook to base

* Update totals correcrly

* Update tests to use schema/routes class

* Update tests to correctly use schema

* Remove type hint to prevent strict standards error
2020-04-06 11:36:28 +01:00
Darren Ethier 4f990fd475 switch from event subscription to status watch (https://github.com/woocommerce/woocommerce-blocks/pull/2119) 2020-04-04 13:36:46 -04:00
Albert Juhé Lluveras 72801baf97 Switch 'Try reloading the page' from links to buttons (https://github.com/woocommerce/woocommerce-blocks/pull/2105)
* Switch 'Reload page' from links to buttons

* Rename class to wp-block-link-button

* Remove no longer needed CSS property
2020-04-03 15:22:56 +02:00
Albert Juhé Lluveras 8a78371703 Checkout: fix skeleton and responsive styles (https://github.com/woocommerce/woocommerce-blocks/pull/2109) 2020-04-03 14:17:09 +01:00
Darren Ethier 30fb8bef28 Fix flaw with event emitters and complete checkout flow for the cheque payment method. (https://github.com/woocommerce/woocommerce-blocks/pull/2108)
* Allow for priority to be set on event emitters

* Add payment event emitters

* add new actions/status to checkout state context

* implement event emitters in payment data context

* refactor checkout state context to use new actions in event emitters

* refactor checkout processor to handle new event emitters

* fix type-defs for registered payment methods

* register observer for cheque payment method integration

* add inline todo

* fix sort

* fix tests and add test for priority usage in event emitters

* remove todo and just add explanatory comment

* condense sort logic

* lowercase test description

* abstract emitter callback to reduce code

* don’t process passed in errors if it’s undefined

* improve error response expectation for payment processing event observer
2020-04-03 07:50:54 -04:00
Seghir Nadir c361a158c4 Respect needs_shipping in Cart and Checkout (https://github.com/woocommerce/woocommerce-blocks/pull/2101)
* replace SHIPPING_ENABLED with needsShipping

* rename needsShipping variable

* only show shipping in checkout sidebar if we need shipping
2020-04-02 18:10:36 +01:00
Seghir Nadir cede3a0acf disable proceed to checkout if rates are loading or being selected (https://github.com/woocommerce/woocommerce-blocks/pull/1978)
* disable proceed to checkout if isCalculating is true

* add checkout provider

* remove unnecessary duplicate checkout count increment/decrement.

* remove redudant checkoutProvider

* remove already handled todo

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-04-02 18:05:08 +01:00
Mike Jolley f0b4be8bc8 Add Payment Methods Registry for registering scripts and data (https://github.com/woocommerce/woocommerce-blocks/pull/2090)
* Added cheque gateway and payment method registration system

Fix promises

Remove log

Use status, not checkoutstate

Bug @nerrad showed me

Payment method type registry

Refactor integrations to register themselves.

Stripe and Cheque Integrations/registration

Splt gateways into separate files on build

Add settings from server to cheque gateway

Merge apple and credit card stripe scripts

* Missing files from rebase

* Tweaks to payment-methods-registry (https://github.com/woocommerce/woocommerce-blocks/pull/2091)

* Small tweaks and docblock updates

* Handle undefined settings

* rebase fix

* Simplify promise

* Remove filesuffix for payment methods config

* Fix typo

* Rebase fix

* Update cart and block actions

* Add woocommerce_blocks_payment_method_type_registration

* Missing method names

* Missing name in stripe

* replace actions with script dependencies

* Scripts are needed in admin context too, by default

* Put back the hooks...

* Add is_active check to see if assets need to be enqueued or not

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-04-02 18:04:15 +01:00
Mike Jolley 8468869319 Cart item validation and notices in cart/checkout (https://github.com/woocommerce/woocommerce-blocks/pull/2079)
* Add error handling to cart API

* Handle new error codes in checkout

* Display errors in cart

* Fix failing test

* Move error codes to constants
2020-04-02 15:04:43 +01:00
Albert Juhé Lluveras 73d1432b02 Hook up checkout validation with context (https://github.com/woocommerce/woocommerce-blocks/pull/2033)
* Hook up checkout validation with context

* Make sure hasValidationErrors is up to date in onCheckoutProcessing

* Move validation check inside CheckoutProcessor's processCheckout

* Make sure all checkout form fields have a unique ID

* Don't clear checkout context errors in shipping context

* Move CheckoutProcessor to the top so scrollToTop works

* Do not disable Place Order Button if there are errors

* Split checkValidation and processCheckout in Checkout Provider

* Refactor event emitter to use Maps

* Save payment method errors to validation context

* Show an notice when a payment method has an error

* Make sure JS errors during payment are displayed

* Remove error notice when payment method doesn't return an error anymore

* Make sure payment methods know if shipping and billing addresses are the same

* Make sure checkout is only processed if payment methods didn't fail

* Make sure state input also has an id

* Clear input and select errors on unmount

* Pass id to CountryInput and StateInput

* Fix function name

* Add missing default context values

* Move onCheckoutCompleteError effect to CheckoutBlock

* Remove conditional from shipping setHasError
2020-04-02 11:27:54 +02:00
Darren Ethier b0370b44b9 split up payment-methods.js file into smaller bits (https://github.com/woocommerce/woocommerce-blocks/pull/2089)
- adds more inline docs
- improves/adds more type-defs
2020-04-01 10:58:50 -04:00
Darren Ethier 2d53b2ace1 Refactor checkout context provider to be more flexible and implement CartProvider (https://github.com/woocommerce/woocommerce-blocks/pull/2083)
* Rename and move existing checkout provider to checkout-state provider.

This allows us to re-use the interface exposed on this provider for cart and checkout blocks.

* refactor checkout provider to implement the new checkout state provider.

* Add Cart provider and export

* fix type-defs

* fix editor context provider and ensure all `isEditor` checks come from this provider

* fix type definition

* implement cart provider
2020-04-01 05:27:53 -04:00
Darren Ethier df851aaff3 refactor checkout error status dispatcher (https://github.com/woocommerce/woocommerce-blocks/pull/2082)
- setHasError now receives a boolean that determines what state to set.
- remove clearError dispatcher
- fix related type-defs in checkout context.
2020-03-31 15:28:36 -04:00
Mike Jolley 9b0f545398 Parse error response before rejecting (https://github.com/woocommerce/woocommerce-blocks/pull/2080) 2020-03-31 17:00:03 +01:00
Darren Ethier d3fdc4b358 Finish wiring up shipping data context provider and add disabled state to checkout submit button (https://github.com/woocommerce/woocommerce-blocks/pull/2070)
* add selecting rate resolution state to the cart store

* expose whether rate is being selected on useSelectShippingRate

* Cleanup and refactor ShippingDataProvider

- remove un-needed component and move shipping rates into context provider
- remove error handling (currently the ui/ux for the checkout should result in no errors and any api errors are non-recoverable).
- Add logic for shipping rate selection into context provider and add event emitters for it.
- increment/decrement checkout calculation counts when shipping rates are being selected.

* dispatch checkout error if there is an error

* disable place order button if checkout is calculating or has error

* update doc block

* fix convention for js comment blocks
2020-03-31 11:40:27 -04:00
Albert Juhé Lluveras 8bac7b8264 Fix minor Stripe payment method issues (https://github.com/woocommerce/woocommerce-blocks/pull/2078)
* Fix params mismatch in Stripe

* Wrap Strip onSubmit with a try/catch block

* Fix createSource signature
2020-03-31 15:21:54 +02:00
Seghir Nadir 0046b73bbf delete passed arg to useShippingRates since it's not needed 2020-03-31 13:22:41 +01:00
Mike Jolley 61a5b7b132 Add checkout error state (https://github.com/woocommerce/woocommerce-blocks/pull/2069)
* Add checkout error state

* Update message wording and icon
2020-03-31 11:47:48 +01:00
Albert Juhé Lluveras 140bdc39d0 Add tests to some cart and checkout hooks (https://github.com/woocommerce/woocommerce-blocks/pull/2013) 2020-03-30 20:32:28 +02:00
Mike Jolley 2bca9840c6 Checkout processing and order creation APIs (https://github.com/woocommerce/woocommerce-blocks/pull/2044)
* CheckoutProcessing work

add missing memoization and implement useRef strategically

This prevents effects from firing unnecessarily.

Tweak assets registration

Order hydration and checkout/ endpoint updates

Fix error handling

Error handling

* Missing isset in stripe

* Fedeback

* rename draft order ID action

* Todos
2020-03-30 15:32:23 +01:00
Albert Juhé Lluveras 5e78c47e4d Move some base components to subfolders (https://github.com/woocommerce/woocommerce-blocks/pull/2034) 2020-03-30 15:04:27 +02:00
Albert Juhé Lluveras e6f6dc9915 Cart and Checkout accessibility fixes (https://github.com/woocommerce/woocommerce-blocks/pull/2041)
* Make Product Price component accessible

* Render checkout form step number before the content instead of after

* Announce changes in the Shipping Rates Control results

* Render product name before product price in the Checkout sidebar

* Verify error element id exists before using it in describedBy

* Avoid reading 'Choose a shipping method' if no shipping methods are available

* Hide product image from screen readers if there is no alt text and make link not focusable

* Move Checkout block buttons below the sidebar

* Simplify selector

* Remove ternary to make code easier to understand

* Fix rebase issue

* Fix step number not visible for payment methods
2020-03-30 14:43:42 +02:00
Darren Ethier fb3cae67e6 Implement Stripe CC and Stripe ApplePay payment methods (https://github.com/woocommerce/woocommerce-blocks/pull/1983)
* Server side changes for payment method integrations

Including adding a stripe class temporarily

* update needed npm packages (and add some types)

* updates to contexts

* remove stepContent from payment config for payment methods

* update payment method interface and typedefs

Exposing a components property to pass along components that payment methods can use (so we keep styles consistent for them)

* add apple pay and stripe cc integration and remove paypal

* remove save payment checkbox from checkout block

It is handled by payment methods.

* Include an id prop for tabs

* fix activePaymentMethod pass through on rendered payment method element

also adds an id for the rendered tab

* add styles for payment method fields

If payment methods use these classes for their fields then the styles will get applied. It _could_ allow for consistent styling, we may have to provide design documentation for this?

These are styles in cases where payment methods have to use elements provided by the gateway (eg. Stripe elements). In future iterations we could look at providing components to payment methods to use (if they aren’t restricted by the gateway).

* fix rebase conflict

* do a test payment request for applePay to determine if the current browser supports it

* don’t console.error for stripe loading.

* Fix placeholder errors in the editor

* improve styling and add missing validation for inline card element

* update pacakge-lock

* rename payment-methods-demo folder to payment-methods-extension

* expose checkbox control on payment method interface

* export payment-methods-extension to it’s own asset build

This allows us to more accurately demonstrate how payment extensions would hook in to the blocks.

* don’t enqueue a style that doesn’t exist

* add full stop to comments and remove obsolete comment blcok

* fix spacing

* switch `activeContent` to `content` for payment method registration config
2020-03-30 08:07:49 -04:00
Darren Ethier 1648e651b4 Fix build issues for production builds (https://github.com/woocommerce/woocommerce-blocks/pull/2042)
* add payment-methods-demo config to sideEffects and install @wordpress/icons and @wordpress/primitives to be used directly.

* configure dependency extraction to ignore imports we want to use directly

* fix style issues for production builds

It looks like when a style is imported on the entrypoint of a component (or in a file with just exports), it get’s treeshaken from the final build _regardless of exception rules_.

* fix style imports from wordpress components

* fix loading skeleton showing on production builds

* fix block skeleton showing on production builds for cart

* import side effectful code

* add treatment for `@wordpress/warning` too

* fix typo

* exclude `settings/block` from sideEffects

* rollback `wordpress-components` update and keep sideEffects fixes

* remove unnecessary handle handling

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
2020-03-27 16:56:48 -04:00
Albert Juhé Lluveras 86215d064d Shipping data context: replace address state with useShippingAddress() (https://github.com/woocommerce/woocommerce-blocks/pull/2037)
* Shipping data context: replace address state with useShippingAddress()

* Move External dependencies to the top

* Remove unnecessary useCallback
2020-03-27 12:14:32 +01:00
Mike Jolley 6d0ee74157 Add billing data context (https://github.com/woocommerce/woocommerce-blocks/pull/2027)
* Checkout class tidyup

* CheckoutProcessor placeholder

* ShippingMethodDataX to ShippingDataX

* Remove billing from checkout provider

* Remove billing data hook

* Remove billing from payment methods state

* Update typedefs

* Billing context

* Fix billing and shipping context persistence bugs

* Remove address form change

* Move phone back; another PR can deal with this

* Remove unused state
2020-03-26 13:31:09 +00:00
Seghir Nadir f3af7f7dfe fix rates not updating if you change coupon (https://github.com/woocommerce/woocommerce-blocks/pull/2026) 2020-03-26 13:43:11 +01:00
Seghir Nadir 06d4042567 Reinitialise useSelectShippingRate when rates change. (https://github.com/woocommerce/woocommerce-blocks/pull/2012)
* reinitilize the selected shipping rate

* useMemo instead of usePrevious
2020-03-26 13:40:56 +01:00
Albert Juhé Lluveras 4b80ef79ef Fix blocks not being added in WP <= 5.2 (https://github.com/woocommerce/woocommerce-blocks/pull/2001)
* Only update grid default attributes on WP >= 5.3

* Use @wordpress/compose from external in Reviews sort-select

* Import withInstanceId from external only on legacy builds

* FallbackModule: add extensions to paths if it's missing

* Use path package to extract path extension

* Make all components import from the base withInstanceId HOC
2020-03-26 13:39:54 +01:00
Albert Juhé Lluveras 7bcf1eb5df Add URL to feedback prompt (https://github.com/woocommerce/woocommerce-blocks/pull/2028) 2020-03-26 12:02:45 +00:00
Darren Ethier 690f61ec93 Move payment method registration state to payment data context and add saved payment methods handling (https://github.com/woocommerce/woocommerce-blocks/pull/2029)
* Add saved-payment-method options handling and improve payment method registration initialization

* add server side exposure of saved customer payment methods

* fix reducer for express payment method state

* fix default for customerPaymentMethods
2020-03-26 07:11:46 -04:00
Rua Haszard 7921c3e5ba Record a tracks event when merchant toggles cart shipping calculator: (https://github.com/woocommerce/woocommerce-blocks/pull/1975)
* record a tracks event when merchant toggles cart shipping calculator:
- add tracks utility func for blocks
  - adds standard event name prefix
  - supplies post id & type params (an example)
- hook this up to UI when user toggles shipping calc
- pass enabled as boolean prop

* fix typo - call isTracksAvailable() !

* remove unnecessary temporary boolean

* update event name based on best practice guidelines

* remove isTracksAvailable preflight check:
- if site opts out, recordEvent is an empty function
- add in standard fallback boilerplate to ensure function exists
Note: currently no mechanism to detect if tracks is available on front end.
2020-03-26 10:12:34 +13:00
Seghir Nadir 4d1b99491d fix weird print in editor (https://github.com/woocommerce/woocommerce-blocks/pull/2024) 2020-03-25 16:39:39 +00:00
Albert Juhé Lluveras b67e5a5f10 Fix 'Show Sorting Dropdown' attribute ignored in All Products block (https://github.com/woocommerce/woocommerce-blocks/pull/2019)
* Fix 'Show Sorting Dropdown' attribute ignored in All Products block

* Update snapshot
2020-03-25 12:19:24 +01:00
Albert Juhé Lluveras c7e20c29d9 Decode address entities in shipping calculator (https://github.com/woocommerce/woocommerce-blocks/pull/2009)
* Fix wrong optional label for city

* Decode all address entities in shipping calculator

* Move decodeEntities to useShippingRates

* Move decodeEntities to useShippingAddress
2020-03-24 11:28:19 +01:00
Seghir Nadir 2ba75fdc25 Refactor useBillingData to useCheckoutContext and hooking it up to form (https://github.com/woocommerce/woocommerce-blocks/pull/2002)
* Add line pricing for cart items in the API (https://github.com/woocommerce/woocommerce-blocks/pull/1979)

* Add line pricing for cart items

* Update checkout linePrice

* Fix tests

* Update schema - add dinero

* Implement dinero in cart totals

* Update preview and remove line totals

* Update package lock

* Update checkout review

* Fix preview and default data shapes

* return first and last name in shipping address

* remove shippingAsBilling option from editor settings

* remove billing data from store

* move to context

* hook billing to hook and sync with shipping

* add email to billingData

* hydrate billing data

* some refactors

* move hydrated billing data to reducer initial state and fix stale dependencies

* fix stale useCallback

* better checks in php types

* get isEditor from context

* update typedefs

* skip state update if nothing changed

* fix rebase

* update snapshots

* rebase package

* wrap setEmail in useCallback

* remove ValidationContextProvider

* fix docs

Co-authored-by: Mike Jolley <mike.jolley@me.com>
2020-03-23 21:13:41 +01:00
Darren Ethier 1d210e184b Fix event-emitters not accounting for observers as Object type. (https://github.com/woocommerce/woocommerce-blocks/pull/2010)
* Fix assumption of eventemitters stored in state as an arry.

* update tests to mock expected emitter state
2020-03-23 11:32:52 -04:00
Albert Juhé Lluveras 2593fcf7da Add Checkout form validation (https://github.com/woocommerce/woocommerce-blocks/pull/1993)
* Add Checkout form validation

* Add back validation when filling the address without having set a country

* Split TextInput and Select so they can be used with or without validation

* Cleanup

* Only display the missing country error if city, state or postcode are entered

* Fix CSS specificity conflict

* Remove unnecessary semicolon

* Rename areThereValidationErrors to hasValidationErrors
2020-03-23 12:22:00 +01:00
Mike Jolley 8abad3ad04 Add no payment methods placeholder (https://github.com/woocommerce/woocommerce-blocks/pull/1998)
* Update tabs and payment methods component classnames to meet standards

* Tidied up logic and added NoPaymentMethods placeholder

* Consistent "NO" placeholders

* frontend notices

* comments

* Update assets/js/base/components/payment-methods/no-payment-methods/style.scss

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* Address feedback

* Moar bundle size

* Another notice

* Tweak text

Co-authored-by: Albert Juhé Lluveras <aljullu@gmail.com>
2020-03-20 12:48:11 -04:00
Darren Ethier e4a82aa1ce Convert emitters to promise (https://github.com/woocommerce/woocommerce-blocks/pull/2003)
* restructure event-emit directory and convert emitters to promises

- also add emitEventWithAbort function

* implement event emitters as promises

* clean up logic

- return from for loop
- define response as const on each iteration.
- return true if loop completes successfully.

* rename event_emit folder to event-emit
2020-03-20 12:46:24 -04:00
Mike Jolley 8ca9fc9b6f Update empty states (https://github.com/woocommerce/woocommerce-blocks/pull/1996)
* Add empty state template

* Checkout empty state

* Update other icons

* Blank alt
2020-03-19 15:50:36 +00:00
Mike Jolley 2ff854e212 Add nonces to Store API endpoints (https://github.com/woocommerce/woocommerce-blocks/pull/1992)
* Disable authentication for the Store API completely.

This may also resolve woocommerce/woocommerce-blocks#1991

* Add nonce handling to the abstract route

* Default state

* Add shared controls including nonce api fetch

* Use shared controls

* Hydrate inital nonce

* Update data stores

* Update nonce validation

* Fix tests by setting nonces

* Remove print_r debug

* Revert useStoreCart change

* Add nonce middleware

Co-Authored-By: Darren Ethier <darren@roughsmootheng.in>

* Switch back to apiFetchWithHeaders

* Docs

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-03-19 11:50:51 +00:00
Mike Jolley cba3b9712f Add checkout skeleton whilst loading (https://github.com/woocommerce/woocommerce-blocks/pull/1995)
* Add checkout skeleton as loading state and remove placeholder text from save method

* Hide skeleton when not loading

* add loading class

* Update snap
2020-03-19 10:39:04 +00:00
Mike Jolley dadebfebbc Add line pricing for cart items in the API (https://github.com/woocommerce/woocommerce-blocks/pull/1979)
* Add line pricing for cart items

* Update checkout linePrice

* Fix tests

* Update schema - add dinero

* Implement dinero in cart totals

* Update preview and remove line totals

* Update package lock

* Update checkout review

* Fix preview and default data shapes
2020-03-17 15:34:33 +00:00
Mike Jolley 84b4a24bfa Use correct count from useStoreCart/API (https://github.com/woocommerce/woocommerce-blocks/pull/1980)
* Use correct count from useStoreCart/API

* Correct preview data counts

* Missing var from rebase
2020-03-17 12:11:30 +00:00
Darren Ethier ad4c981793 Add validation context provider and implement validation for shipping country and coupons. (https://github.com/woocommerce/woocommerce-blocks/pull/1972)
* add errormessage handling to countryinput (along with storybook)

* add types for react

* Add validation context and implement

* implement validation context for country field validation

* tweak ValidationInputError so that it can receive property name for getting error from

* improve storybook webpack config to pull from tsconfig.json

* update storybook story to cover changes with context

* Wrap Checkout Provider with Validation Context Provider

* add screen-reader-text style to storybook

* add styles for input error validation to text input

* improve styling for ValidationInputError component

* add validation error handling to TotalsCouponCode component

And story

* make sure errors are cleared on successful receive/remove item

* dispatch loading cancellation on catching errors

This is needed because loading would be cancelled before the error is thrown so any error handling after the thrown error will not be able to rely on loading.

* implement validation setting for coupon errors

* add error color to labels on inputs too

* fix borders back and force border color

* remove extra structure and improve validation error with alignment for coupon code

* add aria-describedby for text inputs

* add back in validation context provider to fix rebase issue

* rework validation so it works for both checkout and cart

* Some styling tweaks

* more style fixes

* remove unnecessary method

* make sure new function is included in context defaults

* package.lock update? seems harmless so rolling with it.
2020-03-17 12:45:33 +01:00
Mike Jolley bd6c7f657c Configure link for the proceed to checkout button (https://github.com/woocommerce/woocommerce-blocks/pull/1981)
* Add link for proceed to checkout button

* Fixes to indenting/types

* Update snaps

* Update notice
2020-03-17 10:30:52 +00:00
Darren Ethier cdfb457341 Add snackbar notices to notices system and implement for coupon ui/ux (https://github.com/woocommerce/woocommerce-blocks/pull/1973)
* add snackbarnotices to notices system

* implement snackbar notices for coupon code ui

* improve styles with mobile styles as well

* some more css fixes

* use native filter

* remove usage of lodash filter and dont’ output container if there are no regular notices

* remove unnecessary duplication of styles

- load default snackbar styles from WordPress components
- override for frontend to make them fixed to the window (including mobile treatement).

* simplify css class generation (save some bytes)

* improve proptypes definition

h/t: @aljullu

* consistent style handle name

* increase bundle size budget
2020-03-16 16:57:12 -04:00
Mike Jolley 01602f90bf Implement "return to cart" and "place order" buttons on checkout (https://github.com/woocommerce/woocommerce-blocks/pull/1926)
* Add back icon

* Add cart URL constant

* Add button components

* Implement button components into checkout

* Update checkout styles to match mockup incl updates to margins and padding

* Add options to control return to cart link

* Use checkout context

* Update snapshot

* Update context

* href

* Color/arrow styling

* Implement select instead of open URL field

* Add notice and updated settings control

* Show notice conditonally

* Store permalinks to avoid extra API requests, and get pages via API

* Update snapshots

* Fix double layout conflict

* Switch back to ID and add permalink via block setting

* snaps

* Fix snapshot; add default shape for pages

* Feedback

* Better undefined handling

* Update assets/js/blocks/cart-checkout/checkout/block.js

Co-Authored-By: Darren Ethier <darren@roughsmootheng.in>

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-03-16 16:38:24 +00:00
Seghir Nadir 3e7a2d41e4 disable coupon button if the field is empty (https://github.com/woocommerce/woocommerce-blocks/pull/1977) 2020-03-16 14:15:35 +01:00
Albert Juhé Lluveras 361d924c11 Fix layout issues after merges (https://github.com/woocommerce/woocommerce-blocks/pull/1968)
* Fix address form layout broken because select was occupying too much space

* Fix shipping rates appearing in the Checkout sidebar

* Center button text
2020-03-16 14:13:04 +01:00
Darren Ethier 437f80d38b Implement error handling for shipping rates and selected shipping rates. (https://github.com/woocommerce/woocommerce-blocks/pull/1956)
* add a hook for throwing errors in a hook callback.

* implement new useThrowError hook

* throw errors when selected shipping rate results in a rest error

* add error handling for various shipping rate error response types

* fix borked merge conflict resolution

* remove throwing error and use correct property for coupons

* add missing default address in use-store-cart

* add missing notices provider
2020-03-13 16:05:45 -04:00
Darren Ethier 80f692404f Refactor Cart to include shippingAddress (https://github.com/woocommerce/woocommerce-blocks/pull/1960)
* Include shipping and billing address data in cart schema

* update cart hook (and data api) with new properties from endpoint

* add use-shipping-address hook and implement in use-shipping-rates

* update usages of useShippingRates through code

* update tests for use-shipping-rates

* update use-payment-method-interface and typedef to remove country field

This is provided reliably via the shippingAddress now.

* restore pluck comparison to effect.

Also added some clarification docs for why `iniitalAddress` is not included in the effect dependencies.

* remove billingAddress from cart schema

* clear city and postcode when changing country

* Update REST Api schemas aftere rebase

- CustomerSchema no longer exists
- Added ShippingAddressSchema implemented by Cart and Order schemas
- fix broken js because of bad merge conflict resolution.

* remove duplicate keys
2020-03-13 15:04:03 -04:00
Albert Juhé Lluveras 5d1d8f0394 Add Order Summary card to Checkout sidebar (https://github.com/woocommerce/woocommerce-blocks/pull/1959)
* Add missing props to sidebar-layout components

* Move specific CSS class to checkout block

* Add comment on top of @wordpress/components styles in webpack entry

* Make it so our styles load after vendor styles

* Remove unnecessary @todo comment

* Add Order Summary card to Checkout sidebar

* Improve responsive layout

* Increase cart.js bundlewatch size

* Remove wrong comment

* Remove unnecessary usage of useStoreCartItemQuantity

* Refactor layout so the product description can occupy more width

* Move paddings to the button so focus styles look better
2020-03-13 16:49:33 +01:00
Albert Juhé Lluveras bef5514044 Fix IE11 issues with the Checkout block (https://github.com/woocommerce/woocommerce-blocks/pull/1941)
* Refactor useShippingRates so it doesn't use Object.fromEntries

* Refactor Checkout form CSS so it doesn't use grid autopositioning

* Fix Payment Methods title occupying too much space in IE11

* Fix payment methods tab icons not centered in IE11
2020-03-13 15:41:04 +01:00
Mike Jolley 128ac6d63d Refactor cart shipping settings and shipping calculator (https://github.com/woocommerce/woocommerce-blocks/pull/1943)
* Move cart attributes to attributes file

* Stop feedback prompt jumping around; consolodate strings

* Update option labels and descriptions

* Match checkout save function

* hasShippingRate helper

* Refactor full cart/frontend views for shipping calc

* Add hasShippingAddress to useShippingRates hook

* Initial shipping calculator in totals row implementation

* Create cart context

* Update preview data to match API response

* Use context provider for cart

* Provide default cart item for placeholder with correct shape

* Remove outdated shape validation from cartlineitemrow

* Use preview data in editor context

* Tidy up components

* Tests/lint

* Update assets/js/base/components/totals/totals-shipping-item/has-shipping-rate.js

Co-Authored-By: Seghir Nadir <nadir.seghir@gmail.com>

* No need to camel case previewdata

* Use isValidElement

* Implement EditorContext

* Use select if no post is given

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
2020-03-13 13:41:59 +00:00
Albert Juhé Lluveras 1c81066bc4 CSS editor fixes for Cart and Checkout blocks (https://github.com/woocommerce/woocommerce-blocks/pull/1949)
* Set min-height to 0 for Country & State hidden inputs

* Fix button styles broken in the Cart block in editor

* Avoid having editor.scss specific stylesheets for button and totals

* Move Button inside cart-checkout subfolder
2020-03-13 12:02:08 +00:00
Seghir Nadir f55adc41cb Fix select rates when multiple packages exists (https://github.com/woocommerce/woocommerce-blocks/pull/1945)
* Select rates when multiple packages exists

* switch to using package_id

* update docs

* ponyfill fromEntries

* revert useShippingRates fromEntries fix
2020-03-12 10:59:43 +01:00
Albert Juhé Lluveras 2147e8a22a Add checkout sidebar (https://github.com/woocommerce/woocommerce-blocks/pull/1921) 2020-03-12 10:41:35 +01:00
Albert Juhé Lluveras 87b87cee8a Hydrate Checkout block with API data (https://github.com/woocommerce/woocommerce-blocks/pull/1937) 2020-03-12 10:24:50 +01:00
Darren Ethier e2fca8cf02 Update/extract prepare total items to utility (https://github.com/woocommerce/woocommerce-blocks/pull/1950)
* add valueWithTax to CartTotalItem typedef

* Finish off `prepareTotalItems` to include totals with taxes and also add tests

* add whether prices should include tax to the payment method interface

* only export the hook, not the util function

* Indicate values are in subunits

* rename property so it’s consistent with typedef and implement
2020-03-11 21:08:20 -04:00
Darren Ethier 09248192c2 Fix invalid coupon thrown error and form not connected console warning. (https://github.com/woocommerce/woocommerce-blocks/pull/1952)
* remove throwing errors if there’s an error in state.

These type of errors should be surfaced to user as needed via an error notice, not as a blocking error boundary. Error boundary should only be for non-recoverable errors.

* prevent default behaviour for applyCoupon button
2020-03-11 16:23:14 -04:00
Darren Ethier 74fe220f89 Add new hooks related to payment methods and checkout and remove obsolete. (https://github.com/woocommerce/woocommerce-blocks/pull/1929)
* add various hooks and improve hooks folder structure

- Also restructures hooks directory to make things a bit more organized
- Add useStoreOrder placeholder (followed up in future pull)
- Add useBillingData hook.

* implement usePaymentMethodInterface hook in payment method components

* remove obsolete hooks and implement new checkout context hooks

- add useCheckoutSubmit which exposes checkout submit button interface
- add useCheckoutRedirectUrl which exposes checkout redirect url interface

* add alias for `@woocommerce/base-utils` to jest config

* use consistent variable names for payment method id
2020-03-11 06:50:12 -04:00
Rua Haszard 14a593a4bb Make checkout button sticky footer on mobile (https://github.com/woocommerce/woocommerce-blocks/pull/1917)
* sticky footer checkout submit button on mobile

* fix storefront footer icons overlaying sticky checkout CTA footer:
- bump z-index of sticky CTA container
- storefront icons have weird z-index due to css opacity

* hide storefront footer on woo cart page only

* remove storefront specific bug fix for sticky cart footer:
- will log this issue separately
2020-03-11 11:27:52 +13:00
Albert Juhé Lluveras 3b807d5e04 Fix Cart block making 404 requests in the editor (https://github.com/woocommerce/woocommerce-blocks/pull/1925) 2020-03-10 17:50:18 +01:00
Darren Ethier 3e355f8ac2 Update payment registration config to include `edit` components (https://github.com/woocommerce/woocommerce-blocks/pull/1928)
* add isEditor to checkotu context and implement in provider usage

* modify configuration expectations for payment method registration api

* update registration of payment methods in demo

* implement new configuration in payment method components

* fix argument order and update jsdocs
2020-03-10 12:35:30 -04:00
Albert Juhé Lluveras d0cb38d37d Handle cart api errors (https://github.com/woocommerce/woocommerce-blocks/pull/1907) 2020-03-10 16:49:26 +01:00
Darren Ethier 4b4dff1297 Fix PropTypes warning for CartLineItem component (https://github.com/woocommerce/woocommerce-blocks/pull/1927)
* fix proptypes declaration.

This ensures that when `lowStockRemaining` is included it’s either null or a number.

* Ensure backorders_allowed value is boolean.

* add missing properties to cart preview
2020-03-10 11:14:05 -04:00
Mike Jolley e6dfe243f9 Switch out usage from withComponentId to tree-shaken withInstanceId (https://github.com/woocommerce/woocommerce-blocks/pull/1923) 2020-03-10 14:40:30 +00:00
Darren Ethier 2aa2093dfb Add contexts for checkout (https://github.com/woocommerce/woocommerce-blocks/pull/1915)
- restructures `@woocommerce/base-context` imports so it pulls from `index.js` in the `base/context` folder. That way tree-shaking will be used if possible. This also helps with organizing the folder structure a bit better for the new contexts.
- Fixes all the various imports through the code due to the above change.
- Adds `CheckoutContextProvider`, `useCheckoutContext` and related files.
- Adds `PaymentMethodDataProvider`, `usePaymentMethodDataContext` and related files.
- Adds `ShippingMethodDataProvider`, `useShippingMethodDataContext` and related files.
- Adds typedefs used for the various context interfaces.
2020-03-10 09:39:21 -04:00
Seghir Nadir 5ca0593fbd Default to the first state when selecting a country with states (https://github.com/woocommerce/woocommerce-blocks/pull/1919)
* default to the first state

* Update assets/js/base/components/state-input/state-input.js

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

Co-authored-by: Albert Juhé Lluveras <aljullu@gmail.com>
2020-03-10 13:27:58 +01:00
Darren Ethier 0cacf5e0da Disallow selecting quantity of stock past what's available. (https://github.com/woocommerce/woocommerce-blocks/pull/1905)
- `useStoreCartItemQuantity` now receives the cartItem instead of the `cartItemKey` as an argument. I didn't notice in previous reviews how it's used in the context where we already have a cartItem so implementing this reduces complexity and makes the hook more precise for it's purpose.
- Add `backorders_allowed` to the CartItem schema for the API. This allows for client to have correct logic for maximum quantity when this value is true.
- Implement the above in the `CartLineItemRow` so that quantity picker is limited by the amount of stock remaining if that is available (`lowStockRemaining`) and the `backorders_allowed` is false.
- maximum quantity is currently hardcoded to a (filtered) value of `99` when other conditions don't apply (see related issue in woocommerce/woocommerce-blocks#1913)
2020-03-10 07:43:57 -04:00
Mike Jolley 514642395a Prevent wp.components loading on frontend (https://github.com/woocommerce/woocommerce-blocks/pull/1918)
* Avoid importing @wordpress/components in icon library

* Avoid @wordpress/compose and @wordpress/components in `base`

* Move hocs used on frontend to base

* Revert "Move hocs used on frontend to base"

This reverts commit bf09016fdc2fc1bea2f465018fecc76945f69d5e.
2020-03-10 11:20:40 +00:00
Seghir Nadir 952638a3ed Link shipping form fields to shipping rates to load them. (https://github.com/woocommerce/woocommerce-blocks/pull/1890)
* add plukedAddress util function in order to use it for shallowEqual

* refactor useShipping so it accepts and returns the address

* refactor fields

* fix test and return shippingRates to hook

* remove unneeded shippingAddress from ShippingRatesControl

* move keys logic to hook

* refactor tests again

* increase cart size
2020-03-10 11:55:19 +01:00
Albert Juhé Lluveras f14fc54faf Refactor 'Hide shipping costs' Cart attribute logic (https://github.com/woocommerce/woocommerce-blocks/pull/1909)
* Use kebab-case for Cart block attributes

* Simplify Cart edit function

* Refactor showShippingCosts logic

* Update snapshots
2020-03-10 10:09:34 +01:00
Rua Haszard 12f942948e mobile layout fixes for cart totals (https://github.com/woocommerce/woocommerce-blocks/pull/1898)
* tidy cart totals layout on mobile:
- totals column is full width
- reset container (card) borders and padding

* increase specificity of mobile cart styles to ensure skeleton hides after load

* use "not loading" && "not skeleton" approach for more readable mobile style selector
2020-03-10 10:16:03 +13:00
Mike Jolley 38890b3ff9 Add "or continue below" separator to checkout block (https://github.com/woocommerce/woocommerce-blocks/pull/1906)
* Update express checkout component to match coding standards doc

* Improve express checkout spacing/styling

* Add continue rule
2020-03-09 15:49:01 +00:00
Mike Jolley 168ce52935 Include address fields in the AddressForm component (https://github.com/woocommerce/woocommerce-blocks/pull/1892)
* Move default address fields to blocks; normalise address i18n

* Use optionalLabel and other props from addressFields

* Fix apartment field display

* Country address fields

* Fix default field order

* Update for countries with no states

* Add type defs
2020-03-09 14:23:16 +00:00
Darren Ethier 02b3f2fccc add defaults for cart data totals object (https://github.com/woocommerce/woocommerce-blocks/pull/1896) 2020-03-09 08:52:25 -04:00
Darren Ethier 89ab1579b0 Followup for useStoreCartItem work (change hook name and improve typedefs) (https://github.com/woocommerce/woocommerce-blocks/pull/1900)
* add typedefs for CartItem

* remove cartItem from StoreCartItem typedef

* Implement new typedef and fix defaults as well as returned object.

Now that `cartItem` is only used internally, the default set on the state only has to be the properties required internally in the hook.

* add typedefs for shared settings and implement typedef comments.

* change hook name
2020-03-09 08:24:56 -04:00
Albert Juhé Lluveras b7da7ad198 Make Shipping packages collapsible in Cart page (https://github.com/woocommerce/woocommerce-blocks/pull/1867)
* Make Shipping packages collapsible in Cart page

* Fix Cart block radio controls not looking properly in the editor

* Simplify CSS
2020-03-09 12:28:26 +01:00
Rua Haszard 76f5ed5030 improve responsiveness when setting cart item quantities (https://github.com/woocommerce/woocommerce-blocks/pull/1864)
* rework the quantity change generator action so the UI updates quick:
- work in progress - still need to figure out how to debounce API call
- add new action for updating quantity for an item
- don't set cart item as pending while quantity is updating
  - this leaves QuantitySelector enabled so user can click more/less
- use receiveCartItemQuantity to update quantity in UI before sending request

* debounce line item quantity first cut:
- use local state for quantity, so ui allows multiple clicks up/down
- debounce store updates (and server/API call)

* correct comment on cart item quantity reducer

* remove recieveCartItemQuantity - no longer needed

* remove delegation for deleted RECEIVE_CART_ITEM_QUANTITY

* only update quantity in component sideffect if it has changed:
- reduces unnecessary renders

* factor out debounced quantity update into cartItem hook (hat tip @senadir)

* use quantity from store, instead of passing in to hook +
+ fix latent bug in useStoreCartItem - the cartItem value is now object:
  - was previously single-item array
  - (note no client code is using this at present)

* tidy/refactor cart item hook - separate dispatch from select

* remove dud reset of item pending flag (came back in rebase)

* add quantity to StoreCartItem hook return value typedef

* fix js error when adding cart block in editor – cartItem not found

* fix typedef

* fix logic for debouncing

* don’t update quantity on server unnecessarily

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-03-09 15:09:47 +13:00
Seghir Nadir e769516758 better default to array and use length as condition (https://github.com/woocommerce/woocommerce-blocks/pull/1891) 2020-03-06 15:40:07 +00:00
Albert Juhé Lluveras 427a229591 Split Full Cart sidebar totals into several components (https://github.com/woocommerce/woocommerce-blocks/pull/1885) 2020-03-06 12:27:54 +00:00
Mike Jolley 1942491822 Checkout Block: Add Legal links (https://github.com/woocommerce/woocommerce-blocks/pull/1881)
* Create policy component

* Create page constants

* Add toggle options

* Update assets/js/base/components/checkout/policies/style.scss

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* Update assets/css/editor.scss

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* Feedback

* update snapshot

Co-authored-by: Albert Juhé Lluveras <aljullu@gmail.com>
2020-03-06 12:20:17 +00:00
Mike Jolley 0a722b1708 Cart and checkout error boundaries (https://github.com/woocommerce/woocommerce-blocks/pull/1853)
* Add error boundries

Revert block error move

webpack config

fix path

* type in config

* change text allowed type

* Pass error boundary props to renderfrontend

* Editor error boundaries

* Add errorMessagePrefix

* merge rules

* Remove <disabled>

* Update reload page link
2020-03-06 11:43:40 +00:00
Albert Juhé Lluveras 20da4900c2 Add styling to checkboxes (https://github.com/woocommerce/woocommerce-blocks/pull/1880)
* Add styling to checkboxes

* Add resets for some themes

* Simplify props
2020-03-06 11:26:03 +01:00
Seghir Nadir 2c8388f0a8 Update and select shipping rates dynamically (https://github.com/woocommerce/woocommerce-blocks/pull/1794)
* add select shipping endpoint to router

* add select shipping method

* add selected rates to cart

* better select rates

* move schema function to seperate function

* move validation to Cart Controller

* fix wrong session key

* Update shipping/cart endpoints (https://github.com/woocommerce/woocommerce-blocks/pull/1833)

* Items should not have keys in API response

* Include package ID in response (this is just a basic index)

* /cart/select-shipping-rate/package_id

* Add package_id to package array

* Update responses and add shipping-rates to main cart endpoint

* update-shipping endpoint

* Add querying selected shipping rate to the store (https://github.com/woocommerce/woocommerce-blocks/pull/1829)

* add selecting shipping to store

* directly call useSelectShippingRate

* refactor cart keys transformation to reducer

* remove selecting first result and accept selecting

* move update shipping to new endpoint

* pass selected rates down

* select shipping right directly and fix editor issues

* fix some broken prop types

* key -> package id

* Update and fix cart/shipping-rate tests

* fix case for when rates are set

* Update useShippingRates test

* add args to rest endpoint

* move selecting shipping rate logic to hook

* fix some naming issues

* update propTypes

* update action call

* fully watch cart state

* address review issues

* fix prop type issues

* fix issue with rates not loading in checkout

* remove extra package for shipping

* move ShippingCalculatorOptions to outside

Co-authored-by: Mike Jolley <mike.jolley@me.com>
Co-authored-by: Albert Juhé Lluveras <aljullu@gmail.com>
2020-03-05 20:54:05 +01:00
Rua Haszard 5a26d2708e ensure cart totals update when items are removed or quantity changed (https://github.com/woocommerce/woocommerce-blocks/pull/1840)
* ensure cart totals update when items are removed (prototype):
- return complete cart object from DELETE cart/items/:key
- use receiveCart on client to update whole cart including total

* move API endpoint for removing cart items to cart controller:
- returns full cart schema so should be part of cart controller
- is now a POST request with param - not strict REST
- fix up client action to use new API

* move API test for removing cart items (API has moved)

* use correct path for remove API in tests (doh!)

* add extra API test for remove_cart_item with bad key => 404 (experiment)

* experiment: delete test_remove_cart_item, does test_remove_bad_cart_item work?

* reinstate test_remove_cart_item with single valid request

* remove unnecessary newline

* tidy comments in PHP api tests, rerun travis?

* remove test_remove_cart_item which may be causing problems

* reinstate troublesome remove cart item api test (experiment):
- see if this works now travis issue is resolved

* whitespace

* show correct total when changing cart item quantity:
- move update cart item quantity API to cart controller
  - & return full cart response
- update js action to new API route & receive full cart response

* simplify test_remove_cart_item API test - now just tests a valid remove succeeds

* remove test_update_item (API has moved) +
+ experimentally remove test_remove_bad_cart_item
  - testing if cart remove tests interact with each other

* fix tests (🤞) - pass params in body, not as query params

* reinstate test for re-deleting same item

* update API docs - update/delete cart item have moved to /cart

* add response data checks to new cart API tests:
- extra protection against expected 404 "false positives"

* reinstate API test for changing cart item quantity

* fix remove cart item body tests - MIA items return error code, not cart

* fix test - quantity param is int not string

* attempt fix 404ing test_update_item:
- only allow POST, remove trailing `/`
- align array equals for good measure :)

* fix action for update-item - method=POST, now takes body params

* fix response body asserts in test_update_item

* reinstate update_item and delete_item on CartItems controller

* typos + examples in new cart items API docs

* reorder previous cart item docs to minimise diff/churn

* reinstate tabs in docs response example
2020-03-06 08:11:39 +13:00
Mike Jolley 52feba4f85 Add skeleton markup to the cart block (https://github.com/woocommerce/woocommerce-blocks/pull/1866)
* Add skeleton markup

* Add shipping title to skeleton and match styling/spacing

* Combine skeleton and loading styles
2020-03-05 14:15:28 +00:00
Mike Jolley dd54ce1136 Checkout form options to control field visibility (https://github.com/woocommerce/woocommerce-blocks/pull/1868)
* Fix background overlap of feedback box

* TS notices

* Add company name toggle

* Implement new attributes and toggles in editor

* Handle field config in address component

* Remove other hoc rule from tsconfig

* map -> forEach

* Remove return from forEach

* Export and extend field config

* Fix optional text for all field types

* unit text

* Update snapshot
2020-03-05 13:06:47 +00:00
Mike Jolley 401f50a607 Tidy cart items mobile layout (https://github.com/woocommerce/woocommerce-blocks/pull/1875)
* add a smaller min-width for cart column on smaller screens

* ensure full price is inline on mobile (when visible)

* ensure line item totals are bottom aligned even if quantity cell is huge

* revert price vertical alignment - in design they are aligned with quantity digit
2020-03-05 13:05:42 +00:00
Mike Jolley c4c31bd926 make product name display block to push stock badge on to its own line (https://github.com/woocommerce/woocommerce-blocks/pull/1874) 2020-03-05 12:56:57 +00:00
Albert Juhé Lluveras 2544ffd7d1 Option to 'use shipping address for billing': add attribute and make it work in the frontend (https://github.com/woocommerce/woocommerce-blocks/pull/1857)
* Create useShippingAsBilling attribute

* Fix missing prop

* Refactor FormStep so stepNumber is generated by CSS instead of being passed as a prop

* Add billing address form

* Add text before controls

* Remove old @todo comment
2020-03-04 15:13:38 +00:00
Albert Juhé Lluveras e2f769eedf Do not allow focus on Country and State input hidden fields (https://github.com/woocommerce/woocommerce-blocks/pull/1842) 2020-03-04 14:35:18 +00:00
Mike Jolley ea19fad14e Add useStoreCartApiHydration HOC (https://github.com/woocommerce/woocommerce-blocks/pull/1845)
* Add useStoreCartApiHydration hoc

* comment

* indenting

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
2020-03-04 12:40:03 +00:00
Albert Juhé Lluveras e97ffd2821 Hide package name when there is only one (https://github.com/woocommerce/woocommerce-blocks/pull/1852) 2020-03-03 12:38:21 +00:00
Albert Juhé Lluveras 81c09d180b Create AddressForm component and change its fields dynamically based on country (https://github.com/woocommerce/woocommerce-blocks/pull/1847) 2020-03-03 11:46:53 +01:00
Mike Jolley d3a9dc3d6b Create Context Provider for Notices w/ Notices API (https://github.com/woocommerce/woocommerce-blocks/pull/1843)
* Working on store provider

* Working on store provider

* Reducer implementation

* Implement core/notices

* Add notices to store coupon hook with context

* Improve store notice text and styling

* Improve JS side API for notices

* Wrap functions with context additon

* Update test to []

* Implement props feedback and useInstanceId

* Update assets/js/base/context/store-notices-context.js

Co-Authored-By: Darren Ethier <darren@roughsmootheng.in>

* Update assets/js/base/context/store-notices-context.js

Co-Authored-By: Darren Ethier <darren@roughsmootheng.in>

* remove instance id

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-03-03 10:26:02 +00:00
Mike Jolley 5fcf9b0fca Correctly handle store tax options in cart block (https://github.com/woocommerce/woocommerce-blocks/pull/1846)
* Correctly show prices with incl or excl taxes

* Move taxes below shipping

* TaxAmount case
2020-03-03 10:12:18 +00:00
Rua Haszard 201cb4ff50 Support updating quantity of cart items & sold_individually product option (https://github.com/woocommerce/woocommerce-blocks/pull/1824)
* first cut - removing an item from cart:
- add actions to cart store for removing an item and keeping track of
pending removal API call
- add reducer logic for storing pending state on an item, and removing
an item
- expose removeCartItem on new useStoreCartItems hook
- hook it up to remove link / trashcan icon in row item

* disable cart quantity picker/remove link while API request in progress:
- expose cart item pending status from store using selector
- use selector to disable quantity related components in line item row

* add typedef for cart items store object provided by hook

* allow user to change quantity of cart items (first cut):
- add action for replacing a cart item in the store
- add generator action for changing quantity
- expose change quantity action on useStoreCartItems hook
- hook up to quantity UI in cart block
(work in progress)

* post-rebase fixes & fix broken typedef:
- rework cart item change quantity callback - now supplies item key like
remove callback
- fix hook StoreCartItem return value typedef - single item with
specified key, was array of all items
- add quantity JSDoc for changeCartItemQuantity action
- remove changeQuantity callback from UI (currently infinite looping)

* fix bug in recieveCartItem reducer - check keys for equality:
- was key === object

* fix invalid url in POST cart/items/quantity request

* hook up cart line item quantity to API:
- remove internal state/ref for QuantitySelector, is now a controlled
component
- call changeQuantity action from QuantitySelector change callback

* QuantitySelector no longer needs a ref to wrangle number input value

* hoist quantity state out of QuantitySelector into story (fix storybook)

* add product sold_individually option to cart item API response

* limit sold_individually items to 1 per cart/order:
- support optional max value in QuantitySelector
- set maximum dependent on sold_individually API field

* prevent user from requesting zero x cart item (API 500 errors):
- add minimum limit to QuantitySelector
- default limit to 1
+ fix bug with limiting to maximum value in number input change handler

* remove useStoreCartItems, zombie hook coming back from rebase 🧟‍♂️

* address various review feedback:
- inline undefined check, don't use lodash
- quantityInputOnKeyDown callback hook depends on canIncrease/canDecrease
- also removed undefined check for minimum, as minimum has default 0

* use safer typeof check for presence of maximum prop
2020-03-03 14:08:19 +13:00
Albert Juhé Lluveras f2cdd2ade7 Fix Product Search block in last Gutenberg release (https://github.com/woocommerce/woocommerce-blocks/pull/1841)
* Fix Product search block in last Gutenberg release

* Convert ProductSearchBlock to a functional component

* Split ProductSearchBlock into two components
2020-03-02 14:46:56 +01:00
Darren Ethier 12a28556db Switch lint:js command to use wp-scripts and address errors. (https://github.com/woocommerce/woocommerce-blocks/pull/1837)
* switch js lint command to use wp-scripts.

* fix lint warning for improper jsdoc syntax

* fix linting errors
2020-02-28 16:54:07 -05:00
Darren Ethier 6b110d00f2 Fixes some typedef errors (https://github.com/woocommerce/woocommerce-blocks/pull/1832) 2020-02-28 06:51:30 -05:00
Rua Haszard 69ea94378b support removing cart items (https://github.com/woocommerce/woocommerce-blocks/pull/1813)
* first cut - removing an item from cart:
- add actions to cart store for removing an item and keeping track of
pending removal API call
- add reducer logic for storing pending state on an item, and removing
an item
- expose removeCartItem on new useStoreCartItems hook
- hook it up to remove link / trashcan icon in row item

* disable cart quantity picker/remove link while API request in progress:
- expose cart item pending status from store using selector
- use selector to disable quantity related components in line item row

* fix jsdoc - getCartItem returns undefined if not found

* add typedef for cart items store object provided by hook

* fix rebase error - key prop went awol

* orient useStoreCartItem hook to single cart item:
- simplify interface for client component
  - isPending bool (was callback)
  - removeItem callback no need to specify item key
+ reinstate disabled prop on remove link when updating (lost in rebase)

* move cart item pending state out of cartItems, preserve API state shape:
- pending is now stored as array of keys
- fix isItemQuantityPending selector (now much simpler)

* ensure react knows that our useSelect depends on cartItemKey
2020-02-28 15:05:10 +13:00
Rua Haszard bb637bbaa3 support disabled QuantitySelector [in progress] (https://github.com/woocommerce/woocommerce-blocks/pull/1823)
* add basic story for QuantitySelector (so can easily test disabled)

* add disabled prop to QuantitySelector:
- apply to all input controls
- add storybook knob for testing
- use disabled grey for number edit when disabled

* fix indentation of jsdoc comment (linter is coming)

* use self-closing tag in QuantitySelector story

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

Co-authored-by: Albert Juhé Lluveras <aljullu@gmail.com>
2020-02-28 09:52:18 +13:00
Albert Juhé Lluveras 185149f2bd Persist previous shipping rates while loading and show its package name (https://github.com/woocommerce/woocommerce-blocks/pull/1806)
* Persist previous shipping rates while loading

* Refactor ShippingRatesControl LoadingMask

* Show package name

* Simplify CSS to avoid using the adjacent selector

* Add comment to explain why 'selected' is hardcoded in the editor

* Rename package 'index' to 'key'
2020-02-27 19:28:36 +01:00
Mike Jolley d4e843fd65 Update snapshot to fix broken tests 2020-02-27 11:53:12 +00:00
Mike Jolley 6ac5b8288f Add chip component for coupons in the cart (https://github.com/woocommerce/woocommerce-blocks/pull/1807)
* Chip componet and styling

* Tests

* Move coupon code for API requests to body - fixes issues with coupon codes containing special characters

* Implement chip component in cart page

* Revert "Move coupon code for API requests to body - fixes issues with coupon codes containing special characters"

This reverts commit ac5a72f55d51d939bb989f3936e28cf993af19a6.

* Update comment

* prevent overflow

* Add screen reader text for coupon name

* Adjust icon alignment and padding/hit box

* update string
2020-02-26 17:09:18 +00:00
Albert Juhé Lluveras 7603b1391f Checkout block: don't show message of missing shipping options if they are already set (https://github.com/woocommerce/woocommerce-blocks/pull/1804)
* Checkout block: don't show message of missing shipping options if they are already set

* Use 'wc_get_shipping_method_count' to check if shipping methods are created

* Fix frontend error

* Check  exists before calling a method on it

* Fix Configure Shipping Options button mispositioned in last Gutenberg release
2020-02-26 15:50:53 +00:00
Mike Jolley eee2d342ae Add loading placeholder for cart block (inital load) (https://github.com/woocommerce/woocommerce-blocks/pull/1819)
* Tidied up source code for line item row and fixed image placeholder support

* Return null if not rendering

* Add is loading state and className to cart block

* Hide title if there are no items

* Add placeholder rows when there are not items and cart is loading

* Pass though isLoading to cart

* Set defaults for cart item rows

* Style the placeholder elements

* Move placeholderRows

* Remove getPriceNumber

* Move decodeEntities

* Split up utils
2020-02-26 15:49:07 +00:00
Albert Juhé Lluveras 1deb0f853c Fix radio control styles in editor (https://github.com/woocommerce/woocommerce-blocks/pull/1817) 2020-02-26 13:02:48 +00:00
Albert Juhé Lluveras 11f5210297 Wrap Coupon code input/button in a <form> element (https://github.com/woocommerce/woocommerce-blocks/pull/1818)
* Wrap Coupon code input/button in a <form> element

* Add back row class
2020-02-26 13:48:16 +01:00
Mike Jolley 740a636c88 Updated `store/cart` endpoint coupon formatting and handling (https://github.com/woocommerce/woocommerce-blocks/pull/1808)
* Move coupon code for API requests to body - fixes issues with coupon codes containing special characters

* Use wc_format_coupon_code when applying/removing coupons via the cart endpoint

* Add tests
2020-02-26 11:46:58 +00:00
Rua Haszard 0f57b6fdef show discount badge in line items in cart (https://github.com/woocommerce/woocommerce-blocks/pull/1784)
* calculate regular price for line item and return in API `line_subtotal`

* restore `line_subtotal` api field to previous behaviour

* correctly handle discounts on cart line items:
- return product `prices` in cart items endpoint
- calculate full price and discount on client using product
regular_price * quantity in cart

* add product prices to preview cart API data

* show product sale price discount in "save" badge:
- previously we were displaying any effective discount, e.g. from coupons which apply to whole cart
- now this badge will only display discount due to product on sale - much simpler

* rename sale badge class (discount => sale)

* clarify docs for line_subtotal - includes sale prices, not coupons

* clarify line_total docs

* add prices to schema (fix unit test)

* fix schema unit test - return `prices` as object, consistent with `totals`

* Further line total rewording

Co-authored-by: Mike Jolley <mike.jolley@me.com>
2020-02-25 12:17:13 +00:00
Mike Jolley 6d7fdf50e0 Allow coupons to be applied and removed from the cart (https://github.com/woocommerce/woocommerce-blocks/pull/1790)
* useStoreCartCoupons hook

* Apply coupon w/ basic error handling for the fetch

* Basic store specifically for cart data

* Working on error states

* Show error on coupon fail

* removeCoupon action

* Added extra endpoints for more efficient cart queries

* Apply/remove coupons working

* Track applying/removing state

* StoreCartCoupon typedef

* Use coupon code on index

* Remove custom controls definition

* Adjust storecartcoupons mapper and remove ref

* Move cartData defaults and remove ref

* Call API directly, avoid schema lookup

* Improved selectors

* StoreCart typedef

* Split up cart state data and add more typedefs

* Add API tests for apply/remove coupon

* Jest tests

* Move default cart data to constant

* Comment indentation
2020-02-25 11:36:53 +00:00
Albert Juhé Lluveras d803f6cc64 Add product name and quantity to cart shipping rates endpoint (https://github.com/woocommerce/woocommerce-blocks/pull/1783)
* Add product name and quantity to cart shipping rates endpoint

* Make text accessible

* Add styling

* Create Packages component

* Add preview shipping rates to editor

* Add onChange default value

* Order props

* Use CSS instead of JS to render commas between package elements

* Change quantity type to number instead of integer
2020-02-25 10:32:59 +01:00
Albert Juhé Lluveras 4a5ad79823 Add style to radio control (https://github.com/woocommerce/woocommerce-blocks/pull/1789) 2020-02-24 13:30:09 +00:00
Darren Ethier f8d6735baf Create typedefs and add basic typescript configuration (https://github.com/woocommerce/woocommerce-blocks/pull/1796)
* install typescript and add typedef support

* add typedefs for Cart things

* improve typescript config

- adds more base config
- add our aliases

* fix error caught by typescript!

* Tweak typescript configuration

* Add missing `@woocommerce/settings` alias to ts config

* Add alias for type-defs
2020-02-24 07:52:24 -05:00
Mike Jolley 454bb07eda Add permalink to line items (https://github.com/woocommerce/woocommerce-blocks/pull/1791) 2020-02-24 12:39:43 +00:00
Seghir Nadir 2058c64bac redo work after rebase (https://github.com/woocommerce/woocommerce-blocks/pull/1777) 2020-02-21 17:40:25 +01:00
Albert Juhé Lluveras f0239d6378 Make Shipping Calculator Button type="submit" (https://github.com/woocommerce/woocommerce-blocks/pull/1785) 2020-02-21 16:26:27 +00:00
Mike Jolley 3e6f8fe6a6 Add isLoading property (https://github.com/woocommerce/woocommerce-blocks/pull/1788) 2020-02-21 14:08:57 +00:00
Mike Jolley 806cd76987 Display selected shipping location in cart block (https://github.com/woocommerce/woocommerce-blocks/pull/1767)
* county->state clarity

* Show formatted address
2020-02-19 17:14:41 +00:00
Seghir Nadir 90a7579461 Add Shipping settings to Cart block (https://github.com/woocommerce/woocommerce-blocks/pull/1561)
* add cart settings

* address typos

* update how settings should work

* get settings from woo and pass them to frontend

* reapply condition

* fix issue with attributes not presisting

* abstract shipping control

* rename constants

* update props in frontend

* fix bug with attributes not presisting

* conditionally display prices

* use country to decide to show prices

* disable shipping if shipping is not enabled

* enable coupons by default
2020-02-19 17:33:10 +01:00
Mike Jolley 6c954bdc5b Add support for image for product categories block (https://github.com/woocommerce/woocommerce-blocks/pull/1739)
* Add support for image for product categories block.

* Resolve feedback and style images, w/ thumbnails

* Toggle visibility of option based on list style

* Remove image size variable

* hasImage false by default

* reset styles

Co-authored-by: strarsis <strarsis@gmail.com>
2020-02-19 15:12:28 +00:00
Mike Jolley 2a25cfd0ed Implement browser autocomplete for checkout address fields (https://github.com/woocommerce/woocommerce-blocks/pull/1755)
* Add autocomplete support for textinput

* Add autocomplete fields to forms

* Prefix default ids

* Hack for autocomplete on custom select components

* Restore labels and avoid reset of state

* State field autocomplete

* Fix calculator autocomplete

* Simplify existance of hidden field

* move label on autofill preview in chrome

* Put back state clearance

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
2020-02-19 15:10:26 +00:00
Albert Juhé Lluveras 7b53486be3 Add loading state to shipping rates selector (https://github.com/woocommerce/woocommerce-blocks/pull/1764)
* Add loading state to shipping rates selector

* Add screenReaderLabel specific for ShippingRatesControl

* Rename LoadingComponent to LoadingMask
2020-02-19 11:51:15 +01:00
Rua Haszard c13bd7e641 hook up cart items to API data in front end (https://github.com/woocommerce/woocommerce-blocks/pull/1741)
* hook up cart items to API data in front end (first cut)

* correctly decode entities in product attributes in cart:
+ support unnamed attributes

* correctly render markup in cart line item descriptions:
- description api field is html, so use dangerouslySetInnerHTML

* fix PropTypes - cartItems, not items

* hook up cart totals area to API data +
+ move editor preview totals data to resource-previews (to match API)

* tweak/tidy todo comments for cart front end

* use shorter summary field for cart line item blurb

* render empty cart inner blocks on front end when shopper cart is empty

* ensure empty cart doesn't show while cart contents is loading

* decode entities in attribute names when rendering cart items

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* factor out cart data to a custom hook + exit earlier while loading

* wrap preview/sample cart variation data for translation

* use RawHTML component for rendering cart line item summary +
+ linter whitespace tweak

Co-authored-by: Albert Juhé Lluveras <aljullu@gmail.com>
2020-02-19 12:06:37 +13:00
Mike Jolley 2ef1209ed8 Implement last modified header for the products endpoint to allow for cache busting (https://github.com/woocommerce/woocommerce-blocks/pull/1647)
* Implement last modified header for the products endpoint.

* Invalidation handling

* Freshness

* indenting correction

* Remove freshness and resolve feedback for last modified handling

* Remove getCollectionTimestamp

* Move logic to resolver

* Handle state during INVALIDATE_RESOLUTION_FOR_STORE
2020-02-18 11:37:39 +00:00
Albert Juhé Lluveras 29a763d7de Shipping rates: decode entities (https://github.com/woocommerce/woocommerce-blocks/pull/1762) 2020-02-18 11:50:08 +01:00
Rua Haszard 04141b7c43 update all block one-line descriptions to match documentation (https://github.com/woocommerce/woocommerce-blocks/pull/1750) 2020-02-18 11:02:59 +13:00
Mike Jolley 212abe0010 Validate proptypes as any element (https://github.com/woocommerce/woocommerce-blocks/pull/1737) 2020-02-17 16:45:27 +00:00
Mike Jolley d76c3e0714 Implement __experimentalCreateInterpolateElement for translations. (https://github.com/woocommerce/woocommerce-blocks/pull/1736)
* Improved placeholders of translatable string

* Improved one more string

* Include wordpress element package

* Implement __experimentalCreateInterpolateElement for translations

* Dump fragments

Co-authored-by: Claudio Sanches <contato@claudiosanches.com>
2020-02-17 16:31:55 +00:00
Mike Jolley 45119716ed Add catalog visibility arg to product query attributes (https://github.com/woocommerce/woocommerce-blocks/pull/1753)
* Add catalog visibility arg to product query attributes

* catalog visibility
2020-02-17 16:16:01 +00:00
Albert Juhé Lluveras 6736a9d94a Add ShippingCalculator component (https://github.com/woocommerce/woocommerce-blocks/pull/1559)
* Create ShippingCalculatorAddress block

* Make 'change address' button to open/close the address form

* Create ShippingCalculator component

* Use CountryInput and CountyInput instead of TextInputs

* Fix city value not being set

* Fix shipping rate not appearing when there was only one option

* Unify postalCode and postCode to postcode

* Rename 'county' to 'state'

* Add reset styles for popular themes

* Increase cart-frontend.js max size
2020-02-17 12:12:15 +01:00
Albert Juhé Lluveras 69f49760a8 Create CountyInput component (https://github.com/woocommerce/woocommerce-blocks/pull/1727)
* Split CountryInput and Select

* Create County Input

* Show text input when there are no county options

* Reset county value when changing country

* Fix keyboard navigation

* Hide checkmark

* Add reset styles for several popular themes

* Add country prop to ShippingCountyInput
2020-02-14 13:30:33 +01:00
Albert Juhé Lluveras a30615e2cb Hook up shipping methods to API (https://github.com/woocommerce/woocommerce-blocks/pull/1468)
* Create ShippingMethodsControl component

* Hook up shipping methods to API

* Add support for several packages

* Add tests to useShippingRates

* Fix shipping_rates property name

* Only show the products list if there are several packages

* Use <FormattedMonetaryAmount> to display shipping rate prices

* Make 'country' optional in CartShippingRates

* Make CartShippingRate API return currency info

* Minor improvements

* Fix shipping fields hidden in editor

* Fix missing currency in Checkout shipping rates selector

* Add links to issues in @todo comments

* Improve ShippingRatesControl useEffect

* Remove unnecessary tab

* Remove unnecessary id in RadioControl

* API: Add error when country is invalid

* Debounce shipping rates API requests

* 'Country key' -> 'Country code'

* Don't display radio input when there is only one option

* Add message when there are no results

* Minor enhacements

* Remove unnecessary Fragment

* Simplify RadioControlOption export

* Refactor 'renderOptions' and split it into several components

* Prevent Card sidebar from taking too much width

* Move country request check outside of the loop

* Fix failing test
2020-02-14 04:43:13 +01:00
Albert Juhé Lluveras 722599004a Change 'country' to 'country / region' label (https://github.com/woocommerce/woocommerce-blocks/pull/1721) 2020-02-11 18:33:41 +01:00
Albert Juhé Lluveras 85291159ae Fix Reviews blocks loading @wordpress/element in the frontend (https://github.com/woocommerce/woocommerce-blocks/pull/1719) 2020-02-11 15:41:50 +01:00
Albert Juhé Lluveras b5638ce87c Update Attribute Filter strings to ease translation (https://github.com/woocommerce/woocommerce-blocks/pull/1718) 2020-02-11 15:41:42 +01:00
Seghir Nadir a39426495d Give Woo Icon special treatment by making it a component (https://github.com/woocommerce/woocommerce-blocks/pull/1702)
* fix broken woo icon

* treat woo icon in a special way

* fix propType typo
2020-02-10 14:24:02 +01:00
Seghir Nadir 8e3ac17585 Introduce feature flags (https://github.com/woocommerce/woocommerce-blocks/pull/1631)
* introduce feature flags

* move config to webpack-helper

* add flag to deploy command

* remove package default

* add cross-env

* add gating to frontendConfig and coreConfig

* exclude entries from being built on stable mode

* add feature gating to PHP

* add flag to start command

* add flags to travis

* add endpoints

* add better defaults for php

* move code to Bootstrap.php

* no need to spread single object

* ignore blocks.ini

* type check feature flag

* remove blocks.ini

* sanitize flag

* remove flag from npm start

* format condition

* keep spaces for package-lock.json

* check for env before going to block ini

* add env vars to travis

* whitelist env var
2020-01-31 21:04:37 +01:00
Seghir Nadir bfb2f33bfd add new icons and remove old ones (https://github.com/woocommerce/woocommerce-blocks/pull/1644)
* add new icons and remove old ones

* add docs

* add notes and remove gridicons

* update to folderStarred

* typos

* reorder imports

* update prop name to srcElement

* validate element

* fix bad import

* lowecase folderStarred

* add propTypes
2020-01-31 19:20:33 +01:00
Mike Jolley ca8efd7c3e Add API fetch error handling (https://github.com/woocommerce/woocommerce-blocks/pull/1687)
* initial experiment for fetch error handling

* throw error from api response error (this allows for catching it in the stream)

* Add ERROR action type

* Controls: resolve with an error response object rather than throw exception

* remove try catch from resolver; just yield correct object based on presence of any errors

* Make the use collection hook return an error.

* Small tidy up in use-store-products

* Throw exception from Use Collection - useState is needed for the exception to work inside a hook (see comments)

* Show error code from API in error message

* Update assets/js/base/components/block-error-boundary/block-error.js

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* Update assets/js/base/components/block-error-boundary/style.scss

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* Remove comment

* Handle api error in boundry

* Use reject in promise

* Return error message by default which may be undefined (this is ok)

* Update mocks so tests pass again

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
Co-authored-by: Albert Juhé Lluveras <aljullu@gmail.com>
2020-01-31 13:01:34 +00:00
Mike Jolley b569f53083 Add and/or labelling to active filters block (https://github.com/woocommerce/woocommerce-blocks/pull/1630)
* Add And/or labelling

* Revised design

* Update assets/js/blocks/active-filters/utils.js

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* Add prefix so name is not changed - fixes duplicate items

* Update BEM css classes

* Update styling to handle nested lists

* Remove extra padding within chips

Co-authored-by: Albert Juhé Lluveras <aljullu@gmail.com>
2020-01-31 10:15:22 +00:00
Rua Haszard 7f44458418 Basic storybook implementation (https://github.com/woocommerce/woocommerce-blocks/pull/1636)
* install & configure storybook (via magic npx script)

* fix indentation in storybook generated files

* eslint ignore generated storybook files (for now at least)

* unhide storybook folder, consistent with Gutenberg project

* demo story for one of our components (with no css/styles)

* hack in scss webpack config & add story for button:
- fixes scss imports breaking storybook build
- note scss / styling doesn't work yet
+ organise our component stories into folder

* git ignore storybook-static build folder

* pin dependencies for storybook

* piggy-back off main webpack config for storybook module.rules (for scss)

* use gutenberg (wp-components) styles in storybook

* use system font for storybook, consistent with wp-admin/gberg and reasonable default for components in front end

* add --ci flag to prevent storybook opening new browser tab…
- see also https://github.com/storybookjs/storybook/issues/6201

* rename default stories to Default (following Gutenberg pattern)

* add story for ErrorPlaceholder

* failing ProductPreview story (committing to PR as an example for discussion)

* storybook for components/icons

* fix aliased dependencies in components for storybook:
append our webpack aliases to storybook webpack config

* basic story for PriceSlider (looks right but interaction broken)

* fix PriceSlider user interaction:
- PriceSlider expects client to handle onChange and pass in new min/max

* add comment about priceslider max/min (todoish)

* remove default stories from storybook scaffolding

* organise stories by module (aka folder in codebase)

* package-lock update after rebase

* remove unnecessary ignores (default stories are gone)

* delete experimental/risky/broken stories:
- icons components are changing in woocommerce/woocommerce-blocks#1644
- we need to refactor/do more work to get ProductPreview working (settings globals)

* remove unnecessary import

* clarify PriceSlider component intended usage comment in story

* remove redundant wrapper divs from stories

* add common storybook addons (used by Gutenberg storybook)

* rebuild package.lock after rebase

* remove unnecessary wrapper div

* package fixes after rebase

* add configuration for storybook source loader

* add decorators for a11y and knobs plugins

* remove unnecessary react import & import useState from WP

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-01-31 09:59:14 +13:00
Albert Juhé Lluveras c8f297a700 All Products & filters accessibility improvements (https://github.com/woocommerce/woocommerce-blocks/pull/1656)
* Add aria-label to All Products ratings

* Add specific screen reader text to some buttons

* Increase All Products regular price color constrast

* Remove invalid CSS declaration

* Make styleint-disable comment more specific

* Attributes Filter: make input non-focusable if we display the 'change filter' button

* Improve translator documentation

* Hide price slider from screen readers if price inputs are enabled

* Linting fixes

* Price slider: make it non-focusable if input fields are displayed

* All Products: announce how many products were found

* All Products: announce when a filter is removed

* Revert "All Products: announce when a filter is removed"

This reverts commit 2c861bf1b988155313ad44bafbcaf3f4f1549296.

* Pagination component: improve screen reader texts

* Filter submit button: improve screen reader texts

* Remove unnecessary text

* Improve comment

* Use %d for numeric values

* Add label and screenReaderLabel props to FilterSubmitButton component
2020-01-30 11:04:39 +01:00
Albert Juhé Lluveras aa4bc302a5 Replace three dots with an ellipsis in Product Search placeholder (https://github.com/woocommerce/woocommerce-blocks/pull/1672) 2020-01-30 10:28:17 +01:00
Mike Jolley 29600c501f Summary/description consistency update (https://github.com/woocommerce/woocommerce-blocks/pull/1639)
* Audit atomic block labels

* Add summary, descrtiption, and short description to API and use for summary block

* Add summary to cart item api

* Respect short description

* Tweak label of summary block

* Revert product rating label

* One description vs 3

* Update sample content with more appropriate values, and match in cart items sample

* Move summary generation to class

* Tests

* Prevent extending `ProductSummary`

* Tweak $paragraph handling

* More accurate word counting

* add tear down for filter
2020-01-29 10:59:33 +00:00
Mike Jolley b65b93e7e7 Rename the "Align Buttons" option for the All Products Block (https://github.com/woocommerce/woocommerce-blocks/pull/1659)
* Allow css to work for any element

* Rename option to specific last block rather than button
2020-01-29 10:28:40 +00:00
Mike Jolley dcf5bfa67e Fix RTL price slider display issues (https://github.com/woocommerce/woocommerce-blocks/pull/1651)
* Fix slider image direction with RTL

* Fix track position under RTL
2020-01-27 15:16:19 +00:00
Albert Juhé Lluveras 7f048ec9c4 Product grid blocks: display rating stars in the editor (https://github.com/woocommerce/woocommerce-blocks/pull/1650) 2020-01-27 13:56:32 +01:00
Darren Ethier d54340a90e Only populate default attributes on initial mount of block. (https://github.com/woocommerce/woocommerce-blocks/pull/1640)
* Avoid looping through attributes after defaults have been set.

* remove extra method I missed and fix when state updates happen

* don’t update state if we’re not in woo blocks

This prevents non woo blocks from being re-rendered unnecessarily with the state update.

* avoid re-renders and use class property instead
2020-01-24 11:53:15 -05:00
Albert Juhé Lluveras ab51bffaa0 All Products: fix 'Add to Cart' in IE11 (https://github.com/woocommerce/woocommerce-blocks/pull/1642)
* All Products: fix 'Add to Cart' in IE11

* Default Event to null
2020-01-23 19:32:48 +01:00
Mike Jolley 24d2600d43 Move default population to class function instead of using constructor (https://github.com/woocommerce/woocommerce-blocks/pull/1638) 2020-01-23 14:11:15 +00:00
Albert Juhé Lluveras 069b42dc39 Make 'Add order notes?' string localizable (https://github.com/woocommerce/woocommerce-blocks/pull/1629) 2020-01-22 21:35:29 +01:00
Mike Jolley d1737e76c2 Change default rows for product grid blocks to 3 (https://github.com/woocommerce/woocommerce-blocks/pull/1613)
* Change default rows to 3

* Handle all products rows change via deprecation

* Prevent errors if object is undefined

* HOC to set default attribute values

* Separate default attributes from attribute definitions

* Filters to set defaults

* Fix deprecation so attributes are not reordered

* Move flters to index file and limit which blocks are affected

* Fix object assign

* Use typeof for undefined checks

* Move hoc to filter file so it has context

* Fix up comment

* Avoid mutating props

* Prevent multiple `attributes` by cloning props

* Force attributes to be saved to HTML in a specific order, and handle migration

* useEffect to set attributes and avoid prop mutation

* Switch to class component
2020-01-22 16:58:25 +00:00
Mike Jolley 69a509f184 Improved cart styling for desktop and mobile (https://github.com/woocommerce/woocommerce-blocks/pull/1587)
* Style mobile qty selector

* Add dedicated column for image and remove duplicate elements

* Tweak column headers

* Refactor cart styles to use CSS grid, and use nesting for organisation

* adjust column widths

* Remove unused div

* Fix wrapping and flexbox styles

* Add decodeEntities to alt attribute

* Use % basis

* Tweak min widths
2020-01-20 16:43:22 +00:00
Albert Juhé Lluveras e607ce2d1a Preserve query key order in All Products (https://github.com/woocommerce/woocommerce-blocks/pull/1611) 2020-01-20 13:04:13 +01:00
Mike Jolley 8b28a77f01 Consistent HTML entities in Store API (https://github.com/woocommerce/woocommerce-blocks/pull/1597)
* Wrap HTML responses with helper method

* Remove unused get_attribute_taxonomy_name method

* Create prepare_html_response method

* Decode product and attribute names

* Check is_scalar to leave objects alone
2020-01-19 19:19:59 -05:00
Seghir Nadir 7e81841e83 Fix issue in order by date (https://github.com/woocommerce/woocommerce-blocks/pull/1598)
* fix order by of date order in products
2020-01-20 00:00:43 +01:00
Rua Haszard d7be99b520 fix issue when user re-selects same attr when setting up filter block: (https://github.com/woocommerce/woocommerce-blocks/pull/1596)
- exit early if there's no selected attr passed in
2020-01-20 07:58:26 +13:00
Albert Juhé Lluveras 09f2c626f9 Make TextInput respect prefers-reduced-motion preference (https://github.com/woocommerce/woocommerce-blocks/pull/1588)
* Make TextInput respect prefers-reduced-motion preference

* Reverse prefers-reduced-motion check
2020-01-18 10:39:13 +01:00
Albert Juhé Lluveras cad3e72769 Create CountryInput component (https://github.com/woocommerce/woocommerce-blocks/pull/1585)
* Create initial CountryInput component

* Create ShippingCountryInput

* Create BillingCountryInput

* Make backgrounds white

* Correctly align options

* Add CSS resets for 20xy themes

* Fix wrong defaults in countries constants

* Make CountryInput respect 'prefers-reduced-motion'

* Reverse prefers-reduced-motion check

* Set max-width to CountryInput dropdown

* Use decodeEntities to print country names

* Avoid unnecessary JSON enconding and later parsing

* Make sure country name is also encoded when selected

* Fix countries default value
2020-01-17 17:58:08 +01:00
Rua Haszard eaa6b42d89 UI for removing cart items (not including hooking up to API) (https://github.com/woocommerce/woocommerce-blocks/pull/1579)
* correct typography styles for remove link (based on design)

* add trashcan icon from material icons, for removing cart items on mobile

* add & style trash icon for remove cart item on mobile

* a11y - use darker grey for trashcan icon button to improve contrast

* rename IconDelete -> IconTrash

* remove unnecessary div

* use <button> for remove action buttons + add link-button scss mixin

* fix editor styles for cart line items - total column should be right-aligned

* fix various visual issues with cart line items table in editor:
- rows should align hard left and right (first/last child no padding)
- totals should be align-bottom on small screen
- correct vertical padding on column headings
- re-add row border separator lines
2020-01-17 13:46:56 +00:00
Seghir Nadir 4a8c57fbe1 Focus on Full Cart mode after inserting (https://github.com/woocommerce/woocommerce-blocks/pull/1582)
* focus on the cart main block
2020-01-17 13:23:33 +01:00
Rua Haszard f3e4fc2bd4 fix react runtime js error when all products productLink=off: (https://github.com/woocommerce/woocommerce-blocks/pull/1593)
- renderedSalesAndImage is a js var holding react element;
- don't surround with (), converts to obj { renderedSalesAndImage: bla }
2020-01-17 09:50:48 +13:00
Mike Jolley 0e752e9e0d Introduce view switcher component for the cart block (https://github.com/woocommerce/woocommerce-blocks/pull/1576)
* View switcher on cart block

* Dedicated component and styling

* Views and selected should be required

* Rename to ViewSwitcher

* Implement views via render prop

* Remove defaults for required props
2020-01-16 14:50:48 +00:00
Albert Juhé Lluveras 3f0368e63b Checkout: Fix city input field showing country value (II) (https://github.com/woocommerce/woocommerce-blocks/pull/1580) 2020-01-16 12:31:00 +01:00
Mike Jolley 86b8b7779c Add Quantity selector component for cart line items (https://github.com/woocommerce/woocommerce-blocks/pull/1558)
* Implement quantity selector component

* Improve default appearance

* Remove underline

* Add aria speak

* Improved keycode handling

* Add focus styles to buttons and inputs

* Increase constrast
2020-01-15 11:32:54 +00:00
Rua Haszard 5c85ee23cf follow up fixes on cart low stock warning badge (https://github.com/woocommerce/woocommerce-blocks/pull/1564)
* rename low stock prop inside lineitem to avoid unnecessary renders

* remove unnecessary span in low stock warning badge
2020-01-15 12:54:32 +13:00
Rua Haszard 86dca691e5 show discount on cart line items & price styling (https://github.com/woocommerce/woocommerce-blocks/pull/1548)
* show discount on cart line items (no styling)

* style line item discount badge + use correct colors for prices

* show full price inline on mobile

* move all responsive tweaks for cart prices to explicit breakpoints

* add nowrap to FormattedMoneyAmount so prices don't ever wrap

* fix misaligned full price on mobile when prices are large (edge case):
- if price strings are long, the full price stacks above line total
- previous right-margin on full price showed prices misaligned

* allow client code to add class(es) to FormattedMonetaryAmount

* add nowrap so discount badge doesn't wrap

* remove unnecessary span from discount badge +
+ more explicit `display` style for different price column elements
2020-01-15 09:52:42 +13:00
Rua Haszard b9bfef0ba4 show low stock warning badge on cart line items (incl fake test data) (https://github.com/woocommerce/woocommerce-blocks/pull/1557) 2020-01-15 09:50:32 +13:00
Albert Juhé Lluveras 11a033d862 Make RadioControl id optional (https://github.com/woocommerce/woocommerce-blocks/pull/1563) 2020-01-14 21:21:29 +01:00
Albert Juhé Lluveras 1dfcb18a90 Make TextInput id optional (https://github.com/woocommerce/woocommerce-blocks/pull/1560) 2020-01-14 20:10:50 +01:00
Rua Haszard f23dee503f show product details in cart line items: attributes (variations), product short description (https://github.com/woocommerce/woocommerce-blocks/pull/1549)
* show product variation attributes in cart line item + styling:
+ adjust font sizes & colors to match design

* show product description in cart line items…
- this commit also adds descriptions to test cart-items data
- note API does not currently return description/excerpt

* add a class to product attributes to allow custom styling
2020-01-14 12:07:52 +13:00
Seghir Nadir 5c82b2d718 add fieldset and legend to FormStep component (https://github.com/woocommerce/woocommerce-blocks/pull/1400)
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-01-13 10:21:20 -05:00
Darren Ethier 22f423866e fix errors caused by demo payment methods (https://github.com/woocommerce/woocommerce-blocks/pull/1547) 2020-01-13 10:08:14 -05:00
Mike Jolley 5926a56602 Add Empty Placeholder for the on-sale product block (https://github.com/woocommerce/woocommerce-blocks/pull/1519)
* Add EmptyResponsePlaceholder for on sale block

* Linting

* Address feedback
2020-01-10 14:40:15 +00:00
Albert Juhé Lluveras bd2b8cb279 Add Cart totals to Cart block (https://github.com/woocommerce/woocommerce-blocks/pull/1411)
* Add Cart totals to Cart block

* Accessibility improvements

* Load vendors styles separately

* Use same shipping placeholders for cart and checkout

* Refactor how we import @wordpress/components styles so only panel styles are imported

* Remove style-loader from vendors styles build process

* Add htmlFor attribute to TotalsCouponCodeInput

* Update totalItems shape to match API

* Fix wrong total items shape using numbers instead of strings

* Rename wc-blocks classes to wc-block

* Remove unnecessary parseInt()

* Add radix to parseInt()

* Rename totalRows to totalRowsConfig

* Move placeholder content out of the component

* Use Card component for cart's sidebar (https://github.com/woocommerce/woocommerce-blocks/pull/1423)

* Use Card component for cart's sidebar

* Split RadioControl component

* No need to use Label in RadioControlOption

* Remove no longer valid @todo comment

* Use 'checked' prop instead of 'selected' in RadioControlOption

* Rename wc-blocks classes to wc-block

* Rename wc-blocks classes to wc-block (II)

* Make sure radio control ids are unique using withComponentId

* Load PanelBody and PanelRow from last version of @wordpress/components

* Create vendors-frontend.js file

* Load wordpress-component instead of @wordpress/components from <Button> component

* Only load 'withRestApiHydration' HOC

* Make vendors-frontend a dependency of cart-frontend script

* Revert "Only load 'withRestApiHydration' HOC"

This reverts commit 9f9b9759a98047b26e7d8f04189ffe78c1d5bb06.

* Fix fieldset background
2020-01-10 15:37:27 +01:00
Albert Juhé Lluveras f339e28310 Fix prices showing two currencies in some occasions (https://github.com/woocommerce/woocommerce-blocks/pull/1515) 2020-01-10 11:22:09 +01:00
Albert Juhé Lluveras 016b6b97ec Rename wc-blocks to wc-block classname prefix (https://github.com/woocommerce/woocommerce-blocks/pull/1541) 2020-01-10 10:42:53 +01:00
Albert Juhé Lluveras aa1d8e3e56 Fix Attribute Filter not reacting to query changes (https://github.com/woocommerce/woocommerce-blocks/pull/1540) 2020-01-10 10:42:37 +01:00
Rua Haszard 0763655d42 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-10 11:50:14 +13:00
Albert Juhé Lluveras 24fba4880b Fix minor issues with TextInput component (https://github.com/woocommerce/woocommerce-blocks/pull/1523)
* Set default value to TextInput component

* Set TextInput label transition origin

* Set default onChange function prop to noop

* Fix wrong propType name

* Remove default onChange and set it required
2020-01-09 19:06:49 +01:00
Darren Ethier b68b66542b add padding zeros to displayed prices (https://github.com/woocommerce/woocommerce-blocks/pull/1520) 2020-01-08 15:10:29 -05:00
Albert Juhé Lluveras 4be59b5ad1 Add ESLint radix rule (https://github.com/woocommerce/woocommerce-blocks/pull/1512) 2020-01-08 10:48:43 +00:00
Albert Juhé Lluveras 41633e136c Fix withFeedbackPrompt JSDoc definition (https://github.com/woocommerce/woocommerce-blocks/pull/1513) 2020-01-08 10:48:35 +00:00
Darren Ethier 8627b81c16 Add payment method api and components to checkout steps (https://github.com/woocommerce/woocommerce-blocks/pull/1349)
This adds a payment methods api to the checkout block that allows for extension to register payment methods with the block.
2020-01-06 17:28:09 -05:00
Albert Juhé Lluveras 44f70d8438 Fix Cart buttons misalignment in Firefox (https://github.com/woocommerce/woocommerce-blocks/pull/1446) 2020-01-06 12:46:00 +01:00
Albert Juhé Lluveras e082a14e3b Rename checkout classes from 'wc-blocks-xyz' to 'wc-block-xyz' (https://github.com/woocommerce/woocommerce-blocks/pull/1449)
* Rename checkout classes from 'wc-blocks-checkout' to 'wc-block-checkout'

* Rename form components classes from 'wc-blocks-checkout' to 'wc-block-checkout'

* Rename 'wc-components' class names to 'wc-block'
2020-01-03 15:23:49 +01:00
Albert Juhé Lluveras 892a56364c Fix empty cart inner blocks disabled (https://github.com/woocommerce/woocommerce-blocks/pull/1447) 2020-01-03 15:22:50 +01:00
Albert Juhé Lluveras 0a78174d25 Checkout: Fix city input field showing country value (https://github.com/woocommerce/woocommerce-blocks/pull/1467) 2020-01-02 17:36:56 +01:00
Albert Juhé Lluveras 5701f7d6c9 Price filter: allow any numeric input (https://github.com/woocommerce/woocommerce-blocks/pull/1457)
* Price filter: allow any numeric input in inputs

* Price filter: allow negative numbers in input fields (https://github.com/woocommerce/woocommerce-blocks/pull/1458)

* Price filter: allow negative numbers in input fields

* Always update input fields based on minPrice and maxPrice

* Don't default values to 0
2020-01-02 14:07:59 +01:00
Albert Juhé Lluveras 03bfa7d5a5 Remove outdated comments from useStoreProducts (https://github.com/woocommerce/woocommerce-blocks/pull/1466) 2020-01-02 14:00:50 +01:00
Albert Juhé Lluveras a538771bc1 Make price slider accurately represent the selected price independently from step (https://github.com/woocommerce/woocommerce-blocks/pull/1453) 2020-01-02 12:10:41 +01:00
Garrett Hyder 21f1d03199 Fix double 'yet yet' (https://github.com/woocommerce/woocommerce-blocks/pull/1421)
Found during translation of WooCommerce 
Permalink - https://translate.wordpress.org/projects/wp-plugins/woocommerce/dev/en-ca/default/?filters%5Bstatus%5D=either&filters%5Boriginal_id%5D=8771164&filters%5Btranslation_id%5D=68202906
2019-12-20 10:35:08 +01:00
Seghir Nadir aaddf13494 Add type to checkout input fields (https://github.com/woocommerce/woocommerce-blocks/pull/1401)
* add input type

* fix css issues with types and better change default position
2019-12-19 13:59:34 +01:00
Seghir Nadir cf495a775e Fix Price Filter constraints by rounding up and down (https://github.com/woocommerce/woocommerce-blocks/pull/1419)
* fix problem with price not rounding up right

* add test
2019-12-19 13:52:49 +01:00
Albert Juhé Lluveras 548b2b80a9 Update filter blocks descriptions to explain they only work with the All Products block (https://github.com/woocommerce/woocommerce-blocks/pull/1420) 2019-12-19 13:46:30 +01:00
Seghir Nadir ca506d0a48 fix translation quantities (https://github.com/woocommerce/woocommerce-blocks/pull/1415)
* fix translation quantities

* update i18n comments and add variable
2019-12-19 10:22:53 +01:00
Mike Jolley cfe55418b1 Translator string feedback (https://github.com/woocommerce/woocommerce-blocks/pull/1412)
* Translator comments need to immedietely precede strings

* Add some extra context to "chips"
2019-12-18 12:59:22 +00:00
Mike Jolley 6a47b2232a More API price formatting and currency handling (https://github.com/woocommerce/woocommerce-blocks/pull/1394)
* Consistent currency data and formatting for product prices

* Consistent get_store_currency_properties usage

* Update tests with schema changes

* min_price and max_price to subunit format

* Product query of min and max prices using subunit

* Cart item totals

* Collection data schema object and currency data inclusion

* Handle subunits and new API in product prices

* Update price slider to format numbers using library and new API responses for subunits

* Product query of min and max prices using subunit

* Fix indents in readme

* Add todo for currency formatting

* Handle step for subunits, fixes min/max constraints

* Handle subunit conversion on display, using consistent currency object and wrapped NumberFormat component.

* Prettier ran

* Update usePriceConstraints tests so rounding doesn't make all values be 0

* Rename to minorUnitValue

* Move currencyToNumberFormat to index file

* siteCurrencySettings to constant rather than function

* remove cents term

* cents->minor unit

* typo in todo note

* Switch to FormattedMonetaryAmount

* Formatting

* wrong case
2019-12-18 11:29:20 +00:00
Mike Jolley 9470caed80 Remove extra colon in active filter widget (https://github.com/woocommerce/woocommerce-blocks/pull/1399) 2019-12-17 18:32:32 +01:00
Darren Ethier b38c45787a fix incorrect property name for price format (https://github.com/woocommerce/woocommerce-blocks/pull/1397) 2019-12-17 10:25:37 +00:00
Albert Juhé Lluveras 506f964463 Update several blocks so they don't support HTML edition (https://github.com/woocommerce/woocommerce-blocks/pull/1395) 2019-12-17 09:38:31 +01:00
Seghir Nadir d58712ee2b Add Checkout Form components (https://github.com/woocommerce/woocommerce-blocks/pull/1351)
* initial commit at fields

* add radio control

* change input to be uncotrolled

* tweak styles

* populate block with boilerplate

* update aria in radio

* remove comment

* fix typo

* add missing colors

* put reminder to put Disabled back

* wrap text in i18n __

* reorder styles

* rename wc-components to wc-blocks

* use value instead of index for keys

* add no shipping placeholder

* change isEditor default to false

* fix problem with responsive
2019-12-16 23:13:41 +01:00
Albert Juhé Lluveras af5af78266 Price filter: preserve previous constraints while loading (https://github.com/woocommerce/woocommerce-blocks/pull/1386)
* Typo

* Save previous constraint while loading

* Add tests for formatPrice

* Small code refactor

* Refactor usePriceConstraints to DRY and add tests

* Add base-hooks to jest config
2019-12-16 17:48:02 +01:00
Albert Juhé Lluveras 77bb23bf32 Add Feedback Prompt in Cart & Checkout blocks sidebar (https://github.com/woocommerce/woocommerce-blocks/pull/1356)
* Add Feedback Prompt in Cart & Checkout blocks sidebar

* Add border

* Move getInspectorControls out of the component function

* Move feedback prompt to a HOC

* Add @todo comment to feedback link

* Use filter for withFeedbackPrompt

* Export withFeedbackPrompt from hocs index.js

* Typo

* Try moving the feedback texts to context

* Revert "Try moving the feedback texts to context"

This reverts commit 21f889b021ceea6fef722efab9663799829bc769.

* Revert "Use filter for withFeedbackPrompt"

This reverts commit 96bba029d61a383eafa2c0a1c08f7988e319b50d.

* Set feedback text in the HOC function

* Use arrow-function to simplify code

* Refactor
2019-12-16 15:59:16 +01:00
Albert Juhé Lluveras 6d383bee73 Fix Attribute Fiter count misalignment (https://github.com/woocommerce/woocommerce-blocks/pull/1391) 2019-12-16 14:58:29 +01:00
Albert Juhé Lluveras ec77f88a72 Reformat files (https://github.com/woocommerce/woocommerce-blocks/pull/1389) 2019-12-16 14:58:19 +01:00
Darren Ethier 25c32dff45 make sure we only allow one cart/checkout block per page/post (https://github.com/woocommerce/woocommerce-blocks/pull/1384) 2019-12-16 08:27:17 -05:00
Albert Juhé Lluveras a4be92ec15 Always filter attribute filters based on price filter (https://github.com/woocommerce/woocommerce-blocks/pull/1390) 2019-12-16 14:04:19 +01:00
Darren Ethier 80d76944cc account for default orderby changes in editor (https://github.com/woocommerce/woocommerce-blocks/pull/1385) 2019-12-16 07:35:13 -05:00
Darren Ethier 10c27e928d Only allow one instance of the All Products block per page/post. (https://github.com/woocommerce/woocommerce-blocks/pull/1383)
* only allow one instance of the all products block per page.

* limit filter blocks to one instance per page/post
2019-12-16 07:31:38 -05:00
Darren Ethier 762caa5aae Fix messaging when there are no attributes (https://github.com/woocommerce/woocommerce-blocks/pull/1382) 2019-12-16 07:28:03 -05:00
Darren Ethier 5ac157b14a Normalize set minPrice and maxPrice values by step (https://github.com/woocommerce/woocommerce-blocks/pull/1379)
* normalize set minPrice and maxPrice values by step

* follow standards for comment blocks
2019-12-13 16:54:35 -05:00
Albert Juhé Lluveras 5485e4c51c Use wc_review_ratings_enabled() API function to check if review ratings are enabled (https://github.com/woocommerce/woocommerce-blocks/pull/1374) 2019-12-13 18:13:11 +01:00
Albert Juhé Lluveras 810341d084 Add Cart block checkout button (https://github.com/woocommerce/woocommerce-blocks/pull/1366) 2019-12-12 20:46:56 +01:00
Albert Juhé Lluveras b5791d9c53 Rename SubmitButton to FilterSubmitButton (https://github.com/woocommerce/woocommerce-blocks/pull/1369) 2019-12-12 20:16:39 +01:00
Albert Juhé Lluveras bd4b57074e Load ErrorPlaceholder CSS only in the editor (https://github.com/woocommerce/woocommerce-blocks/pull/1368) 2019-12-12 20:16:11 +01:00
Darren Ethier cd25b1be07 Install bundlecop and configure in package.json size-check script (https://github.com/woocommerce/woocommerce-blocks/pull/1364)
* install bundlecop and configure in package.json size-check script

* update js doc to test bundlecop

* uninstall bundlesize package
2019-12-11 09:58:49 -05:00
Mike Jolley 5a1bbbefb9 Update NPM dependencies and script dependency handling (https://github.com/woocommerce/woocommerce-blocks/pull/1337)
* Update NPM packages

* Switch JSON dependencies to new PHP files

* include->require

* include->require

* Remove from package and run audit fix

* Update wp-prettier

* Use version from asset file

* Fix eslint issues and test failures

* Update OriginalComponent docblocks

* Props are objects, not arrays

* Array to Object

* fix tests throwing unhandled rejection errors in node.

These tests were all testing Promise.rejects but then not properly catching the reject in the assertions.

* exclude rule for no short array syntax allowed

This is a WordPress core standard that we choose to ignore because it’s silly in our context to follow that rule (and we’re being consistent with WooCommerce Admin).
2019-12-10 12:17:46 -05:00
Albert Juhé Lluveras bf260b0838 Add Empty Cart View with inner blocks (https://github.com/woocommerce/woocommerce-blocks/pull/1350)
* Add Empty Cart View with inner blocks

* Add logic so empty cart is always saved and only displayed when cart is empty

* Make cart hidden until the correct display is loaded

* Add missing propTypes

* Remove is-loading class

* Import InnerBlocks from @wordpress/block-editor

* Add explanation for always rendering EmptyCart in the editor
2019-12-10 16:41:57 +01:00
Albert Juhé Lluveras 0fa4dd05a5 Add 'Go' button to Attribute Filter (https://github.com/woocommerce/woocommerce-blocks/pull/1332)
* Add 'Go' button to Attribute Filter

* Code cleanup

* Fixes

* Avoid onSubmit being called in the editor

* Update attributes help texts

* Fix wrong input check box width
2019-12-06 16:36:55 +01:00
Seghir Nadir 58d4d73b51 Introduce Checkout Form skeleton and Checkout Form Step Component (https://github.com/woocommerce/woocommerce-blocks/pull/1329)
* introduce form steps

* add last step

* add prop types

* fix css color variable naming

* add label for a11y

* use :last-child

* white space

* use direct args in classnames

* typo

* rename ids for steps

* fix line height to match title

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* heading-content

* rename css var

* move vars to file

* move components within file

* move imports

* rename prop name to kebabCase

* update prop name

* make components responsive with storefront

* fix some compatiblity problems with 2020

* battle in the CSS ground

* move import to correct place

* turn stepHeadingContent to render prop

* styling
2019-12-06 14:18:55 +01:00
Rua Haszard 6afd947631 allow merchant to toggle cart empty/full modes in block editor (https://github.com/woocommerce/woocommerce-blocks/pull/1327)
* allow merchant to toggle cart empty/full modes in block editor

* use text `Button` for empty/full toolbar buttons

* fix highlighting of current cart state (empty/full) in editor:
- use new custom TextToolbarButton for empty/full mode buttons

* use color variables from css/abstracts/_colors

* Update assets/js/components/text-toolbar-button/index.js

Co-Authored-By: Seghir Nadir <nadir.seghir@gmail.com>

* fix className now props is separated out
2019-12-06 10:08:48 +13:00
Albert Juhé Lluveras 578ddbe94d Minor code style fixes in All Products blocks (https://github.com/woocommerce/woocommerce-blocks/pull/1330) 2019-12-05 17:03:31 +01:00
Albert Juhé Lluveras aa43840f13 Add 'AND' display format to Attribute filter dropdown (https://github.com/woocommerce/woocommerce-blocks/pull/1309)
* Add 'AND' display format to Attribute filter dropdown

* Add translators comments

* Remove 'assertive' from speak calls

* Wrap some functions in useCallback

* Only filter available filters if style=list and query=and

* Show placeholder in AND query type

* Add default cursor to list-item elements

* Fix issues with 20xx themes

* Fix issues with 20xx themes (II)
2019-12-05 14:58:44 +01:00
Albert Juhé Lluveras 41374cf5ea Fix price slider layout in narrow columns 2019-12-03 21:18:11 +01:00
Seghir Nadir ee1cdf7e0d Skeleton Checkout block (https://github.com/woocommerce/woocommerce-blocks/pull/1308)
* add checkout block

* prevent block from loading in wrong page

* remove block limitation

* exclude file from build

* rename todo

* remove fragment

* move files

* refactor example file
2019-12-03 15:12:46 +01:00
Rua Haszard 8e2b94fd69 Skeleton shopping cart block (https://github.com/woocommerce/woocommerce-blocks/pull/1306)
* basic empty cart block

* use a real placeholder for placeholder editor content

* remove unnecessary Fragment

* updates to config and frontend script

* enqueue frontend script

* add example config to block registration

* change name typo
2019-12-03 08:57:56 -05:00
Albert Juhé Lluveras f7c807a0c6 Add dropdown display style to Attribute Filter block (https://github.com/woocommerce/woocommerce-blocks/pull/1255)
* Add dropdown display style to Attribute Filter block

* Unify filter blocks margin

* Show attribute label inside dropdown input

* Minor CSS reorganization

* Refactor code to smaller files

* Preserve input values on blur

* Only save data-display-style if it's different than 'list'

* Remove inputRef prop in DropdownSelectorInputWrapper

* Accessibility: fix missing label

* Prevent input field being unselected when removing an item with the backspace

* Remove isLoading styles and don't set isDisabled when it's not actually disabled

* Accessibility: increase color contrast

* Add package-lock.json

* Prevent input field being unfocused when removing an item with its chip card

* Don't show menu when input is unfocused
2019-12-03 14:39:11 +01:00
Darren Ethier 1670757534 Remove with-query-string-values hoc implementation (https://github.com/woocommerce/woocommerce-blocks/pull/1287)
* remove with-query-string-values hoc implementation

* remove unnecessary passed in props and clean up proptypes

* remove dead code
2019-12-02 07:52:10 -05:00
Albert Juhé Lluveras aaa37637c2 Replace 'isPreview' with 'isEditor' when it refers to the editor (https://github.com/woocommerce/woocommerce-blocks/pull/1276)
* Replace 'isPreview' with 'isEditor' in several places

* Explicitly set props to true

* Add missing propTypes
2019-12-02 11:27:44 +01:00
Albert Juhé Lluveras 5698e123d3 Fix Price Filter block if minPrice or maxPrice are null (https://github.com/woocommerce/woocommerce-blocks/pull/1278) 2019-11-29 15:28:14 +01:00
Jeff Stieler fb8a21ba81 Add getAdminLink() to shared settings export. (https://github.com/woocommerce/woocommerce-blocks/pull/1244)
* Add getAdminLink() to shared settings export.

* Import getAdminLink from @woocommerce/settings

* Uninstall @woocommerce/navigation
2019-11-28 17:33:29 +01:00
Albert Juhé Lluveras ed4e4ad7b9 Use attribute label instead of slug in Filter by Attribute title (https://github.com/woocommerce/woocommerce-blocks/pull/1271) 2019-11-27 14:29:28 +01:00
Albert Juhé Lluveras ec4ae1269d Filter by Attribute: Allow reselecting unselected attribute (https://github.com/woocommerce/woocommerce-blocks/pull/1264)
* Filter by Attribute: Allow reselecting unselected attribute

* Run prettier
2019-11-26 17:43:27 +01:00
Seghir Nadir e8f0a071ba Fix bug with cart not updating (https://github.com/woocommerce/woocommerce-blocks/pull/1258)
* fix bug with add to cart

* prettier

* migrate to Event

* prettier

* Update assets/js/atomic/components/product/button/index.js

update to fix on sequential adds

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* Avoid dispatching cart update event on initial mount

* add condition to check if Event is defined
2019-11-26 11:26:53 -05:00
Seghir Nadir 998d3920c9 Fix color on pagination caused by Twenty Twenty (https://github.com/woocommerce/woocommerce-blocks/pull/1257)
* fix color on pagination caused by twentytwenty
2019-11-26 12:45:00 +01:00
Albert Juhé Lluveras ea1a31123f Fix wrong proptypes definition in BlockTitle component (https://github.com/woocommerce/woocommerce-blocks/pull/1259) 2019-11-26 12:16:28 +01:00
Rua Haszard 1ec624f2d7 Fix inconsistent heading editor styles for filter blocks (https://github.com/woocommerce/woocommerce-blocks/pull/1256)
* override title bg to transparent in editor for filter blocks
2019-11-26 11:56:14 +01:00
Mike Jolley c55a387657 Prevent multiple collection data requests using debounce (https://github.com/woocommerce/woocommerce-blocks/pull/1233)
* Add context for collection data query

* Introduce useCollectionData hook

* Implement hook in filter blocks

* Update API to handle nuances of counts instead of client side

* Clone requests so original is untouched

* Prevent dupe requests is working

* Cleanup

* Update assets/js/base/hooks/use-collection-data.js

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* Update assets/js/base/hooks/use-collection-data.js

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* Feedback

* Remove context
2019-11-23 17:04:30 +00:00
Mike Jolley c595444b7f Hydrate REST endpoint data in the stores (https://github.com/woocommerce/woocommerce-blocks/pull/1206)
* Helper to get namespace routes from the REST Api

* Add routes to store settings

* HydrateRestApiData component

* Correct usage of useSelect

* Remove lodash

* Move code to HOC
2019-11-23 16:29:35 +00:00
Darren Ethier 5c26249e26 don’t mutate default state constant. (https://github.com/woocommerce/woocommerce-blocks/pull/1245)
There was no need to have a const for the default state and also needed to make sure we’re not mutating it because it would result in the mutation of the default state.  This in turn meant that on the initial reducing action, the default state in the store would have a ghost value.
2019-11-22 15:18:45 -05:00
Seghir Nadir aa2e2d8f1e introduce block title component (https://github.com/woocommerce/woocommerce-blocks/pull/1240)
* introduce block title component

* style with prettier

* rename component class

* update readme
2019-11-21 18:21:14 +01:00
Mike Jolley 2f3c4623b7 Update `useQueryStateByContext` to remove need for context when setting values (https://github.com/woocommerce/woocommerce-blocks/pull/1239)
* Don't require context for set

* Update tests
2019-11-21 16:06:52 +01:00
Mike Jolley 6e2978413e level -> headingLevel (https://github.com/woocommerce/woocommerce-blocks/pull/1230) 2019-11-21 12:19:34 +00:00
Mike Jolley b96f568c2e Price Slider -- Only do instant updates if filter button is disabled (https://github.com/woocommerce/woocommerce-blocks/pull/1228)
* Only do instant updates if filter button is disabled

* Update assets/js/blocks/price-filter/block.js

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>
2019-11-21 11:53:08 +00:00
Albert Juhé Lluveras e3eebe89c2 Move ErrorBoundary to renderFrontend() function (https://github.com/woocommerce/woocommerce-blocks/pull/1226) 2019-11-21 09:09:14 +01:00
Albert Juhé Lluveras 4652ce1547 Honor CSS classes in editor (https://github.com/woocommerce/woocommerce-blocks/pull/1227)
* Honor CSS classes in editor

* Remove is-loading classes from editor

* Make sure we always destructure all attributes
2019-11-21 08:50:30 +01:00
Albert Juhé Lluveras 6f4a9e7782 Remove minConstraint and maxConstraint from price filter state (https://github.com/woocommerce/woocommerce-blocks/pull/1192)
* Remove minConstraint and maxConstraint from price filter state

* Remove 'useMemo' from minConstraint and maxConstraint

* Make sure minConstraint and maxConstraint are numbers before updating min/max prices

* Make sure non-valid price constraints don't make it to usePrevious

* Remove again track min/max constraint useEffect
2019-11-21 08:42:58 +01:00
Mike Jolley 0272c4472b Add no result templates (https://github.com/woocommerce/woocommerce-blocks/pull/1178)
* All Products block with filters: avoid showing loading placeholders if there are no results

* Hide sort select and show message when no products are available

* Add no result templates

* Remove product-grid

* Move images to assets dir

* Update images

* Switch functions to Components

* Capitals

* add missing context
2019-11-19 15:47:46 +00:00
Seghir Nadir bb0227edb1 Show number of reviews in each category in Reviews per Category block (https://github.com/woocommerce/woocommerce-blocks/pull/1177)
* Add reviews to Category endpoint

* add option to show categories with reviews

* update label text if we're using reviews for counting

* update reviews count to use raw sql

* add flag before querying review count

* add review_count to collection data & schema

* fix PR code review problems

* update tests to it expects the new collection param

* add note about review_count is schema
2019-11-19 16:22:16 +01:00
Albert Juhé Lluveras dceb2c6a0f All Products: avoid pagination disappearing when switching pages/changing sort value (take 2) (https://github.com/woocommerce/woocommerce-blocks/pull/1201)
* Use same query for headers collection

* All Products: avoid pagination disappearing when switching pages/changing sort value (take 2)

* Cleanup

* fixes after rebase

* Make it work after last rebase

* only do page change when queryState.page has changed.

* Fix woocommerce/woocommerce-blocks#1198 again

* Remove previousPage and isInitialized checks
2019-11-19 16:14:34 +01:00
Mike Jolley 8eec47e241 Use same query for headers collection (https://github.com/woocommerce/woocommerce-blocks/pull/1196) 2019-11-19 13:17:03 +01:00
Darren Ethier 2ca9f5eca2 Fix: Page selection will reset to 1 after deselecting filterable item, re-sorting products, and selecting new page. (https://github.com/woocommerce/woocommerce-blocks/pull/1205)
* initial commit

* change initialization state when user triggered page change
2019-11-19 06:20:23 -05:00
Darren Ethier 652aa0caa2 Fix paging issues (https://github.com/woocommerce/woocommerce-blocks/pull/1202) 2019-11-19 04:55:16 -05:00
Darren Ethier 3189a9483b Implement useProductLayoutContext for layout prefix in atomic blocks. (https://github.com/woocommerce/woocommerce-blocks/pull/1183)
* implement product layout context for product button

* convert product image component to functional component

- also implements useProductLayoutContext

* ensure edit context for AllProducts block has appropriate providers wrapping it.

* update price block with useProductLayoutContext

* convert ProductRating block to functional component and add useProductLayoutContext

* add useProductLayoutContext to ProductSummary

* update sale badge component adding useProductLayoutContext

* add useProductLayoutContext to ProductTitle component

* update ProductListItem component to add useProductLayoutContext

* update ProductList component to add useProductLayoutContext
2019-11-18 15:25:29 +01:00
Mike Jolley abd92e0c32 Filter block previews (https://github.com/woocommerce/woocommerce-blocks/pull/1184)
* Enable preview for price filter block

Using the defaults works fine, so no options required.

* Attribute preview via block attribute

* Add sample content for preview

* remove unnecessary key

* remove unneeded export
2019-11-15 16:10:49 -05:00
Darren Ethier cd3914b9a1 don’t use deprected imports (https://github.com/woocommerce/woocommerce-blocks/pull/1186) 2019-11-15 15:57:20 -05:00