Commit Graph

1123 Commits

Author SHA1 Message Date
Albert Juhé Lluveras 257c970726 Don't add the hidden class name to elements with the hidden attribute (https://github.com/woocommerce/woocommerce-blocks/pull/3582)
* Revert "Add 'hidden' class name when using the 'hidden' attribute"

This reverts commit 0332e33a60a516506718e8ed4659e45d32dc80a4.

* Add styles for hidden panel content

* Add docs about account for the hidden attribute in styles

* Update docs/theming/README.md

Co-authored-by: Rua Haszard <rua.haszard@automattic.com>

Co-authored-by: Rua Haszard <rua.haszard@automattic.com>
2020-12-22 10:26:59 +01:00
Seghir Nadir a713e56c7a use ReplaceMediaFlow in featured category and feature product (https://github.com/woocommerce/woocommerce-blocks/pull/3579)
* use ReplaceMediaFlow in featured category

* use ReplaceMediaFlow in featured product

* remove redudant prop
2020-12-21 17:09:10 +01:00
Seghir Nadir 94d8d580a2 Fix isDefault on Buttons and switch Toolbar with ToolbarGroup (https://github.com/woocommerce/woocommerce-blocks/pull/3577)
* Fix isDefault notice

* fix Toolbar to ToolbarGroup
2020-12-21 17:03:54 +01:00
Seghir Nadir 800f3c9624 Fix direct call to setState in EditProductSearch body (https://github.com/woocommerce/woocommerce-blocks/pull/3578) 2020-12-21 16:56:58 +01:00
Bartosz Budzanowski 9cfa54579d Fix data type used for paymentData.paymentMethods handling. (https://github.com/woocommerce/woocommerce-blocks/pull/3576)
* Fix data type for used paymentData.paymentMethods.

* This check is no longer necessary.
2020-12-21 16:32:59 +01:00
Albert Juhé Lluveras 7ea0aa4fbc Use em for coupon code button height (https://github.com/woocommerce/woocommerce-blocks/pull/3575) 2020-12-21 14:49:43 +01:00
Albert Juhé Lluveras 4197cfdb2d Add 'hidden' class name when using the 'hidden' attribute (https://github.com/woocommerce/woocommerce-blocks/pull/3569) 2020-12-21 14:47:51 +01:00
Albert Juhé Lluveras 5d01c8d781 Merge markup from Product Title atomic block and ProductName component (https://github.com/woocommerce/woocommerce-blocks/pull/3562)
* Merge markup from ProductTitle atomic block and ProductName component

* Add test

* Remove duplicate decodeEntities call

* Minor improvements
2020-12-21 14:45:27 +01:00
Albert Juhé Lluveras e3d97d7387 Fix Fees not visible in Cart & Checkout blocks when order doesn't need shipping (https://github.com/woocommerce/woocommerce-blocks/pull/3521) 2020-12-21 14:15:27 +01:00
Albert Juhé Lluveras 28ffe1be49 Replace IconButton component with Button (https://github.com/woocommerce/woocommerce-blocks/pull/3547)
* Replace IconButton component with Button

* Fix All Products editor.scss file not included by Webpack
2020-12-21 14:11:13 +01:00
Bartosz Budzanowski e2e934ec46 Remove customer saved payment methods from context if they are not enabled. (https://github.com/woocommerce/woocommerce-blocks/pull/3551)
* For gateways with disabled saved payment metods, don't show saved items in context.

* Fix style.

* Update name.

* Simplify and fix.

* Whitespace.

* Revert for another PR.

* Formatting fix.
2020-12-21 12:07:31 +01:00
Mike Jolley 55f0bc73a6 Fix Address Validation in the Store API and client (https://github.com/woocommerce/woocommerce-blocks/pull/3552)
* Trim input values before validation on Checkout

* Fixes required field checking at schema level

* Require country during checkout and ensure values are formatted

* Add handling for rest_invalid_param messages

* Remove prepare_address_fields - handled by schema

* Add address validation to OrderController

* Implement address validation

* Error errors from all endpoints more gracefully

* update non-true description

* required prop

* Update tests

* Fix equalityFn so updates are triggered when address changes

* Remove debounce so fields update if context changes

* Update src/StoreApi/Schemas/AbstractAddressSchema.php

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>

* Add missing wp_unslash

* Validate allowed countries should block checkout if no countries are allowed

* Type in locale variable

* Update assets/js/base/utils/errors.js

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>

* Fix validator calls

* Remove refererence

* Restore onChange order

* eslint fix

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-12-17 14:52:44 +00:00
Thomas Roberts ef081ef8a2 Fix select inputs when dark mode is enabled in Twenty Twenty-One (https://github.com/woocommerce/woocommerce-blocks/pull/3554)
* Add CSS rules for dark mode theme setting in Twenty Twenty-One

This is required because the theme may be set to dark mode independently of the browser. The reason we need two rules for this is because the checkout block can be set to have dark mode inputs too, so this rule doesn't need to apply then.

* Add theme-specific class for Twenty Twenty-One
2020-12-16 16:01:46 +00:00
Albert Juhé Lluveras 56485d6da5 Rename version compare functions to isWpVersion and isWcVersion and add docblocks (https://github.com/woocommerce/woocommerce-blocks/pull/3548)
* Add docblocks to compareWithWpVersion and compareWithWooVersion

* Rename functions to isWpVersion and isWcVersion
2020-12-15 16:10:24 +01:00
Mike Jolley 6e66799414 Update usage of legacy packages (inc. ServerSideRender) (https://github.com/woocommerce/woocommerce-blocks/pull/3541)
* Use the @wordpress/server-side-render package

* Add @wordpress/server-side-render dependency

* Update requiredPackagesInWPLegacy for 5.4 support

* Update package lock
2020-12-14 11:55:05 +00:00
Mike Jolley f459ad664c Switch to Fragment Short Syntax (`<>`) (https://github.com/woocommerce/woocommerce-blocks/pull/3536)
* Replace Fragment with shorthand

* Update eslint rules for short fragment syntax
2020-12-14 11:54:34 +00:00
Albert Juhé Lluveras 02174c5431 Add stories to Cart & Checkout totals components (https://github.com/woocommerce/woocommerce-blocks/pull/3533)
* Add stories to Cart & Checkout totals components

* Create @woocommerce/knobs alias

* Update TotalsFooterItem default values so they are in line with other stories
2020-12-14 09:15:50 +01:00
Albert Juhé Lluveras baa97e528f Update minimum required WP version to 5.4 (https://github.com/woocommerce/woocommerce-blocks/pull/3537)
* Update minimum required WP version to 5.4

* Remove WP legacy version check in blocks registration

* Remove no longer needed version check
2020-12-10 15:39:04 +01:00
Rua Haszard 87d9b01dfb Add storybook demo for CheckboxControl (https://github.com/woocommerce/woocommerce-blocks/pull/3030)
* story for CheckboxControl aka Checkbox

* Rename exported story to Default and use correct component name

This keeps our stories more consistent
2020-12-10 10:38:26 +00:00
Albert Juhé Lluveras 8d9d98d8e9 Add missing experimental functions to the feature flags page (https://github.com/woocommerce/woocommerce-blocks/pull/3522)
* Remove no longer used __experimentalPersistItemToCollection function

* Add __experimentalDeRegisterPaymentMethod and __experimentalDeRegisterExpressPaymentMethod to feature flags doc
2020-12-09 15:10:57 +01:00
Albert Juhé Lluveras bc40247d70 Rename Cart & Checkout totals components (https://github.com/woocommerce/woocommerce-blocks/pull/3520)
* Rename TotalsCouponCodeInput to TotalsCoupon

* Rename SubtotalsItem to Subtotal

* Rename TotalsDiscountItem to TotalsDiscount

* Rename TotalsFeesItem to TotalsFess

* Rename TotalsFooterItem folder

* Rename TotalsItem folder

* Rename TotalsShippingItem to TotalsShipping

* Rename TotalsTaxesItem to TotalsTaxes
2020-12-09 08:29:34 +01:00
github-actions[bot] dc5ad5701d Release: 4.0.0 (https://github.com/woocommerce/woocommerce-blocks/pull/3509)
* generating changeset for pull request

* generating changeset for pull request

* Update readme changelog

* Update requirements

* Testing instructions

* Update zip file

* Update nonce outside of json parse

* Set logged in cookie on store api requests

* Update zip

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Mike Jolley <mike.jolley@me.com>
2020-12-08 13:40:40 +00:00
Seghir Nadir 231d49406a Introduce pluginArea in Cart and Checkout (https://github.com/woocommerce/woocommerce-blocks/pull/3498)
* add plugin area

* add invisible errorBoundary

* move PluginArea to CheckoutProvider
2020-12-04 10:52:52 +01:00
Bartosz Budzanowski 2293e41f1d Fix:3501 Omit keys in `customerPaymentMethods` that have an empty list as a value. (https://github.com/woocommerce/woocommerce-blocks/pull/3502)
* Don't add empty methods key.
2020-12-03 19:33:33 +01:00
Albert Juhé Lluveras 2e5bcca7c6 Update @wordpress/components to v. 11.1.1 and @wordpress/base-styles to v. 3.2.0 (https://github.com/woocommerce/woocommerce-blocks/pull/3457)
* Update @wordpress/components and @wordpress/base-styles

* Fix JS warning in Select/downshift

* Remove color definitions that are now imported from @wordpress/base-styles. Fixes woocommerce/woocommerce-blocks#3311

* Use -unit values from @wordpress/base-styles. Fixes woocommerce/woocommerce-blocks#3313

* Update snapshots

* Fix payment methods test

* Don't extract dependencies that are not available in WP 5.3

* Avoid extracting @wordpress/compose since last version doesn't have resize observer

* Remove unnecessary uses of @wordpress/compose in a frontend scripts

* Add missing spaces
2020-12-03 14:04:25 +01:00
Rua Haszard ce6dd93e7b Handle change to logged-in status in checkout API AJAX requests (https://github.com/woocommerce/woocommerce-blocks/pull/3429)
* refactor and reorder checkout processing

* improve handling of checkout POST with mixed success:
- return coupon errors in a property
- don't throw from coupon validation:
  - return info about errors to route handler
  - tweak logic in route handler to prevent subsequent processing
  - default payment result to fail to avoid accidental successful checkout
- in client, catch errors and new customer id:
  - render any errors as notices - i.e. coupon error
  - if a customer ID is included, push into store (so UI updates)

* fix linter whitespace issue from rebase merge

* fix MIA order validation/errors (due to rebase):
- reinstate thrown exception when validating order
- return exception was an experiment, now solved in woocommerce/woocommerce-blocks#3454

* hide "Create account" checkbox if account is created during an error response:
- update store with new user id
- remove stale response.errors handling;
  - current approach (https://github.com/woocommerce/woocommerce-blocks/pull/3454) is to add data to error response

* show a notice informing user that they have signed up

* white space

* Handle header and update typedef

* Remove "errors" schema

* remove errors

Co-authored-by: Mike Jolley <mike.jolley@me.com>
2020-12-02 14:27:28 +00:00
Rua Haszard 0cb3b3d9a8 refactor and reorder checkout processing (https://github.com/woocommerce/woocommerce-blocks/pull/3454)
* refactor and reorder checkout processing

* move experimental order_processed hook as last step before payment:
+ flesh out docs - intention/purpose, introduced version, link to PR,
relationship to legacy hook

* return current user_id with checkout error responses, so UI can update

* clarify user id comment

* Add store API nonce to all responses

* catch new nonce & update store for POST /checkout errors

* ensure $order hook param and database are in sync

* fetchResponse->errorResponse

* Move payment method ID validation to schema

* Add the nonce inline

* Simplify error method

* Add todo for injection

* Hook docs

* Return user ID as a header instead of in error response

* Default to private methods

* Tidied processing logic/order save placement

* White space removal

* Remove duplicate comment

* Remove root slash

* Remove unused created variable

* Remove woocommerce_registration_error_email_exists filter in error message from API

* Move payment validation

* Moved comments

Co-authored-by: Mike Jolley <mike.jolley@me.com>
2020-12-02 12:22:42 +00:00
Albert Juhé Lluveras 5683ed1e54 Fix c notice close button color in Twenty Twenty One dark mode (https://github.com/woocommerce/woocommerce-blocks/pull/3472) 2020-12-02 13:09:57 +01:00
Albert Juhé Lluveras 281cc99291 Create IE11 SCSS mixin (https://github.com/woocommerce/woocommerce-blocks/pull/3473) 2020-12-01 09:04:52 +01:00
Albert Juhé Lluveras 0b2112c3d5 Prevent exclude drafts filter being tree shaken (https://github.com/woocommerce/woocommerce-blocks/pull/3463) 2020-11-25 13:46:13 +01:00
opr 704fab02d6 Reverse logic for hiding product name in checkout sidebar (https://github.com/woocommerce/woocommerce-blocks/pull/3464)
The hasLink prop was removed from ProductName and disabled is used instead, this change makes the variable name more descriptive, and uses disabled to signal if the ProductName should link or not.
2020-11-25 12:39:02 +00:00
opr 404e669f72 Change left margin of notice's dismiss icon to auto (https://github.com/woocommerce/woocommerce-blocks/pull/3455)
This is needed to ensure the dismiss icon in notices will always be as far over to the right of the parent container as possible.
2020-11-25 11:50:59 +00:00
Albert Juhé Lluveras 94064c1597 Fix checkbox and textarea styles in Twenty Twenty One when it has dark controls (https://github.com/woocommerce/woocommerce-blocks/pull/3450)
* Fix textarea styles in Twenty Twenty One when has dark controls

* Fix checkbox styles in Twenty Twenty One when has dark controls
2020-11-23 15:20:31 -05:00
Albert Juhé Lluveras e125dfd97b Fix radio controls and checkboxes in Twenty Twenty One dark theme (https://github.com/woocommerce/woocommerce-blocks/pull/3446)
* Fix radio controls in Twenty Twenty One dark theme

* Fix checkbox control in Twenty Twenty One dark theme
2020-11-23 14:43:36 -05:00
Mike Jolley cf9dc1b6bf Fix Twenty Twenty One Button and Placeholder Styling (https://github.com/woocommerce/woocommerce-blocks/pull/3443)
* Reset product list padding

* Adjust placeholder color if css variable exists

This is 2021 specific but may become more prominant.

* FIx editor button styles in 2021

* Adjust button sizes based on columns

* Adjust padding
2020-11-23 14:21:36 -05:00
Albert Juhé Lluveras 5a38fca235 Fix Twenty Twenty One Price filter, Active filters and radio control styling (https://github.com/woocommerce/woocommerce-blocks/pull/3444)
* Fix price slider styling in Twenty Twenty One

* Fix price slider styling in Twenty Twenty One

* Fix radio control styling in Twenty Twenty One and remove usage of mixin

* Force 0 padding on active filters list
2020-11-23 17:30:27 +01:00
opr a7461de3b3 Hide spinner on cart block's "Proceed to Checkout" link when page unloads (https://github.com/woocommerce/woocommerce-blocks/pull/3436)
* Hide spinner on cart's "proceed to checkout" button when page unloads

This is required because of a feature of Safari where the page state is saved, including all class names, when a transition occurs. Navigating using the back button restores the page to that cached state, so the spinner class remains on the button. Resetting the state just before the page gets cached stops this from happening.

* Change comment case to sentence case.
2020-11-23 13:20:04 +00:00
opr fcfe5ee7dc Stop hidden products from being linked in cart and checkout blocks (https://github.com/woocommerce/woocommerce-blocks/pull/3415)
* Add catalog_visibility to CartItemSchema.php

This is used to get whether the product is visible in the catalogue, visible in the shop only, visible in search results only, or visible everywhere. We need to know this so we can pass it to the ProductImage and ProductName components.

* Remove links from CartLineItemRow if not visible in catalogue

Added catalog_visibility to lineItems prop, and when the product is not visible in the catalogue do not wrap product image in a link. Also pass down the hasLink prop to ProductName.

* Add hasLink prop to ProductName

When this prop is false we should not output the link around the product name. This is for when the product is hidden from the catalogue but we still want to show its name somewhere.

* Add tests and storybook for ProductName

* Add catalog_visibility check to OrderSummaryItem

When the catalogue visibility of a product is set to hidden or search, then the product name in the checkout sidebar should not be hyperlinked.

* Reverse logic for hiding link on product image & disabling link on name

Following a point from @budzanowski we do not need the hasLink prop, making use of disabled is probably a better idea.

* Remove tabindex from a in ProductName & output span if name is disabled

This change removes the need to pass a tabindex to the a in ProductName. This is because a disabled ProductName will now never output an a tag. When the ProductName is disabled a span is output instead, which has no tabindex by default.

This change also reverses the logic to decide whether the a or span should be output so as to make the code more readable and flow better.

* Update storybook and tests/snapshots for ProductName
2020-11-23 13:03:08 +00:00
Darren Ethier 36d4123ba2 if express payment is active, don’t show payment method options (https://github.com/woocommerce/woocommerce-blocks/pull/3432) 2020-11-20 12:45:12 -05:00
Mike Jolley 76b62f514c Refresh PaymentRequest after cancelling payment to prevent addresses remaining populated on repeat attempts (https://github.com/woocommerce/woocommerce-blocks/pull/3430)
* Re-init after a cancelation

* Remove empty data when normalising

* combine conditonals

* Move callbacks within effect
2020-11-20 11:40:58 -05:00
Mike Jolley 849e351a0e Sync shipping address with billing address when shipping address fields are disabled (https://github.com/woocommerce/woocommerce-blocks/pull/3358)
* Correct docblock description

* Sync shipping address changes with billing data

* Update inline documentation

* Revert address sync because it fails when shipping is disabled explicitely

* Avoid loading shipping address from customer is shipping is disabled

* Rather than update order from the wc/store/checkout request, update the customer object

This is turn is synced to order, but also allows the cart calcultions to use the posted data. This means that taxes will be updated based on address data even if not displayed on the checkout.

* Add action that combines billing and shipping updates

* Add route for updating billing and shipping address

* Sync billing data to server on change

* Shared constants for billing data

* Skip address update if missing country

* Allow null values to skip formatting

* Add billing to cart schema

* Removed unwanted hooks from previous commit

* Decoding is handled in useStoreCart

* Remove hook

* Make shipping context hold state

* Make billing context hold state

* Add address processors

* Cart does not have billing

* Update tests, remove some unrelated changes affecting the diff

* Revert "Update inline documentation"

This reverts commit 0393f49316de3152c6dcf6fda1192c06a74f1b55.

* Make shippingRatesAreResolving conditonal based on API request

* Shared address processor in cart and checkout

* Rename REST endpoint

* CustomerDataProvider and hook

* Update shipping address type defs

* Rename customer address endpoint, and remove update-shipping

* Update tests

* Fix tests by restoring country validation

* typo

* Update assets/js/base/hooks/cart/use-store-cart.js

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>

* Simplify debounce and request handling

* Remove state from address sync

This will mean billing is "forgotten" if using the checbox, but this greatly simplifies logic.

* Rename shipping rates loading to customer data loading

* Sync based on useStoreCart data

* Made cart API less strict on addresses

* Fix useCheckoutAddress sync

* Add note on currentShippingAsBilling

* Use incoming isCart

* Add more detailed inline comment for shippingAsBilling toggle event

* Combine customer billing and shipping ref

* Update address docblock

* Error handling in pluckAddress

* Fix cart response after rebase

* Update customer tests

* Update src/StoreApi/Routes/CartUpdateCustomer.php

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-11-20 15:13:35 +00:00
opr 5ded3a9058 Ensure "Add a note to your order" section is styled correctly when disabled (https://github.com/woocommerce/woocommerce-blocks/pull/3427)
* Pass disabled prop to FormStep in order-notes-step.js

This way we can add the disabled class to the div or fieldset rendered by FormStep.

* Add disabled class & style for disabled FormStep components

Allows us to style disabled elements that cannot have the disabled attribute (divs) the same way as disabled fieldsets are.

* Update test snapshot for FormStep

This is because we added a class to the div/fieldset element when it is disabled.

* Remove redundant selector from form-step styles

Because we now add the --disabled modifier to the class, we no longer need the disabled selector. The new class-name based selector covers both fieldsets and divs.
2020-11-20 10:48:26 +00:00
opr 897abcb73a Prevent checkout step heading text overlapping actual heading on small viewports (https://github.com/woocommerce/woocommerce-blocks/pull/3425)
* Change style rules for checkout step headings

This is required because when the checkout heading text is too long it collided and overlapped the heading content due to its absolute position. In this commit we add a grey line to the left of the checkout step heading to ensure consistency with the checkout step container's styling.

* Remove position rule from checkout-step heading content

This was no longer needed as it nothing relied on the position of this element.
2020-11-20 10:44:24 +00:00
Mike Jolley caaf9e14c2 Improve Stripe (chrome pay) express payment method availability (https://github.com/woocommerce/woocommerce-blocks/pull/3424)
* Check price >= 30

* Force payment methods to react to order totals change

* Fix express payments reducer so it overwrites

* Fallback to 0 if undefined
2020-11-20 10:10:04 +00:00
Rua Haszard 8395954c7a Support a plain js config argument to payment method registration APIs (https://github.com/woocommerce/woocommerce-blocks/pull/3404)
* handle plain options passed to registerPaymentMethod:
- no need for a callback dance
- support the previous API: if a function is passed, call it as before

* update Stripe for new registerPaymentMethod interface

* update docs & all built-in payment methods to simpler API

* handle plain options arg to registerExpressPaymentMethod:
- add legacy fallback if passed a function
- update stripe express payment method
- update docs
- remove unused `assertValidPaymentMethodCreator` util

* use correct case for `JavaScript`

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>

* typedefs for payment registration options + tidies for regular methods

* typedef express payment options arg & tidy stripe/payment-request:
- use camelCase for config instance (not a constructor/type)

* mention typedefs in payment method dev docs

* use @wordpress/deprecated to warn if callback passed to payment register

* update unit tests for new payment method API

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-11-19 11:06:33 +13:00
Albert Juhé Lluveras 3f01676d16 Exclude checkout-draft orders from WC Admin reports and My Account > Orders (https://github.com/woocommerce/woocommerce-blocks/pull/3379)
* Exclude checkout-draft orders from WC Admin reports

* Hook into order query args

* Add comments before applying filters

* Revert "Add comments before applying filters"

This reverts commit 83b695665c05a3a9e7669e8777080c6ff10d8421.

* Revert "Hook into order query args"

This reverts commit 94cec6c83cf5b5ce05cd106daf217c0b08f13a03.

* Hide draft orders from My Account > Orders

* Move filter to its own file

* Use custom plugin namespace for filter
2020-11-18 10:11:37 +01:00
Mike Jolley ec22a5c6c4 Cart and checkout should respect the global "Hide shipping costs until an address is entered" setting (https://github.com/woocommerce/woocommerce-blocks/pull/3383)
* Remove custom fieldconfig for shipping calculator so required fields for shipping are collected

* If the store config requires an address before shipping, do not return rates or totals

Totals, calculated by the cart, would be set to 0 in this scenario which could lead to customer confusion (why is the rate $10 but shipping shown as $0?)

* The shipping total row is missing a border

* Revert "If the store config requires an address before shipping, do not return rates or totals"

This reverts commit f3a4f24f5785392eb43bfc69a5548d398c47d8bb.

* Add hasCalculatedShipping to schema and hooks

* Show shipping notices with updated wording based on if shipping has calculated yet or not

* Refactor shipping row display to use new API props

* Remove block level isShippingCostHidden

* fix test

* Correct the math in the shipping preview in cart

* Document null

* Remove test—this option no longer exists

* Remove unused settings/constants
2020-11-17 11:58:38 +00:00
Mike Jolley 7b9898deeb Fix cart block isLarge console error in the editor when running WordPress 5.6 beta (https://github.com/woocommerce/woocommerce-blocks/pull/3408)
* Remove isLarge prop from Button component

* More isLarge button
2020-11-17 11:07:26 +00:00
Mike Jolley 582d9e87fc Show Express Payment Method Error Notices after Payment Failure (https://github.com/woocommerce/woocommerce-blocks/pull/3410)
* Strip tags from stripe error notices

* Revise abortPayment - this does not need to provide or handle responses

* Decode entities in responseData

* Correctly handle checkoutResponse props

* Show one error at a time from express methods

* Set ID to context to avoid need to manually define it
2020-11-17 10:51:27 +00:00
Albert Juhé Lluveras 624a8601bc Fix: orders not being placed when paying with an Express payment method from the Cart block (https://github.com/woocommerce/woocommerce-blocks/pull/3403)
* Fix Express payment methods in Cart block

* Create a draft order inside get_draft_order_object() if the ID doesn't match a draft order
2020-11-16 13:12:56 +00:00
Mike Jolley f1df45ddd2 Show the phone number field in the billing section when shipping is disabled in settings (https://github.com/woocommerce/woocommerce-blocks/pull/3376)
* Add missing context docs for shouldCreateAccount

* shouldCreateAccount context docs

* No need to handle showOrderNotes in component—just don't render it

* Only render notes if needed

* Create PhoneNumber component to insert when needed
2020-11-09 11:00:31 +00:00
Darren Ethier f3fdbd7b59 Fix account creation bugs (https://github.com/woocommerce/woocommerce-blocks/pull/3371)
* account for registration enabled setting when creating accounts

* default to false instead of global setting for initial allowCreateAccount attribute

* consider global allows signup value for whether account creation checkbox shows

* include existing hook when determining if checkout signup is available:
- woocommerce_checkout_registration_enabled hook

* use public api for registration settings (via WC_Checkout)

* initial round of test fixes

* fix logic flaw exposed by tests and align tests with actual values in real use

* return early if WC_Checkout is not available

* remove temporary test group and uncomment new test.

* improve test method name

* fix comment to match new routine name

* ensure block shows login prompt when store disables checkout signup

* fix incorrect conditional order and cover with tests

Co-authored-by: Rua Haszard <rua.haszard@automattic.com>
2020-11-05 15:22:43 +13:00
Rua Haszard 01132107a4 Allow shoppers to sign-up for an account from the Checkout block (https://github.com/woocommerce/woocommerce-blocks/pull/3331)
* expose checkout signup feature to release build (feature plugin):
- remove isExperimental from block/editor js (the block is already gated
  to plugin only)
- gate entire service class to feature plugin && Woo >= 4.7
  - this ensures our custom email and set password flow are only active
    for supported woo version, if blocks plugin is active
  - also refactored the gating logic so the woo version check is used to
    gate all code

* eslint action told me to delete comment `.` ... ?

* remove experimental feature flag for checkout signup front-end:
- "Create Account?" checkbox in address/contact component
- logged-out prompt logic - handle case when signup is enabled and guest
checkout is not enabled, i.e. checkout requires automatic signup

* fix formatting issues

* add allowCreateAccount to proptypes for CheckoutForm and AddressStep
2020-10-29 10:42:49 +13:00
Albert Juhé Lluveras 109a7c3f54 Fix React hook dependency warnings in filter an All Products blocks (https://github.com/woocommerce/woocommerce-blocks/pull/3285)
* Fix wrong JSDocs

* Fix React hook dependency warnings in usePrevious hook

* Fix React hook dependency warnings in Filter an All Products blocks
2020-10-27 16:39:08 +01:00
Albert Juhé Lluveras 55e1a15149 Fix React hook dependency warnings in Cart & Checkout blocks + withAttributes HOC (https://github.com/woocommerce/woocommerce-blocks/pull/3314)
* Fix React hook dependency warnings in Cart & Checkout blocks

* Fix React hook dependency warnings in withAttributes HOC

* Fix select validation

* Fix test

* Remove unnecessary optional chaining

* Undo merge of two useEffects
2020-10-27 15:37:18 +01:00
Bartosz Budzanowski f66aa18e43 Change items organisation on smaller viewports. (https://github.com/woocommerce/woocommerce-blocks/pull/3299)
* Change items organisation on smaller viewports.

* Justify and gap.

* Align cost to quantity.
2020-10-27 15:23:27 +01:00
Bartosz Budzanowski abed796bd6 Respect Enable Taxes setting for checkout block taxe display. (https://github.com/woocommerce/woocommerce-blocks/pull/3291)
* Respect Enable Taxes setting for checkout block taxes display.

* Refactor logic into a named const.
2020-10-26 11:34:30 +01:00
Remi Corson 181797906a E2E WC Core Terms Consistency (https://github.com/woocommerce/woocommerce-blocks/pull/3310)
* E2E WC Core Terms Consistency

fixes 3309

* fix test text

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
2020-10-22 09:49:55 -04:00
Albert Juhé Lluveras 10ceda5851 Use @wordpress/base-styles and @automattic/color-studio as a base for our styles (https://github.com/woocommerce/woocommerce-blocks/pull/3300)
* Use colors variables instead of hardcoded values when possible

* Update WC colors from @automattic/color-studio

* Decrease specificity of price-slider CSS selectors

* Update colors to WC purple

* Update bright colors

* Update grays

* Update blacks and whites

* Add @todo comment

* Remove unnecessary blank line

* Remove purple color from price slider handle

* Fix colors not shown in SVG background

* Remove unnecessary box-shadow declaration

* Add theming docs

* Refactor/remove SCSS variables

* Add @todo comment to breakpoints

* Update package-lock.json
2020-10-22 12:40:32 +02:00
Albert Juhé Lluveras 4f60b6367e Fix 3D secure payment errors (https://github.com/woocommerce/woocommerce-blocks/pull/3272)
* Add errors to UI in onCheckoutAfterProcessingWithError

* Fix missing useEffect dependency

* Typo

* Reset source id if Stripe intent fails

* Remove default error on onCheckoutAfterProcessingWithError

* Add missing useEffect dependency

* Only add default error message if there is no errors in any other context

* Fix useEffect running too many times

* Add type-defs and minor improvements

* Only count error notices
2020-10-20 11:50:33 +02:00
Rua Haszard c7b4e3aa76 Use store-themed set password form for checkout signup (https://github.com/woocommerce/woocommerce-blocks/pull/3236)
* use my-account/lost-password endpoint url for set password (tbd):
- companion for working on https://github.com/woocommerce/woocommerce/issues/27754

* use more appropriate (new) set-password endpoint

* add version check - use new woo core endpoint if woo version is new enough

* use my-account/lost-password for setting password in checkout signup:
- this has been available forever - no need for a version check
- page will show `Lost password`; looking at options for overriding that

* use more explicit `newaccount` action for set password url if available

* tweak feature gating for checkout signup:
- only available in dev builds (will change soon)
- only available if Woo core 4.7 or newer
- checkout signup relies on fixes in 4.7+ (tbc) to
  my-account/lost-password endpoint for setting initial password
- standardise feature gate logic so is consistent, ensure feature is
  disabled in API/backend, hide editor option, and disable front end
- add new setting `wcVersion` to allow feature gating on woo version

* fix woo-version feature gate of checkout signup:
- fixed version logic, explicit 4.7.0 reference version
- refactor version compare routine so can be used for woo or WP version

* revamp Woo 4.7+ logic so PHPunit tests aren't dependent on Woo version:
- Woo-version feature gating is implemented at integration layer:
  - checkout REST API
  - register/override new account email handler
2020-10-15 14:13:49 +13:00
Farook Ibrahim b98dac6c62 Fixed: woocommerce/woocommerce-blocks#3084 (https://github.com/woocommerce/woocommerce-blocks/pull/3185) 2020-10-14 18:07:01 +01:00
Albert Juhé Lluveras 89a1ec7206 Ensure new payment methods are only displayed when no saved payment method is selected (https://github.com/woocommerce/woocommerce-blocks/pull/3247)
* Ensure new payment methods are only displayed when no saved payment method is selected

* Simplify logic

* Add tests

* Fix wrong props definition in JSDoc

* Use default parameter instead of default prop for functional component (Label)

* Remove usePaymentMethods mock

* Remove NoPaymentMethods mock

* Fix tests
2020-10-12 14:43:52 +02:00
Albert Juhé Lluveras e04e5d8033 Make 'retry' property on errors from checkoutAfterProcessingWithSuccess/Error observers default to true if it's undefined (https://github.com/woocommerce/woocommerce-blocks/pull/3261)
* Make 'retry' property default to true if it's undefined

* Create new shouldRetry method in useEmitResponse
2020-10-12 10:19:30 +02:00
Albert Juhé Lluveras b98ecd8116 Simplify emitEventWithAbort logic (https://github.com/woocommerce/woocommerce-blocks/pull/3256) 2020-10-09 10:52:04 +02:00
Albert Juhé Lluveras d90d7428bd Restore saved payment method data after closing an express payment method (https://github.com/woocommerce/woocommerce-blocks/pull/3210)
* Restore saved payment method data after closing an exprss payment method

* Fix wrong JSDoc props

* Add tests
2020-10-08 11:21:47 +02:00
Albert Juhé Lluveras e01e191397 Fix wrong propType introduced in woocommerce/woocommerce-blocks#3226 (https://github.com/woocommerce/woocommerce-blocks/pull/3242) 2020-10-06 15:58:41 +02:00
Albert Juhé Lluveras 2f7b0ba3b4 Don't load contents of payment method hidden tabs (https://github.com/woocommerce/woocommerce-blocks/pull/3227) 2020-10-05 15:25:40 +02:00
Albert Juhé Lluveras e486b8b906 Refactor payment methods components (https://github.com/woocommerce/woocommerce-blocks/pull/3226)
* Move 'renderedTabs' to its own component

* Move getRenderedTab to its own component

* Remove 'getPaymentMethod' function

* Fix wrong typedef

* Remove unnecessary useRef

* Simplify NewPaymentMethodTab

* Drop 'New' prefix from components name

* Add JSDocs to new components

* Add propTypes to new components
2020-10-05 13:59:20 +02:00
Rua Haszard f000fb4f7a Support "create account" option in checkout block (https://github.com/woocommerce/woocommerce-blocks/pull/2851)
* prototype 'create account' checkbox in checkout block

* expose store config for generating password/username  to blocks:
+ use FILTER_VALIDATE_BOOLEAN instead of hard-coded `yes`

* stub out signup form in checkout block

* context / provider to store checkout signup form data

* revert signup form - checkout block will always generate username etc

* persist signup checkbox in checkout state & pass to checkout API

* add `create_account` param to order API, fix name in client POST

* handle creating user account as part of order (first cut)

* ensure the order is associated with the new customer

* only show 'create account' checkbox when appropriate (guest checkout)

* remove unnecessary username/password variables

* refactor account-creation logic into functions:
- clarify inputs and outputs
- use RouteException for error handling
- use woo options directly, avoid dependency on WC_Checkout

* update "email exists" error message to use existing error message text

* handle all known errors from wc_create_new_customer + use core message

* only show "create account" checkbox to shopper when necessary:
- if guest checkout is disabled, user must create account - not optional

* only show "create account" if account creation is optional:
- fixes incorrect logic in previous commit
- add some comments to clarify

* fix create account logic in API when checkout requires account:
- use correct woo setting option name
- reverse logic to match option = allow guest false means registration required

* strip html tags from create account error messages

* temporarily force enable autogenerate user/pass in new account API

* fix rebase errors

* add new allowCreateAccount attribute in checkout block

* show/hide `Create account` checkbox dependent on block attribute:
- previously was dependent on store setting

* new create user API, with set initial password email (first cut):
- use core register_new_user for creating the user
  - this triggers core "set new password" email
- generate username using logic lifted from WC core
- rough cut, lots to tidy/polish here

* remove alternative/unused create account function

* set `Customer` role for signups during checkout

* eslint fix - switch case break

* remove comments that mirror code & might go stale

* tidy func comment

* remove unused function

* use store setting `allow signup` for default value of new block option

* refactor order signup logic to service class first cut:
- new CreateAccount service
- hook up via custom action (for now at least)
- paste over existing create account logic (temporary - will be replaced)

* adapt wc_create_new_customer logic in CreateAccount service (WIP)

* set default_password_nag on new account + throw instead of WP_Error

* rename `createAccount` => `shouldCreateAccount` to clarify meaning

* fix checkout block - renamed `shouldCreateAccount` (missed in prev commit)

* prototype sending alternative email template for checkout signup

* add magic link to set password to blocks new account html email

* tidy up new account email templates - set password link, subject/heading

* use same id so merchant setting tweaks apply to our new improved email

* remove logging

* code tidies in CreateAccount service:
- remove unnecessary constructor
- type-hint in should_create_customer_account
- streamline logic in should_create_customer_account - remove
unnecessary `empty` check
- add comments to illuminate different use-cases handled by should_create_customer_account

* don't provide password to new account email templates (no longer used)

* declare dependencies in root namespace

* code tidies on new account email class:
- correct namespace and camelcase name
- declare class in file, don't instantiate; instantiate in client code
(CreateAccount service) when used
- no require/file import, use `use`

* move CustomerNewEmail to folder matching namespace

* use Package->get_path for email template paths:
- CreateAccount service now depends on Package
- CreateAccount passes Package to email class so it can use `get_path`
- note: CustomerNewAccount is not registered with DI container as it
needs to be instantiated after Woo init (for `WC_Email`)
- shift email templates to {plugin}/templates, consistent with WP
convention

* call CreateAccount::from_order_request directly, no custom hook:
- custom hook is not appropriate as we may not want to allow
extensibility in this way - TBD

* add appropriate margin above create account checkbox

* remove unnecessary direct-access protection

* generalise name of error-handling method

* simplify CustomerNewAccount - instantiate directly, when needed

* remove unused new_account_email member - now instantiated on demand

* numerous fixes and updates due to rebase changes

* fix typo in name of CustomerNewAccount php file (missing `n`)

* experiment - link to lost-password form in my-account (prototype branded screen)

* Revert "experiment - link to lost-password form in my-account (prototype branded screen)"

This reverts commit e1dc6dd5e9f0218ede81da92188d813c2d0856d9.

* feature gate CreateAccount service init to dev build only +
+ remove stale comment

* feature gate front end "Create account" checkbox to feature plugin only

* feature gate editor "allow signup" option to dev build only

* feature gate checkout api create account - dev build only

* tweak feature gating PHP logic so it's robust:
- all PHP feature gating is in the service class
- all publicly-available methods return early if feature gate off
- Checkout rest API transparently calls service - no explicit feature
gate at API level

* ensure frontend/editor features are feature gated (isExperimentalBuild is a function)

* feature gate value of checkoutAllowsSignup - can only be true in feature plugin

* fix a / an typo in comment

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>

* remove commented code

* hello world unit test (doesn't test anything yet)

* add a command for running unit tests when container already up:
- this should probably move to another PR/branch

* basic tests of core logic in CreateAccount service

* import isExperimentalBuild direct:
- import from alias package was causing an issue, likely a dependency cycle

* refactor from_order_request to return new user ID so it's easier to test

* test creating a customer from an order + rest request:
- i.e. a full end-to-end integration test

* delete redundant test and tidy comments

* generalise test to provider format

* refactor create-dup-user err test to use same approach as success test

* add test for when user should not be created

* don't hard-code options in "create" test, remove redundant provider in no-account-requested test

* de-generalise "user already signed up" test

* add test for malformed email

* flesh out & comment successful signup tests

* flesh out "invalid email" tests

* clarify no account requested test comment

* remove phpunit:quick - I don't think it's needed

* add comment explaining this is an integration test

* experiment – disable feature flag, is this why the tests are failing?

* revert test commit - restore feature gate (experimental flag)

* skip all tests if CreateAccount is disabled due to feature flag

* d'oh - expose CreateAccount:is_feature_enabled so can be used in tests

* add jsdoc for checkout-state shouldCreateAccount field

* remove unnecessary comment + fix whitespace/indentation

* simulate logged-out user for createaccount signup tests

* use a single, compound if statement for early return (review nitpick)

* don't hide `checkoutAllowsSignup` store setting behind feature flag:
- the feature flag should be used to enable/disable behaviour
- it's dangerous to adjust store settings/options based on feature flag

* rejig tests so they require woocommerce_blocks_phase==3:
- make feature gate method private to avoid exposing
- remove feature flag check & test skip for other builds
- set blocks phase in travis config

* remove redundant user-logout in test setup - cleaner to just require this

* use WP function bracket style (same line)

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2020-10-01 15:07:16 +13:00
Albert Juhé Lluveras 1f8ea4f494 Remove selectedToken state from PaymentMethods (https://github.com/woocommerce/woocommerce-blocks/pull/3135) 2020-09-29 10:15:45 +02:00
Rua Haszard 7441ce6eec use the "light" bg colour for dropdown list by default (https://github.com/woocommerce/woocommerce-blocks/pull/3189) 2020-09-28 11:25:22 +02:00
Darren Ethier c844b41d6a enable testing-library/no-await-sync-query rule and fix rule violations (https://github.com/woocommerce/woocommerce-blocks/pull/3203) 2020-09-26 17:59:51 -04:00
Darren Ethier 1e6abded42 re-enable @wordpress/no-unused-vars-before-return eslint rule and fix violations (https://github.com/woocommerce/woocommerce-blocks/pull/3202) 2020-09-26 17:00:54 -04:00
Darren Ethier ba6a2e2ace re-enable @wordpress/valid-sprintf eslint rule and fix violations (https://github.com/woocommerce/woocommerce-blocks/pull/3201) 2020-09-26 16:05:00 -04:00
Darren Ethier a6750e0388 Fix esLint rule violations for @wordpress/i18n-translator-comments rule. (https://github.com/woocommerce/woocommerce-blocks/pull/3200)
* re-enable linting for @wordpress/i18n-translator-comments rule

* fix violations for the `@wordpress/i18n-translator-comments` eslint rule
2020-09-26 15:38:17 -04:00
Darren Ethier bb2acf726a Change default branch name to trunk (https://github.com/woocommerce/woocommerce-blocks/pull/3199)
* replace references to main branch with references to trunk

* update travis config to point to trunk not main branch

* more branch name changes
2020-09-26 13:28:16 -04:00
renovate[bot] 1dc8442a31 Update dependency wordpress-element to v2.17.1 (https://github.com/woocommerce/woocommerce-blocks/pull/3104)
* Update dependency wordpress-element to v2.17.1

* update experimental function to stable version

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-09-26 09:51:21 -04:00
Darren Ethier be66dc35fa Fix broken Express Payment Method use in the Checkout block for logged out or incognito users. (https://github.com/woocommerce/woocommerce-blocks/pull/3165)
* add experimental api for deregistering payment methods

Not going to promote this api just yet.

* fix for express payment method bug

Removes incorrect condition for the purpose of this effect. The Effect is expressly for setting a default active payment method if none is set. Since active payment methods might be either a registered express payment method or a registered payment method, the check for whether the payment method is included or not is breaking express payment method behaviour.

* add test for express active state and deactive state transition

* account for possibilitiy active payment method might not be currently registered.
2020-09-24 10:45:40 -04:00
Darren Ethier f915c7c8a3 re-enable dependency grouping linting and fix errors (https://github.com/woocommerce/woocommerce-blocks/pull/3167) 2020-09-21 09:43:10 -04:00
Darren Ethier 9115160c2f Enable and fix all jsdoc rule violations (https://github.com/woocommerce/woocommerce-blocks/pull/3168)
* add param jsdocs to satisfy jsdoc require-param rule

* Fix jsdoc-checktypes rule violations

* fix jsdoc/require-param-type rule violations

* fix jsdoc/check-param-names violations

* fix jsdoc/require-property-description rule violations

* fix rule violations for jsdoc/valid-types rule

* fix rule violations for jsdoc/require-property rule

* fix jsdoc/no-undefined-types rule violations

* fix jsdoc/check-types rule violations

* fix jsdoc/require-returns-description rule violation

* enable jsdoc/require-returns-type rule

* fix jsdoc/newline-after-description rule violations
2020-09-20 19:54:08 -04:00
Albert Juhé Lluveras f5b18f6fe1 Add useStoreNotices tests (https://github.com/woocommerce/woocommerce-blocks/pull/3162)
* Fix wrong type def

* Add useStoreNotices tests

* Use forEach instead of map
2020-09-18 14:50:45 -04:00
Albert Juhé Lluveras 261844d05b Use noticeContexts from useEmitResponse instead of hardcoded values (https://github.com/woocommerce/woocommerce-blocks/pull/3161) 2020-09-18 14:39:32 -04:00
Albert Juhé Lluveras d641d2e1a4 Don't throw an error when registering a payment method fails (https://github.com/woocommerce/woocommerce-blocks/pull/3134)
* Show all payment methods when it's an admin and let the error boundary handle errors

* Use StoreNoticesContainer in Payment method error boundary so notices have styling

* Filter out saved payment methods for admin users if they don't accept payments

* Simplify update options logic

* For admins, only show payment methods that errored but canPay was not false

* Simplify how new payment method option is appended

* Wrap canMakePayment in a try catch block to handle payment methods that throw an error

* Add an id to payment method error boundary errors

* Add an error boundary to express payment methods

* Hardcode failing content and savePaymentInfo to false if the payment method failed

* Add some new comments

* Add a notice instead of registering the payment method if it fails and user is admin

* Throw error early if stripe failed to load

* Split express and standard payment method error notices

* Don't add payment methods in the editor and instead add a notice

* Fix error id

* Use noticeContext constant

* Add missing JSdoc param

* Remove unnecessary removeNotice
2020-09-18 12:27:54 +02:00
Albert Juhé Lluveras a285376e96 Fix State label for Spain (https://github.com/woocommerce/woocommerce-blocks/pull/3147) 2020-09-16 10:50:24 +02:00
Seghir Nadir 62de2eb6fc Fix an issue with COD not showing when first enabled (https://github.com/woocommerce/woocommerce-blocks/pull/3088)
* Fix issue with COD not showing when first set

* generating changeset for pull request

* generating changeset for pull request

* change condition to arrays only

Co-authored-by: github-actions <github-actions@github.com>
2020-09-14 10:36:14 -04:00
Albert Juhé Lluveras 76ebf9c860 Merge ProductPrice atomic block and component (https://github.com/woocommerce/woocommerce-blocks/pull/3065)
* Merge ProductPrice atomic block and component

* Update assets/js/atomic/blocks/product-elements/price/block.js

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>

* Update assets/js/atomic/blocks/product-elements/price/block.js

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>

* If product price component has alignment, make it a block

* Make ProductPrice propTypes more specific

* Add align prop to loading product price

* Add stories to ProductPrice component

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-09-14 12:56:10 +02:00
Rua Haszard e5c9243f73 Ensure shopper saved card is used as default payment method (default was being overwritten in some circumstances) (https://github.com/woocommerce/woocommerce-blocks/pull/3131)
* bail out of setting a default payment method if shopper has saved card

* ensure default payment method is only set as active if necessary:
- use functional form of setState; previous state (current payment
  method) is not potentially stale value
- so the default is only set if there really is no active payment method

* remove unnecessary remnant hook dependency 🧟‍♀️
2020-09-11 08:48:23 +12:00
Darren Ethier 69ba8161b6 Add @woocommerce/eslint-plugin dependency (https://github.com/woocommerce/woocommerce-blocks/pull/3115)
* convert eslint config to use @woocommerce/eslint-plugin

- removes unnecessary dependencies
- adds e2e-tests/specs to eslint ignore (they are automatically generated)
- turns off rules that will be handled in subsequent pulls (to avoid a mammoth changeset for review).
- NOTE: prettier config needs left in because of a bug with the existing version of `@wordpress/eslint-plugin` pulled in (fixed in https://github.com/WordPress/gutenberg/pull/25068) so I left the file for now.

* prettier fixes.

* remove obsolete plugin and fixes for eslint update

This branch brings an update to eslint which also changes some syntax with plugins. So this commit:

- fixes featuer-flag plugin syntax.
- removed obsolete dependency-group plugin (which is now in the `@woocommerce/eslint-plugin` configuration.

* add to-do comment

* fixes for test runs

- this also converts our e2e test scripts to use `wp-script test:e2e`, an advantage of this is it will load CHROMIUM on demand for the e2e test run.

* fixes for test runs

- this also converts our e2e test scripts to use `wp-script test:e2e`, an advantage of this is it will load CHROMIUM on demand for the e2e test run.

* include prettier alias as a dependency

This has to be done because prettier is installed with storybook and thus the alias setup in `@wordpress/scripts` is over-ridden by the storybook import.

* another attempt at e2e-test-fix

* add some debugging and temporarily just add one e2e config test for travis

* more debugging

* try installing full puppeteer and see if fixes

* fix package-lock?

* setupSettings separately from other fixture loading

* add debugging of files

* add another console.log (hopefully trigger travis)

* split out blockPage creation to it’s own as well

* fixed! remove debugging and re-enable travis configs for entire test suite

* fix config and rename e2e-tests to e2e

- fixes the failing product-search test
- tests/e2e-tests was redundant, I changed to `tests/e2e` (this follows a file pattern change made in woocommerce core as well).

* add todo for some eslint properties

* remove unnecessary early function execution

* revert earlier commit and remove duplicate call to createBlockPages
2020-09-07 13:31:10 -04:00
Albert Juhé Lluveras a9bcdb7d08 Create DebouncedValidatedTextInput component (https://github.com/woocommerce/woocommerce-blocks/pull/3108)
* Fix wrong Form component name

* Split CheckoutForm into smaller components for each step

* Centralize call to useCheckoutAddress

* Create DebouncedValidatedTextInput component

* Rename some variables
2020-09-07 19:03:04 +02:00
Albert Juhé Lluveras 1e75a866d8 Split Checkout form component into smaller files (II) (https://github.com/woocommerce/woocommerce-blocks/pull/3106)
* Fix wrong Form component name

* Split CheckoutForm into smaller components for each step

* Centralize call to useCheckoutAddress
2020-09-07 17:43:05 +02:00
Albert Juhé Lluveras fa593359bf Fix Cart&Checkout layout broken in some themes (https://github.com/woocommerce/woocommerce-blocks/pull/3111) 2020-09-07 17:39:53 +02:00
Albert Juhé Lluveras dfd57b0ee8 useMemo for complex computations in Country/State inputs (https://github.com/woocommerce/woocommerce-blocks/pull/3107) 2020-09-03 10:02:26 +02:00
Rua Haszard 5c7447f434 Rename js/components to js/editor-components (https://github.com/woocommerce/woocommerce-blocks/pull/3069)
* mass-rename js/components => js/editor-components & update webpack

* mass-change import '@woocommerce/editor-components' +
+ jsprettier quotes fix

* more mass-rename @woocommerce/editor-components

* fix up references to js/editor-components in various places:
- docs/readmes
- jest config
- typescritp config

* fix story path to match new folder/alias 'editor-components'

* fix jest tests: use new alias for editor-components

* include renamed `editor-components` in editor stylesheet cache group
2020-09-02 10:21:46 +02:00
Albert Juhé Lluveras 4de3a0447b Fix product element styling class names (https://github.com/woocommerce/woocommerce-blocks/pull/3095)
* Update sale badge align class names to match other element blocks

* Update product price align class names to match other element blocks

* Fix Product title alignment class names. Fixes woocommerce/woocommerce-blocks#3094

* Make styling attributes apply to Product title block when it's not a link. Fixes woocommerce/woocommerce-blocks#3093

* Linting fixes
2020-09-01 16:52:25 +02:00
Seghir Nadir 4c371e064c Use wp_login_url instead of hardcoding login path (https://github.com/woocommerce/woocommerce-blocks/pull/3090)
* use wp_login_url instead of hardcoding login path

* generating changeset for pull request

* generating changeset for pull request

Co-authored-by: github-actions <github-actions@github.com>
2020-09-01 10:56:11 +01:00
Seghir Nadir d7a8328528 Fix JS console error when COD is enabled and no shipping method is available. (https://github.com/woocommerce/woocommerce-blocks/pull/3086)
* only return selected shipping methods from useSelectShippingRate

* add docs
2020-08-31 17:15:56 +01:00
Albert Juhé Lluveras 80400e50da Split Checkout block component into smaller files (https://github.com/woocommerce/woocommerce-blocks/pull/3062)
* Rename CheckoutForm to Form

* Create CheckoutForm component

* Simplify directory structure

* Add docs about class name changes

* Add PropTypes to CheckoutForm

* Update skeleton class name

* Extract LoginPrompt

* Move loginToCheckoutUrl to a constant

* Move replaced class name docs to 3.4.0 specific file
2020-08-31 12:17:42 +02:00
Rua Haszard 77aa2a33a3 clarify intentions / purpose of different component folders in docs (https://github.com/woocommerce/woocommerce-blocks/pull/3025)
* add high-level docs about our components & remove stale detail info

* use current collection/folder naming in docs:
- let's rename js/components in a separate PR
- split paragraphs on to separate lines to improve future diffs

* rename storybook.md => components.md and update link/summary

* tweak component collection docs:
- base have more stringent requirements, since they can be used anywhere
- editor components are less strict and can assume editor context

* clarify js/base/components readme in line with main doc

* remove line about editor components being specialised to woo blocks
2020-08-27 08:15:16 +12:00
Albert Juhé Lluveras 8d9de5c11c Fix discounted price misalignment in Cart block (https://github.com/woocommerce/woocommerce-blocks/pull/3047)
* Fix discounted price misalignment in Cart block

* Fix Product Price block alignment
2020-08-25 15:10:11 +02:00
Albert Juhé Lluveras a6178359bb Display Checkout block with a notice when adding a product sold individually that was already in the cart (https://github.com/woocommerce/woocommerce-blocks/pull/2854)
* Rename component to match directory

* Typo

* Checkout API: return cart errors as 'notice' property instead of throwing

* Checkout block: display server errors as notices

* Strip tags content

* Use same strings as in Core

* Add support for several notices

* Rename variables and allow all kind of notices

* Strip HTML tags and content in frontend

* Fix Checkout block in editor

* Add stripTagsAndContents tests

* Print notices before running blocks logic
2020-08-21 09:34:29 +02:00
Albert Juhé Lluveras 8bb217cec6 Show express payment methods in the Cart block (https://github.com/woocommerce/woocommerce-blocks/pull/3004)
* Shown express payment methods in Cart block

* Fixes

* Create usePositionRelativeToViewport hook

* Typo

* Style fixes

* Remove footer push div

* Styling fixes

* Improve code clarity

* Split ExpressCheckoutFormControl into two components

* Rename visibilityObserver to referenceElement

* Replace 'useEffect' with 'useLayoutEffect'

* Add tests for usePositionRelativeToViewport

* Self-closing div

* Add explanatory comment

* Create a shim for IntersectionObserver

* Update express payment components class names

* Add todo comment to remove IntersectionObserver shim when we drop IE11 support
2020-08-20 16:14:12 +02:00
Seghir Nadir 28d3bd7dda remove suspense polyfill (https://github.com/woocommerce/woocommerce-blocks/pull/3015) 2020-08-18 12:32:40 +01:00
Seghir Nadir 69ff731b4e use TextControl instead of PlainText (https://github.com/woocommerce/woocommerce-blocks/pull/3014)
* use TextControl instead of PlainText

* update e2e test

* revert changes for label

* update test
2020-08-18 12:25:48 +01:00
Darren Ethier c0dbb08ef9 Deprecate wc.wcSettings.setSetting function. (https://github.com/woocommerce/woocommerce-blocks/pull/3010)
* Add deprecation notice for setSettings

* add todo for followup issue to actually remove the function

* update todo

* fix tests

* fix todo

* Update assets/js/settings/shared/set-setting.js

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
2020-08-18 10:40:08 +01:00
Seghir Nadir 85ed96b58e Add dark colors support to Cart & Checkout controls (https://github.com/woocommerce/woocommerce-blocks/pull/2981)
* add dark styles setting

* add attributes to blocks

* add colors to input and select

* cover rest of items

* tweak select contrast

* fix ie11 issue

* fix focus

* include checkbox styles

* fix extra spacing after phone number

* add styling to quantity selector

* remove extra rule

* remove editor styles for radio control

* use border-color

* rename variables and classes and wording

* adjust colors

* provide tighter control over colors

* remove redudant outline rule

* add more variables

* add support for order note

* use variables for textarea

* move dark mode panel to last
2020-08-14 12:08:16 +01:00
Seghir Nadir 1fddb9451d Use real previews for the Cart and Checkout blocks (https://github.com/woocommerce/woocommerce-blocks/pull/2992)
* Use real previews for the cart and checkout

* remove extra files and css
2020-08-13 14:24:51 +01:00
Rua Haszard 39270f5657 Remove generic payment method icons (Stripe CC + Cheque) (https://github.com/woocommerce/woocommerce-blocks/pull/2968)
* remove generic icons from Cheque & Stripe CC payment methods

* remove icon prop from PaymentMethodLabel - no longer supported:
- icons should only be used for recognisable brands
- generic icons (e.g. credit card) are not recommended

* Revert "remove icon prop from PaymentMethodLabel - no longer supported:"

This reverts commit 1990028a6c98b82750fb917ff3086dbe022ef41d.
2020-08-12 08:44:19 +12:00
Albert Juhé Lluveras a16af68975 Hide saved payment methods if their gateway is disabled (https://github.com/woocommerce/woocommerce-blocks/pull/2975)
* Hide saved payment methods if their gateway is disabled

* Fix wrong type-def

* Remove extra blank line

* Rename var

* Use FILTER_VALIDATE_BOOLEAN instead of comparing to 'yes'

* Use data from Payment Method context instead of reading setting from the server

* Use data from Payment Method context instead of reading setting from the server
2020-08-11 15:43:03 +02:00
Albert Juhé Lluveras 339c0532f1 Fix text input and select error styles on focus (https://github.com/woocommerce/woocommerce-blocks/pull/2974) 2020-08-11 11:55:26 +02:00
Seghir Nadir 145db3ff5d fix issue with no margins on phone input (https://github.com/woocommerce/woocommerce-blocks/pull/2989)
* fix issue with overlapping margins

* move styles out of select

* remove extra spacing

* remove extra spacing from cart

* move styles to state input and remove extra position.
2020-08-11 10:00:53 +01:00
Seghir Nadir fc9f6fe71a Use SVG for checkbox (https://github.com/woocommerce/woocommerce-blocks/pull/2320)
* use svg for checkbox

* update borders

* switch to rems

* define a rem function

* fix ie11 issue

* fix focus

* add ie hack

* fix spacing and switch to em

* switch to rem
2020-08-11 09:59:59 +01:00
David Levin 4a8026623e It's its not it's unless it's it's. (https://github.com/woocommerce/woocommerce-blocks/pull/2988)
Co-authored-by: David Levin <davidlevin@Davids-MacBook-Pro-2.local>
2020-08-10 16:33:17 +01:00
Rua Haszard b8137587c3 Link cart/checkout merchant (editor) feedback prompt to special GitHub issue type (https://github.com/woocommerce/woocommerce-blocks/pull/2976)
* issue template for cart & checkout feedback

* fix example desktop OS (not iOS!)

* delete `withFeedbackPrompt` - not used

* link cart/checkout editor feedback to GitHub issue:
- add new CartCheckoutFeedbackPrompt with specialised text & url
- use in cart/checkout blocks
- tweaked wording of feedback prompt text

* use speech bubble icon to represent feedbackiness

* simplify cart/checkout feedback prompts

* add default labels to all issue templates

* use markdown heading syntax for headings (was basic bold previously)

* tweak wording (remove hint of frustration) and use new "feedback" label
2020-08-10 08:18:36 +12:00
Albert Juhé Lluveras dfec03202d Fix JS-rendered blocks inside Empty Cart (https://github.com/woocommerce/woocommerce-blocks/pull/2904)
* Fix JS-rendered blocks inside Empty Cart

* Add deprecation rules

* Performance improvements

* Typo

* Remove 'is-loading' class requirement

* Undo changes moved to woocommerce/woocommerce-blocks#2952

* Improve some comments

* Improve code

* IE 11 fix

* Minor fixes

* Assign default value in arguments destructuring

* Refacot renderFrontend code to make it easier to understand

* Revert "Assign default value in arguments destructuring"

This reverts commit 04ae943c675b94e599a1d1700075a79ef8be5004.
2020-08-07 13:33:32 -04:00
Rua Haszard e18c036f5e use static pos for payment errors so they push out other content: (https://github.com/woocommerce/woocommerce-blocks/pull/2977)
- default styling for validation errors is absolute
- this requires the layout provides appropriate space for errors
- payment form is too compact to provide room for errors,
  - especially when checkout is narrow due to window or theme
2020-08-07 07:30:27 +12:00
Mike Jolley b680686c34 Add inspector notice for unsupported product types (https://github.com/woocommerce/woocommerce-blocks/pull/2944)
* Add notice for unsupported product types

* Simple products can be added to cart, not others
2020-08-06 10:28:20 -04:00
Seghir Nadir 96819fc2d2 account for negative sale values (https://github.com/woocommerce/woocommerce-blocks/pull/2955) 2020-08-05 11:27:59 +01:00
Albert Juhé Lluveras fcf8f5c51f Show Checkout block in editor also when guest checkout is not allowed (https://github.com/woocommerce/woocommerce-blocks/pull/2958) 2020-08-05 10:35:38 +02:00
Albert Juhé Lluveras 5a300b91c2 Fix All Products block 'No products' placeholder link (https://github.com/woocommerce/woocommerce-blocks/pull/2961) 2020-08-05 10:35:08 +02:00
Rua Haszard afe77fb1e3 Show payment gateways in correct (merchant-configured) order (https://github.com/woocommerce/woocommerce-blocks/pull/2934)
* enqueue order of payment gateways as script data

* use configured gateway order for payment method tabs

* clarify name of payment gateway sort order setting

* fix formatting

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>

* fix bug - express payment methods not working due to ordering logic:
- move ordering code to payment methods in usePaymentMethods hook;
  - this only applies to standard (non express) payment methods
- also any code that uses payment methods will get them in correct order

* why did this formatting not happen pre-commit?

* move method ordering into refreshPaymentMethods to avoid infinite loop:
- pass keys of express payment methods so they work correctly (show up)
- refreshPaymentMethods dispatches availablePaymentMethods to redux
  store; I suspect this was causing infinite loop as the callback
  depends on registeredPaymentMethods
- handle case when a payment method is not in PAYMENT_GATEWAY_SORT_ORDER
  - this happens with COD when dependent on shipping

* fix formatting

* use shallow equal to prevent refreshCanMakePayments infinite loop

* use native Set instead of lodash.union for unique gateway names

* code formatting

* check to ensure we register paymentGatewaySortOrder asset once only

* fix COD tab showing out of order if not available at page load:
- return ALL gateways in sort order array
  - note this includes gateways that are not enabled by merchant

* reinstate return bool from usePaymentMethods hook (broken in refactor)

* add basic typedefs for payment methods hooks

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-08-05 13:56:33 +12:00
Albert Juhé Lluveras e73e5ba3fe Simplify reviews render method (https://github.com/woocommerce/woocommerce-blocks/pull/2952) 2020-08-04 10:29:02 +02:00
Albert Juhé Lluveras 3d0d6cab87 Add autocapitalize attribute to Address Form fields (https://github.com/woocommerce/woocommerce-blocks/pull/2884)
* Add autocapitalize attribute to Address Form fields

* Set autocapitalize attribute to 'sentences' in address form
2020-08-03 10:53:42 +02:00
Albert Juhé Lluveras 311d8ddf12 Add 'Order notes' to Checkout block (https://github.com/woocommerce/woocommerce-blocks/pull/2877)
* Add Checkout Order notes (UI)

* Add Checkout Order notes (context)

* Add missing useEffect dependencies

* Remove duplicate toggle in editor

* Minor fixes

* Check whether orderNotes have changed before creating a new state object

* Rename showCounter to showStepNumber

* Rename 'onChange' with 'onTextChange'

* Add comment and tests to FormStep component

* Rename 'with-counter' to 'with-step-number'

* Fix wrong prop

* Make it so order notes are persisted when toggling the checkbox

* Update type-defs

* Set showStepNumber default value to true
2020-07-31 17:17:01 +02:00
Mike Jolley 36c1bb7361 Add to cart context provider (https://github.com/woocommerce/woocommerce-blocks/pull/2903)
* Provider progress

* Revert nonce change for debugging

* Working emitters

* Fix dismiss link alignment in notices

* Fix button state and double adds

* Remove old context file

* Add type defs

* Fix context name

* Leftovers from merge

* Hooks up the variation picker to cart context

* Group event emitters in context

* Fix external product display

* Pass product through to VariationAttributes

* Pass around dispatchers

* Update assets/js/base/context/add-to-cart-form/form-state/reducer.js

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>

* Update assets/js/atomic/blocks/product-elements/add-to-cart/product-types/variable/variation-attributes/attribute-select-control.js

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>

* Update assets/js/base/context/add-to-cart-form/form-state/reducer.js

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>

* remove placeholder comment

* content->container

* Clarify variation method comment

* update comment

* Switch nesting of providers

* Variation attribute utils test coverage

* If nothing is selected yet, just return all variations.

* Comments to explain loops

* Use refs to avoid recalculation of attributes on every render

* Update memo usage

* typo

* move mock data to test file

* Switch to useShallowEqual

* trigger cart fragment refresh after add to cart

* Decode option entities

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-07-30 11:57:22 +01:00
Rua Haszard e2b82561bd enqueue and respect merchant option for disabling stripe express pay (https://github.com/woocommerce/woocommerce-blocks/pull/2920)
* enqueue and respect merchant option for disabling stripe express pay

* don't even register express payment method if merchant has disabled it

* add StripeServerData.allowPaymentRequest to typedef
2020-07-30 10:29:58 +12:00
Albert Juhé Lluveras 7e6968e68e Fix Reviews editor styles (https://github.com/woocommerce/woocommerce-blocks/pull/2941) 2020-07-29 16:07:21 +02:00
Albert Juhé Lluveras 8d21c7257e Fix reviews blocks in WP 5.2 (https://github.com/woocommerce/woocommerce-blocks/pull/2940) 2020-07-29 16:06:44 +02:00
Darren Ethier a0b28f2a06 Fix typo in state property for idle status in checkout state reducer (https://github.com/woocommerce/woocommerce-blocks/pull/2925)
* fix typo in state property for idle status in checkout state reducer

* remove arg causing failure in phpunit tests on travis
2020-07-29 13:00:26 +02:00
Rua Haszard 2cc98391a0 add hover style to ensure consistent margin/padding for order summary so it doesn't jump on mouseover (https://github.com/woocommerce/woocommerce-blocks/pull/2921)
* add hover style to ensure consistent margin/padding for order summary

* decrease specificity of panel__button hover/active etc styles
2020-07-29 11:50:06 +02:00
Darren Ethier 59ca5ad19c Release: 3.0.0 (https://github.com/woocommerce/woocommerce-blocks/pull/2887)
* add changelog to readme.txt

* Add testing docs for release

* add some new commands to help with release testing phase

* Add testing notes for 3.0.0

* fix testing note typo

* updae notest to reference the new package-plugin:deploy script for use as part of the release process

* Add note about creating manual tag for the release.

* automate creation of dev tag for release.

* remove release branch from travis branches because we now do pull requests for releases

* remove duplicate back order badge for cart (https://github.com/woocommerce/woocommerce-blocks/pull/2890)

* update zip link in testing notes

* only update stable version in readme.txt if not a pre-release

* Add handling for conditional github release creation based on WP deploy question

* add distignore fir wp deploy builds

* Cart & Checkout: fix '0' visible when product stock was 0 and it allowed backorders (https://github.com/woocommerce/woocommerce-blocks/pull/2891)

* Create wordpress-deploy.yml

* fix cod not accounting for global rate values (https://github.com/woocommerce/woocommerce-blocks/pull/2894)

* ensure we’re only running checks for `wc_reserved_stock` table when necessary (https://github.com/woocommerce/woocommerce-blocks/pull/2895)

* update readme.txt changelog

* remove unnecesary variable definitions

* update github deploy script

* Bumping version strings to new version.

* add missing step for checking out code from tag

* fix exclusion for docker-compose.yml

* fix zip name (it differs from repository name)

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2020-07-22 12:36:55 -04:00
Mike Jolley cd9f7e0ccb ⚛️ Introduce Product Element Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/2871)
* Product selection when out of context for price and title blocks

* Move product element name/description/icons to constant files

* Add attributes and hocs to all elements

* Standalone block rendering

* Add a placeholder if title has no content

* Revert "Add a placeholder if title has no content"

This reverts commit 29115154b33eedc661ccd3cc758acdbc5041ffbc.

* parentClassName is not always present

* Loading state

* Wrap description in P

* Fixed loading styles when nested

* Maintain product shape in useProductData

* feature gate elements from showing in inserter

* fix feature flag

* include price PR

* edit withProductSelector to be a hoc

* fix lint issue

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
2020-07-22 13:20:54 +01:00
Albert Juhé Lluveras ff2f135e7e Make stylesheets order consistent between build and dev (https://github.com/woocommerce/woocommerce-blocks/pull/2818)
* Add specific webpack config for styles

* Remove style.scss file from story

* Fix storybook

* Extract progressbarplugin config

* Add back ignore-loader

* Fix styling entries

* Cleanup

* Simplify webpack-entries.js

* Add appropiate exclude handles to styling config

* Add back MergeExtractFilesPlugin

* Unify style entries suffix

* Fix experimental flag

* Replace MergeExtractFiles plugin with RemoveFiles

* Prevent duplicate reviews frontend scripts

* Fix unnecessary files being created

* Remove editor.js file generate by MiniCssExtractPlugin

* Remove CSS generation from payment methods config

* Remove unnecessary config

* Simplify styling entries name

* Cleanup

* Refactor webpack-entries
2020-07-22 14:05:56 +02:00
Darren Ethier 21b7637ef5 fix cod not accounting for global rate values (https://github.com/woocommerce/woocommerce-blocks/pull/2894) 2020-07-21 15:57:21 -04:00
Albert Juhé Lluveras a69a50856a Cart & Checkout: fix '0' visible when product stock was 0 and it allowed backorders (https://github.com/woocommerce/woocommerce-blocks/pull/2891) 2020-07-21 17:41:14 +02:00
Seghir Nadir 9eabf73a65 Update ⚛️ Product Price (https://github.com/woocommerce/woocommerce-blocks/pull/2881)
* use currency as block symbol

* add color and font size support for price block

* support align

* revert to two options

* fix feature gating
2020-07-21 14:28:59 +01:00
Seghir Nadir 5299d7267b Update ⚛️ ‎‎‏‏‎ Product Title (https://github.com/woocommerce/woocommerce-blocks/pull/2860)
* rename heading-toolbar to heading-switcher

* update icon

* add controls to title block

* fix typos in css rules

* feature gate changes in Product Title

* fix jsdoc types

* fix onChange param

* fix missing textDomain

* fix modifier prefix

* move styling to util

* hardcode line height

* move settings near color
2020-07-21 14:27:41 +01:00
Albert Juhé Lluveras 4ef64a4453 Fix Credit Card input font size in some themes (https://github.com/woocommerce/woocommerce-blocks/pull/2869)
* Fix Credit Card input font size in some themes

* Fix spacing between credit card icon and input label

* Fix min-width of credit card input fields

* Improvements to the way credit card input fields are resized

* Simplify min-width
2020-07-20 13:56:22 +02:00
Rua Haszard aee97ceb3f Support cash on delivery payment method in checkout block (https://github.com/woocommerce/woocommerce-blocks/pull/2831)
* stub out COD payment method for checkout block

* consistently use sentence case for (default) payment tab labels

* expose COD `enable_for_virtual` option to client

* correct docblock return value comment Stripe::get_inline_cc_form()

* allow merchant to disable COD payment for virtual/downloadable orders

* tweak canMakePayment dev docs - add cart-dependent example use case

* only allow (show) COD if initially-selected shipping method(s) allow

* tweak `canMakePayment` payment extension API docs

* use $VID:$ substitution for `@since` version in new payment methods

* use FILTER_VALIDATE_BOOLEAN for payment method boolean options

* use more semantic `some` when hunting for COD-unsupported shipping

* clarify `canMakePayment` API docs

* re-select payment method if selected method disappears (e.g. COD) +
+ factor out early return into separate if at top for clarity
2020-07-15 10:14:41 -04:00
Albert Juhé Lluveras 8bfb95c808 Deregister core cart/checkout scripts and styles when rendering the blocks (https://github.com/woocommerce/woocommerce-blocks/pull/2842)
* Deregister core cart/checkout scripts and styles when rendering the blocks

* Fix regression: redirect to full cart when adding a product from empty cart

* Make it so it scrolls to the top

* Update assets/js/base/utils/legacy-events.js

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>

* Add check for jQuery availability

* Listen to removed from cart event too

* Remove unnecessary useEffect dependency

* Remove jQuery event subscriptions on component unmount

* Fix tests

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-07-14 15:46:44 -04:00
Albert Juhé Lluveras d894fed1df Cart block: show products on backorder (https://github.com/woocommerce/woocommerce-blocks/pull/2833)
* Show backorder notice in the Cart block

* Don't render variation <div> if empty

* Create ProductBackorderNotification component

* Add product backorder notification to the checkout block

* Fix classname and comment

* Rename notification->badge and don't show low stock badge if backorder is shown

* Use ternary to dispaly backorder/low stock badge
2020-07-14 17:25:53 +02:00
Mike Jolley be513c8875 Lazy Loading Atomic Components (https://github.com/woocommerce/woocommerce-blocks/pull/2777)
* Implement lazy loading with basics spinner

* Add chunkFilename

* chunkFilename breaks render

* Suspense at inner block level

* Suspense for all products block

* Update assets/js/atomic/blocks/component-init.js

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>

* Handle lazy components in registerBlockComponent

* update tests

* Update locks

* Update assets/js/blocks-registry/block-components/register-block-component.js

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-07-14 12:35:15 +01:00
Rua Haszard 1df11f5461 allow payment methods to disable based on shipping (API change) (https://github.com/woocommerce/woocommerce-blocks/pull/2840)
* allow payment methods to disable based on shipping or other factors:
- renamed 'initialized' array 'available' to match primary purpose of
  `canMakePayment` api - whether payment method should be available
- trigger refresh of available payment methods when shopper chooses
  different shipping method
- rename resolveCanMakePayments => refreshCanMakePayments
- tweaked some variable names and scope for clarity
- added comments to clarify things

Note this should not affect behaviour yet - no existing payment methods
use this new feature. COD payment method will need this - woocommerce/woocommerce-blocks#2831

* optimise refreshCanMakePayments:
- useShallowEqual to avoid unnecessary call when shipping methods have
not actually changed (but object value has)

* replace ("set") payment methods in store, was appending:
- payment methods may come and go depending on cart/checkout state
- the previous SET action appended provided payment methods to the
  collection
- this prevents dynamic payment methods e.g. COD from being able to hide
  i.e. disable

* cache test payment request to avoid unnecessary stripe API calls:
- in the canMakePayment callback there's a test payment to determine if
  chrome pay/apple pay is set up and available
- canMakePayment is now called multiple times as checkout state changes
- now the results of the test payment are stored in variable, and
  returned on subsequent calls

* set init flag to avoid additional attempts to init stripe API:
+ tweak naming of init flag
2020-07-14 10:52:13 +12:00
Albert Juhé Lluveras 0f43c3af0f Remove classes from dashicons (https://github.com/woocommerce/woocommerce-blocks/pull/2848) 2020-07-10 14:20:57 -04:00
Albert Juhé Lluveras 8c06276b00 Unify Chip styles (https://github.com/woocommerce/woocommerce-blocks/pull/2765)
* Improve cross character used in dropdown selector

* Add is-open and has-checked classes to dropdown selector so we stop relying on complex pseudoselector combinations

* Update Chip component with new props

* Update Chip styles

* Update dropdown selector selected chip with the Chip component

* Update active filters chip with the Chip component

* Style fixes

* Update snapshots and add tests

* Change onRemove prop signature

* Fix wrong bottom margin

* Fix misaligned remove icon

* Update assets/js/base/components/chip/index.js

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>

* Update assets/js/base/components/chip/index.js

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>

* Add missing default prop

* Prettier

* Ensure showScreenReaderText is a bool

* Rename removeOnClick with removeOnAnyClick

* Update snapshots

* Fix Chip aria-label logic

* Split Chip and RemovableChip

* Replace chip close character with an icon

* Fix outdated comment

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-07-10 11:09:49 +02:00
Rua Haszard 1d364a04bf Support bank transfer (BACS) payment method in checkout block (https://github.com/woocommerce/woocommerce-blocks/pull/2821)
* stubs for bank transfer payment method

* allow merchant to disable BACS payment method

* show customised BACS title & description in checkout

* re-add entry point for BACS payment method (lost in rebase)
2020-07-08 12:39:16 +12:00
Albert Juhé Lluveras 2fadea064e Document Cart & Checkout button styles (https://github.com/woocommerce/woocommerce-blocks/pull/2814)
* Reduce specificity of some button styles

* Submit container: make it possible for themes to change the shadow color without the need to rewrite shadow values

* Use background-color instead of background property in docs

* Add docs to style the button and the submit container

* Remove border from button

* Add back state styles to button component

* Docs improvements

* Undo unncessary changes in button component styles

* Add spaces
2020-07-07 11:59:51 +02:00
Mike Jolley 8cd96950e8 Reviews by product/category e2e tests (https://github.com/woocommerce/woocommerce-blocks/pull/2808)
* Tests for reviews by product

* reviews by category
2020-07-06 14:48:39 -04:00
Albert Juhé Lluveras 2013c5e0f5 Dashicon module replacement: prevent cloning a non-element (https://github.com/woocommerce/woocommerce-blocks/pull/2804) 2020-07-03 10:51:37 +02:00
Seghir Nadir 81570d733c Tweak some logic in our cart Integration test. (https://github.com/woocommerce/woocommerce-blocks/pull/2778)
* Fix Cart test async logic

* tweak test

* refactor test to not call response twice

* add comment for why we're calling fetch twice

* fix duplicate calls

* reset empty test to normal value

* switch to mockResponse

* convert comment to todo block

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-07-02 15:10:19 -04:00
Darren Ethier 4f5693e63c Add storybook story for icon library (https://github.com/woocommerce/woocommerce-blocks/pull/2787)
* modify dashicon replacements to be consistent with other icon exports

This also involved modifying the dashicon module replacement to use `cloneElement` instead of `createElement`.

* import from packages not global

* export woo icon consistent with other icons from the library

The Woo category icon was not using the Icon system and not exported consistent with other icons.

* add missing viewbox to arrowBack

* add story for icon library

* Update assets/js/icons/stories/index.js

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2020-06-26 10:22:41 -04:00
Mike Jolley c65fd05a73 Reorder dependencies (https://github.com/woocommerce/woocommerce-blocks/pull/2774) 2020-06-26 13:01:35 +01:00
Mike Jolley d25d233f27 Replace usage of `cart-checkout/button` with `@woocommerce/base-components/button` (https://github.com/woocommerce/woocommerce-blocks/pull/2781)
* Change to base component

* Remove todo
2020-06-25 16:50:48 +01:00
Albert Juhé Lluveras 3fae904643 Use WooCommerce thumbnail images in Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/2755)
* Remove legacy files

* Use thumbnail product image for Cart, Checkout and Reviews blocks

* Add option to toggle between full size and cropped image to the Atomic Product image block
2020-06-23 13:25:28 +01:00
Albert Juhé Lluveras b74b85dc03 Remove text color from Cart and Checkout blocks (https://github.com/woocommerce/woocommerce-blocks/pull/2745)
* Remove text color from Cart and Checkout blocks

* Fix Cart price column misalignement. woocommerce/woocommerce-blocks#2744
2020-06-23 11:13:53 +01:00
Mike Jolley 94306573bc Call add to cart in click handler (https://github.com/woocommerce/woocommerce-blocks/pull/2763) 2020-06-23 11:10:06 +01:00
Albert Juhé Lluveras dfa6fca924 Cart & Checkout: show shipping method prices with taxes depending on settings (https://github.com/woocommerce/woocommerce-blocks/pull/2748) 2020-06-22 10:47:35 +02:00
Mike Jolley 98d240d5e6 Introduce Variation Picker Component (https://github.com/woocommerce/woocommerce-blocks/pull/2497)
* Add attributes to API

* Add component

* API updates to return variation data

* Update to handle updated api responses

* Working picker

* Update tests

* update test

* Use SelectControl

* Add Picker to Form Block

* Code cleanup and splitting

* Inline todos

* Update todos

* Update assets/js/atomic/blocks/product/add-to-cart/product-types/variable/variation-attributes/index.js

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>

* change classname and move styles within component

* Correct conditional

* Avoid nesting filters

* Remove exclude from getVariationsMatchingSelectedAttributes

* basic select styles

* remove custom select styles

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2020-06-19 15:51:09 +01:00
Mike Jolley cae6cbb191 `registerInnerBlock` ->`registerBlockComponent` (https://github.com/woocommerce/woocommerce-blocks/pull/2688)
* registerBlockComponent

* BW compat and docs

* Add tests for deprecated methods
2020-06-17 14:10:46 +01:00
Albert Juhé Lluveras 610e082f9c Update base/components classnames (https://github.com/woocommerce/woocommerce-blocks/pull/2711)
* Update base/components classnames

* Fix class name conflict

* Fix some class names mismatch

* Fix review loading placeholder styles

* Fix docs format

* Update old class name

* Fix price slider regression

* Fix load more button component missing legacy class

* Fix wrong loading mask styles classname

* Remove 'checkout' from 'wc-block-components-checkout-payment-methods__save-card-info' classname

* Make it explicit legacy classes will be removed in the next major version

* Make product variation data styles belong to product metadata

* Improve docs sentence
2020-06-17 11:53:42 +02:00
Mike Jolley 09aa20d0d3 Introduce Atomic Add to Cart Block (https://github.com/woocommerce/woocommerce-blocks/pull/2705)
* Form/button stucture

* Use registerBlockComponent

* Context for add to cart form

* Working cart button

* Tidy up button component

* Add todos

* Revert reg block

* Hide stock indicator if not purchasable

* Hide terms if empty

* Add url and type to API

* Skip default category from term response

* Rename form element

* Form for product types

* Tidy up context provider and expand todos

* No longer using qty icon

* Update todos

* Correct text domain

* registerExperimentalBlockType

* Duplicate method

* Remove prevent default

* Update docblock

* Description for button code
2020-06-17 10:52:03 +01:00
Albert Juhé Lluveras b0ef232271 Fix Product Categories List align attribute (https://github.com/woocommerce/woocommerce-blocks/pull/2700)
* Fix Product Categories List with align attribute

* Add support to align attribute to the Product Categories List block
2020-06-16 13:18:04 +02:00
Mike Jolley 582ba8797f Update references to use main 2020-06-16 10:38:19 +01:00
Albert Juhé Lluveras 2004c48c5e Remove background color from Express Checkout title (https://github.com/woocommerce/woocommerce-blocks/pull/2704)
* Remove background color from Express Checkout title

* Fix Express checkout title padding not visible on npm run build

* Add explanatory comment
2020-06-15 13:39:46 +02:00
Darren Ethier 582b5f60bb convert code to be IE11 friendly (https://github.com/woocommerce/woocommerce-blocks/pull/2708) 2020-06-12 15:58:31 -04:00
Albert Juhé Lluveras f46bc68f6e Fix Cart and Checkout sidebar styling issues (https://github.com/woocommerce/woocommerce-blocks/pull/2694)
* Order summary: Add spacing between product name and price name

* Remove border from shipping options in the side bar

* Add a hasBorder prop to Panel

* Checkout Order summary: remove margin product description

* Fix padding when there are multiple packages and remove old code

* Simplify selector

* Add margin botton to no shipping options notice

* Make sure Checkout titles are aligned when there are no express payment methods

* Update step heading margins according to new designs
2020-06-12 14:07:02 +02:00
Albert Juhé Lluveras 1a0c50078a Add theming docs (https://github.com/woocommerce/woocommerce-blocks/pull/2691)
* Add theming docs

* Update some components to the new class name structure

* Add docs about class name updates

* Update coding guidelines

* Minor improvements

* Update docs/theming/class-names-update-280.md

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-06-11 19:38:31 +02:00
Mike Jolley 52496a3506 Stock Indicator Block (https://github.com/woocommerce/woocommerce-blocks/pull/2675)
* Stock Indicator Block

* Add to block map

* Put behind flag

* Move EditProductLink context

* stock text props
2020-06-11 10:02:00 +01:00
Darren Ethier 41ca430ffe Add initial cart flow tests (https://github.com/woocommerce/woocommerce-blocks/pull/2678)
* more setup configuration for rtl

* move default state for cart out of reducer

This also creates a file for default store states, it should make it easier to execute tests in various environments.

* Make sure there’s a default object for cart line item row

* set defaults for cartData

* add fetchMock as a global in eslint config

* add initial cart flow tests

This is just to get the ball rolling, the cart block needs more tests

* fix missing @wordpress/jest-console configs (because I overwrote the original configuration)

* update test because of change in branch

* switch import order

* add globals.d.ts file to declare globals we use.

This is a quick solution to prevent typescript linting warning about `fetchMock`. At some point we could also create a proper interface for it or import the types (if they exist) for the `jest-mock` package.

The new `globals.d.ts` file is excluded from published builds.
2020-06-10 14:21:34 -04:00
Mike Jolley 2c6d8d7f97 Add Atomic Category and Tag blocks (https://github.com/woocommerce/woocommerce-blocks/pull/2667)
* Add categories and tags to the API

* Add atomic categories block

* Add tag list block

* Add edit views

* Add correct icons

* Update styles

* Update assets/js/atomic/blocks/product/category-list/style.scss

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>

* Update margin

* Use registerExperimentalBlockType

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2020-06-10 16:56:13 +01:00
Albert Juhé Lluveras 9b05b19028 Add aria-expanded to Change address button (https://github.com/woocommerce/woocommerce-blocks/pull/2603) 2020-06-10 15:38:39 +02:00
Darren Ethier c25a45c3a4 Ignore dashicons imports (https://github.com/woocommerce/woocommerce-blocks/pull/2664)
* ignore dashicons imports

* need to provide a path to module replacement

* add in replacements for used dashicons

* fix spelling

* use classnames
2020-06-08 11:27:40 -04:00
Albert Juhé Lluveras f68f11c6ca Update Checkout step progress indicator design (https://github.com/woocommerce/woocommerce-blocks/pull/2649) 2020-06-08 13:13:34 +02:00
Albert Juhé Lluveras c4e7191269 Fix credit card validation errors alignment (https://github.com/woocommerce/woocommerce-blocks/pull/2662)
* Use same margin-bottom in credit card input as in checkout inputs

* Set cursor:text for Checkout input labels

* Increase line height of expiry and cvc input validation errors in large viewports

* Increase height of expiry and cvc input validation errors in small viewports
2020-06-08 12:55:10 +02:00
Albert Juhé Lluveras 40426cbf93 Fix styling issues introduced in woocommerce/woocommerce-blocks#2597 and woocommerce/woocommerce-blocks#2619 (https://github.com/woocommerce/woocommerce-blocks/pull/2652)
* Move order summary styles to component style.scss

* Fix wrong class name in Order summary

* Move express payment methods a little bit higher

* Fix shipping options panel misaligned in the Cart sidebar

* Add right padding to panel button so text doesn't overlap the arrow

* Fix wrong class name in Order summary (II)
2020-06-08 11:28:58 +02:00
Darren Ethier 2bbe2e63c6 Fix retrying after failed payment processed server side. (https://github.com/woocommerce/woocommerce-blocks/pull/2655)
* add state for selected saved token in payment data

* add handling for flipping payment status back to pristine when checkout has error

If payment status is successful client side, but the checkout state goes into an error after server side processing, then we reset payment status to pristine to allow for reprocessing of payment method client side.

This is skipped for saved payment method tokens because they effectively are _only_ processed server side.
2020-06-07 16:47:16 -04:00
Seghir Nadir 0ac76337d4 Expand Feature flags (https://github.com/woocommerce/woocommerce-blocks/pull/2591)
* Revert "Move blocks to stable flag (https://github.com/woocommerce/woocommerce-blocks/pull/2261)"

This reverts commit a005649ab8.

* migrate to number based gating

* add todo to watch feature flag

* remove flags from build

* change flag in travis

* load flag in right order

* expose flag to js

* simplify flag definition

* more feature flags

* wrap flag in check

* add helper functions

* add helpers in PHP

* fix typo in flag

* move php code to src/domain/package

* tweak if condition

* return flag to travis

* fix broken block name
2020-06-05 20:13:51 +01:00
Darren Ethier 5dafeac1ab Audit payment method interface API (https://github.com/woocommerce/woocommerce-blocks/pull/2622)
* remove obsolete useStoreOrder hook and implementation.

This hook was actually never completed and was only implemented in the `usePaymentMethodInterface` hook/api. The original purpose was to expose order details to registered payment methods, but that is now exposed via checkout state event emitters so it’s no longer needed.

OrderId is exposed via the `CheckoutState` context provider.

* remove setBillingData from being exposed to payment methods directly

billingData is updated via event emitter callback responses (see payment method data context provider) and is not something that should be set directly via payment methods.

We want checkout to have control over how billing data is updated in the state.
2020-06-05 11:20:05 -04:00
Albert Juhé Lluveras eaeedd31e0 Update item count badge styles (https://github.com/woocommerce/woocommerce-blocks/pull/2619)
* Update item count badge styles

* Make sure item count badge doesn't break in multiple lines

* Make item count badge have white background

* Add docs

* Move order summary CSS properties outside of the sidebar class to reduce specificity

* Move Order summary to its own component
2020-06-05 17:03:48 +02:00
Mike Jolley 2925d0d0ee Add Atomic SKU block (https://github.com/woocommerce/woocommerce-blocks/pull/2645)
* Add SKU block

* Edit product link in inspector
2020-06-05 15:36:07 +01:00
Albert Juhé Lluveras 1b51a8e050 Unify Cart headers (https://github.com/woocommerce/woocommerce-blocks/pull/2615)
* Unify Cart headers

* Change Cart title to 'Your cart (x items)'
2020-06-05 16:30:49 +02:00
Mike Jolley da58a8b44f Add Inner Block Rendering and Atomic Block Styles (https://github.com/woocommerce/woocommerce-blocks/pull/2607)
* Register Atomic Blocks and save some block content

* renderInnerBlocks utility

* Frontend Rendering

* Clean up atomic block classnames

* Move shared styles

* Create a hoc for attribute mapping

* Rename some unpluralised class names

* Remove prefixes from atomic component class names

* Updated styles

* Update styles from master

* Revert product list styles

* 2020 fixes

* Separate renderFrontend from renderInnerBlocks

* Lazy loading of components

* Tweak loading classes

* FIx all products loading state

* Revert lazy implementation - creates too many unneccessary files due to webpack config

* Cleanup

* Remove wcBlocksBuildUrl

* Move call to register_atomic_blocks

* Remove duplicate key

* reuse render frontend

* Corectly handle frontend attribute mapping to keep editor working

* Style updates

* Update side effects

* Remove width style from rating to fix alignment

* Move ssr grid styles to main stylesheet

* Put back prefixed classnames

* 2020 styling fixes

* Create frontend files instead of doing it all in block map

* Update assets/js/atomic/utils/get-block-map.js

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>

* Update assets/js/atomic/utils/render-parent-block.js

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>

* Fix last child alignment regardless of block type

* More specificity fixes

* 2020 button alignment

* static fix to prevent offsets

* fix placeholder image in firefox

* Issues reported in feedback

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2020-06-05 13:18:16 +01:00
Albert Juhé Lluveras 77b68795d8 Update Cart & Checkout heading styles (https://github.com/woocommerce/woocommerce-blocks/pull/2597)
* Honor heading styles in Cart and Checkout blocks

* Replace Panel with DisclosureWidget and remove Card

* Remove panel-style from main entry

* Rename DisclosureWidget props

* Simplify TitleTag assign

* Add aria-expanded attribute

* Rename DisclosureWidget to Panel

* Make Panel button clickable area smaller

* Fix specificity issues with Twenty Twenty

* Reset italics in reset-typography mixin

* Make C&C titles font size large

* Add padding to shipping options when in the sidebar
2020-06-05 12:00:19 +02:00
Albert Juhé Lluveras 8a65d7297b Make sure Select styles don't change on hover (https://github.com/woocommerce/woocommerce-blocks/pull/2647) 2020-06-05 11:12:34 +02:00
Albert Juhé Lluveras 13e79f21b4 Fix product grid blocks markup & design inconsistencies (https://github.com/woocommerce/woocommerce-blocks/pull/2428)
* Fix Sale badge markup discrepancy. Fixes woocommerce/woocommerce-blocks#2107

* Fix product link markup discrepancy

* Use same class name for ratings markup in product grid blocks

* Remove editor specific class name for product title

* Unify price layout between product grid blocks and All Products block

* Change specificity raising classes to avoid editor class names

* Make small images fill the available width in product grid blocks

* Avoid increasing selector specificity in the frontend

* Undo AbstractProductGrid.php template changes

* Do not remove .wc-block-grid__product-rating__stars from CSS

* Add theming docs
2020-06-02 17:06:28 +02:00
Mike Jolley 28d516050e Add context support to Atomic Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/2592)
* Bulk rename InnerBlockConfiguration to InnerBlockLayout context

* Refactor button to use context and handle null product data

* Move preview data to context

* Update blocks to support context

* fix button

* Update assets/js/atomic/blocks/product/title/block.js

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>

* remove falsey check

* Update product retrieval code

* Update product prop usage

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2020-06-02 12:14:46 +01:00
Albert Juhé Lluveras a6da13920d Fix Cart sidebar styles after font size changes (https://github.com/woocommerce/woocommerce-blocks/pull/2593)
* Fix Cart sidebar styles after font size changes

* Margin/padding cleanup
2020-06-02 09:33:10 +02:00
Albert Juhé Lluveras 31b5f4e00c Fixes to Twenty Twenty product grid styles (https://github.com/woocommerce/woocommerce-blocks/pull/2573)
* Remove underline from discounted prices

* Fix position of on sale badge in Twenty Twenty

* Make sure we reset styles from Core

* Fix image on sale badge not correctly positioned

* Fix sale badge alignment when they are on in the right
2020-06-02 09:18:34 +02:00
Albert Juhé Lluveras 00b0a81874 Make filter font sizes named (https://github.com/woocommerce/woocommerce-blocks/pull/2594) 2020-06-01 06:45:40 +02:00
Mike Jolley 2361c5f52c Add "edit product" card to single product block sidebar (https://github.com/woocommerce/woocommerce-blocks/pull/2585)
* Add edit product card

* Replace with div
2020-05-29 14:50:12 +01:00
Mike Jolley a5b09b7a43 Update atomic block structure (https://github.com/woocommerce/woocommerce-blocks/pull/2587)
* Move components to blocks dir

* Update import

* Create edit.js for each block

* Remove components/fix title

* Update imports

* Pass corect attributes on edit

* Import

* remove lightBlockWrapper
2020-05-29 14:49:56 +01:00
Mike Jolley 18480b0d68 Add layour editor to the single product block (https://github.com/woocommerce/woocommerce-blocks/pull/2586) 2020-05-29 12:28:04 +01:00
Albert Juhé Lluveras d1685bda7b Use named font sizes instead of values in px (https://github.com/woocommerce/woocommerce-blocks/pull/2533)
* Use named font sizes instead of values in px

* Convert rem mixin to em

* Remove unnecessary line-height

* 'Design' -> 'layout'

* Add comment to magic line-heihgt number

* Update a couple of class names to use BEM

* Use consistent name for SCSS variables

* Fix order summary line heights

* Update docs/contributors/coding-guidelines.md

Co-authored-by: Mike Jolley <mike.jolley@me.com>

Co-authored-by: Mike Jolley <mike.jolley@me.com>
2020-05-29 12:16:33 +02:00
Mike Jolley 597c9ded72 Single Product Block Edit Mode (https://github.com/woocommerce/woocommerce-blocks/pull/2577)
* Previews

* Edit mode

* Remove preview alt text

* Remove unused styles
2020-05-28 12:41:10 +01:00
Albert Juhé Lluveras 0ba29d28d4 Update placeholder styles (https://github.com/woocommerce/woocommerce-blocks/pull/2456)
* Convert several default buttons to primary

* Align primary and tertiary buttons

* Align select controls of placeholders

* Don't force a placeholder background color

* Add border to placeholder lists

* Add work-around for SearchListComponent compatibility with last version of @wordpress/components
2020-05-28 12:20:47 +02:00
Mike Jolley 2dc0e8112a Create shared contexts handle for inner blocks (https://github.com/woocommerce/woocommerce-blocks/pull/2568)
* Create shared contexts

* At to jest config
2020-05-28 11:02:10 +01:00
Albert Juhé Lluveras bc51052b04 Checkout steps improvements (https://github.com/woocommerce/woocommerce-blocks/pull/2530)
* Don't render step heading content if there is no content

* Make checkout step headings h2

* Add empty alt value to form step counter
2020-05-27 16:48:23 +02:00
Mike Jolley a06aa1eb39 Create single product block placeholder (https://github.com/woocommerce/woocommerce-blocks/pull/2569)
* Create single product block placeholder

* test

* Placeholder frontend js

* Update imports

* Update src/BlockTypes/SingleProduct.php

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>

* Update src/BlockTypes/SingleProduct.php

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2020-05-27 15:45:18 +01:00
Mike Jolley b062a67faf Accept object parameters in renderFrontend util (https://github.com/woocommerce/woocommerce-blocks/pull/2567) 2020-05-27 11:11:30 +01:00
Darren Ethier a5b6061dcc Ensure all inline @todos in code are covered by issues and obsolete @todos removed. (https://github.com/woocommerce/woocommerce-blocks/pull/2557)
* Remove todos for colors (see woocommerce/woocommerce-blocks#1331)

* remove todo for payment method express payments placeholder

No placeholder is needed because we don’t want to show this at all if there are no payment methods setup (or initialized based on `canMakePayment`). The payment methods step will have instructions in the editor for users to setup their payment methods.

So this todo was invalid.

* Remove todo comment for useStoreOrder (see woocommerce/woocommerce-blocks#2555)

* remove obsolete todos for usePaymentMethodInterface

* changed todo into a Note for the useQueryState tests

With focused work happening on tests, this is better as a note that can be picked up when this file is touched again.

* remove obsolete todo from payment method registration validation

* remove todo covered by created issue (see woocommerce/woocommerce-blocks#2166)

* remove obsolete todo for stripe utils

* Convert todo to a Note for Checkout Block php registration

For now, I think having the comment block noting what is happening here is sufficient. Whether or not we extend the blocks to cover the other endpoints is something that will surface in future planning and putting in an issue right now coudl be premature (and likely just land the issue in the icebox)

* Remove todo related to ReserveStock covered by woocommerce/woocommerce-blocks#2556

* Remove todo in AbstractRoute covered by issue in WooCommerce project

see https://github.com/woocommerce/woocommerce/pull/26219 for the issue.

* Convert todo to note for wp_version check in Library class
2020-05-26 13:31:33 -04:00
Albert Juhé Lluveras 79359e7056 Fix Cart style discrepancies (editor-frontend) (https://github.com/woocommerce/woocommerce-blocks/pull/2486)
* Fix different heading size of Cart block between frontend and editor

* Increase Cart submit button specificity so styles are applied in the editor

* Ensure buttons don't inherit borders

* Simplify styles

* Create Title component

* Rename 'level' prop to 'headingLevel'
2020-05-25 18:45:38 +02:00
Darren Ethier ce1e334c56 Fix broken dynamic address fields dependent on locale for selected country. (https://github.com/woocommerce/woocommerce-blocks/pull/2547)
* add missing dependency

* Don’t include all defaultAddressFields in address field config
2020-05-25 07:00:26 -04:00
Darren Ethier a5bca5708c Reakit tab already handles selecting the default tab if it isn’t set. (https://github.com/woocommerce/woocommerce-blocks/pull/2545) 2020-05-22 15:32:41 -04:00
Darren Ethier 5668f58f2c Include `onSubmit` handler for CheckoutForm component. (https://github.com/woocommerce/woocommerce-blocks/pull/2532)
* include `onSubmit` handler for CheckoutForm component and implement

* remove redundant preventDefault
2020-05-22 10:51:38 -04:00
Albert Juhé Lluveras 6d1cb26d63 Import TwentyTwenty block styles from Core (https://github.com/woocommerce/woocommerce-blocks/pull/2513)
* Add TwentyTwenty styles from Core

* Increase product on sale selector specificity

* Add theme class name to admin

* Fix some more style discrepancies

* Use em instead of rem
2020-05-21 19:09:50 +02:00
Albert Juhé Lluveras a59966350d Align Product Categories List select and button (https://github.com/woocommerce/woocommerce-blocks/pull/2517) 2020-05-21 10:53:13 +02:00
Albert Juhé Lluveras 60c0ebfdb7 Fix misalignment between value and label in form components (https://github.com/woocommerce/woocommerce-blocks/pull/2518)
* Fix misalignment between value and label in form components

* Do the calculation in SCSS
2020-05-20 15:54:37 +02:00
Albert Juhé Lluveras 0dc7e9e6f1 Fix decimal ratings not correctly displayed (https://github.com/woocommerce/woocommerce-blocks/pull/2507)
* Fix decimal ratings not correctly displayed

* Fix aria label rounding ratings
2020-05-19 17:24:20 +02:00
Albert Juhé Lluveras 8f2003df4b Remove some unique font-size (https://github.com/woocommerce/woocommerce-blocks/pull/2498)
* Remove font-sizes which are already inherited

* Remove font sizes from buttons with no text

* Make summary item quantity font-size 12px
2020-05-19 08:06:35 -04:00
Albert Juhé Lluveras b18e2a7d0d Add notices docs (https://github.com/woocommerce/woocommerce-blocks/pull/2502)
* Query state docs fixes

* Add notices docs

* Improve format

* Typo

* Avoid repeating in each method that current context is used.
2020-05-19 07:40:48 -04:00
Albert Juhé Lluveras 1fea56d8cd Remove class 'button' from Button component (https://github.com/woocommerce/woocommerce-blocks/pull/2494) 2020-05-18 12:53:57 +02:00
Albert Juhé Lluveras d91de709df Remove ProductPreview component (https://github.com/woocommerce/woocommerce-blocks/pull/2499) 2020-05-18 11:20:00 +02:00
Seghir Nadir c48518de54 Use Reakit in payment tabs (https://github.com/woocommerce/woocommerce-blocks/pull/2371)
* WIP

* convert to reakit

* rebase and fix styling issues

* add forget initialTabName

* delete button and force manual select

* fix git diff problem in package-lock

* directly render tabs

* fix regression

* gaurd against unset values

* update reakit and guard against empty tabs
2020-05-15 14:55:17 -04:00
Darren Ethier 121cf0a893 swap rate pricing for preview data (https://github.com/woocommerce/woocommerce-blocks/pull/2496) 2020-05-15 11:07:24 -04:00
Darren Ethier 519ca4febd Fix Editor performance issues with checkout block. (https://github.com/woocommerce/woocommerce-blocks/pull/2495)
* add missing typedef

* make sure default shipping address is consistent with everywhere else

* fix test for new expectation
2020-05-15 08:48:45 -04:00
Albert Juhé Lluveras b59a6d56e3 Checkout block: fix error 'setIsSuppressed' in editor (https://github.com/woocommerce/woocommerce-blocks/pull/2492) 2020-05-15 07:09:36 -04:00
Darren Ethier e2d6e4a038 Fix shipping rate and address handling in Stripe payment request payment method. (https://github.com/woocommerce/woocommerce-blocks/pull/2484)
* fix dependencies

* refactor stripe payment-request to extract things into smaller units

- adds/fixes typedefs
- fixes dependencies
- improves logic.

* implement memoizing for functions.

* if same shipping address is selected, just call updateWith immediately

* add separate handler for failed shipping rate retrieval

* improve logic around shipping rate fail/success status

* add notice suppression logic to store notices.

- this is implemented in checkout processor to suppress notices when express payment methods are active.

* add error detection for shipping address errors and update the shipping status accordingly

* update type-def

* set billingData before shippingData

This is needed because of the shipping data and billing data sync logic in use-checkout-address.

* have to tighten dependencies to prevent unnecessary firing

With us now adding error status setters for shippping, the potential for the shipping status changes to trigger the effect went up. So tightening the dependencies to only the stati we care about prevent unnecessary effect calls.

* refactor event handlers to be named and remove all listeners.

This is an undocumented api on the stripe `paymentRequest.on` return value, but I’m trusting it will be relatively stable for this api.

The need for this is caused by the fact that without it, the listeners are re-registered on the paymentRequest event everytime the paymentRequest modal is closed and reopened.

* fix typo in doc block
2020-05-14 19:55:22 -04:00
Rua Haszard 89f843b2b7 respect stripe saved cards store setting (https://github.com/woocommerce/woocommerce-blocks/pull/2455)
* expose a allowSavedCards option to JS on stripe settings data

* hide 'save my card' checkbox if merchant disables saved cards

* use stripe allowSavedCards option to control "Save my card" checkbox

* (linter) remove unnecessary useEffect dependency:

- stripePromise const is defined outside component, so hook doesn't
depend on it

* clarify comment about saved cards and supports( tokenization )

* correct comment about save card merchant option - doesn't affect paying with previously saved payment methods

* use true boolean value for stripe allow saved cards setting:

previously was using woo option `yes no` style, other JS settings all use true bool

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>

* fix client side check now `allowSavedCards` is true boolean

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-05-15 11:35:17 +12:00
Mike Jolley e5c500c70d Only set to pristine when checkout is idle, not when idle status changes (https://github.com/woocommerce/woocommerce-blocks/pull/2485) 2020-05-14 18:18:18 -04:00
Albert Juhé Lluveras 11981947c5 Add CSS resets for better theme compatibility (https://github.com/woocommerce/woocommerce-blocks/pull/2478) 2020-05-14 11:07:21 +02:00
Darren Ethier a5a62359d7 Fix all shipping address changes in stripe payment request timing out with no rate update. (https://github.com/woocommerce/woocommerce-blocks/pull/2482)
* remove unnecessary shipping field and shipping fields setter

* remove a commented out block

* account for billingData having values but billingFields not when shipping address changes.
2020-05-13 20:05:09 -04:00
Mike Jolley 24035a1508 Update Stripe Method to display generic icon and text in label, with cards below (https://github.com/woocommerce/woocommerce-blocks/pull/2466)
* Support card alignment as a prop

* Add generic card icon to stripe

* Add icons to stripe content

* Update styles

* Label element with icon whitelist

* Update assets/js/base/components/payment-methods/payment-methods.js

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>

* Remove activePaymentMethod

* Remove spread operator

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-05-13 16:48:03 +01:00
Mike Jolley 2395137790 Ensure email and phone are persisted through `setBillingData` (https://github.com/woocommerce/woocommerce-blocks/pull/2477)
* Force inclusion of email and phone

* Update deps

* update deps
2020-05-13 15:39:26 +01:00
Darren Ethier 0f53b24f1a Fix regression for payment methods in incognito mode. (https://github.com/woocommerce/woocommerce-blocks/pull/2473)
* ensure we set initial tab if it’s not set

* set appropriate defaults for supports if we don’t have payment method configuration object yet.
2020-05-13 05:34:05 -04:00
Rua Haszard f822e8dbb5 Ensure order summary is displayed :) - (https://github.com/woocommerce/woocommerce-blocks/pull/2470)
correct logic for early bail while container width thing is setting up
2020-05-13 09:54:44 +12:00
Mike Jolley 9caf01c354 Update wp.editor references, bump min version support (https://github.com/woocommerce/woocommerce-blocks/pull/2434)
* Update wp.editor references to wp.blockEditor

* Bump min version requirment to 5.2

* Update packages

* Revert "Update packages"

This reverts commit 7565c83a14fe8efd2e7c52473eeeaa5f837fa9fb.

* Undo server side render import changes

* bump min wp version variable
2020-05-13 08:31:49 +12:00
Mike Jolley 9a7658179b Refactor `usePaymentMethodRegistration` to ensure payment methods are populated once initialization is true (https://github.com/woocommerce/woocommerce-blocks/pull/2467)
* Refactor usePaymentMethodRegistration so initialisation happens at same point as dispatch

* Update NoPaymentMethods conditonal

* Suggested changes to payment init
2020-05-12 12:40:08 -04:00
Rua Haszard fd91263986 Allow shopper to save Stripe payment method in user account for subsequent purchases (https://github.com/woocommerce/woocommerce-blocks/pull/2453)
* always default "save my card for next time" checkbox to unchecked:

This is based on the previous checkout behaviour.
I.e. the shopper has to actively opt-in to save their card.

* Implement "save payment method for next purchase" in checkout:

- send "save card" option using existing post key
  - wc-stripe-new-payment-method
- comment out inappropriate use of "save" when using a saved card (tbc)

* don't hard code the payment gateway name in 'save payment method' key

* refactor "save payment info" checkbox so payment methods can opt-in:

- Add options.allowSavePaymentToken to payment method
registration / config.
- Opt-in in Stripe CC, it allows saved cards.
- Remove render of "save my card" checkbox from Stripe CC UI component.
- Render "save my card" checkbox automatically in payment method tab
(based on allowSavePaymentToken option).
+ todo/follow up comments

* rejig "save my payment method" behaviour so it's generic:

- Any payment method that supports "save" can opt-in:
  - options.allowSavePaymentToken = true/false
  - handle `wc-XXX-new-payment-method` key server side to persist
- Add support in payment context/state reducer for storing checkbox
state, expose value and action via context
- Convert state flag to appropriate API key/value in payment processor
- Remove previous stripe-specific implementation
+ bonus add comment to payment context about preserving state in
PRISTINE action

* rename payment method "allow save" option, more consistent with UI

* remove last vestiges of gateway-specific "save card" impl:

- No need to pass CheckboxControl to payment methods; checkbox is
now handled automatically by checkout.
- Remove shouldSavePayment prop passing through various layers of
stripe payment processing code. (Now handled in context/processor.)

* change new option property name and shape. Also adds validation.

* update type-defs

* use more reliable `activePaymentMethod` for saved payment method

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-05-12 11:12:28 -04:00
Mike Jolley 73abba295e Use display table instead of flex in radio control group (https://github.com/woocommerce/woocommerce-blocks/pull/2461)
* Use display table instead of flex

* Target direct child span only
2020-05-12 15:17:02 +01:00
Albert Juhé Lluveras 53c64600a3 Remove Shipping totals editor.scss file (https://github.com/woocommerce/woocommerce-blocks/pull/2465) 2020-05-12 15:56:09 +02:00
Mike Jolley fae3028c8a Update labels to match frontend sorting dropdown (https://github.com/woocommerce/woocommerce-blocks/pull/2462) 2020-05-12 11:05:38 +01:00
Darren Ethier 27508537f2 If product is changed for featured product block, update the link in the button. (https://github.com/woocommerce/woocommerce-blocks/pull/1894)
* If product is changed for featured product block, update the link in the button

* add handling to _only_ update the product url when the product is changed.
2020-05-12 05:08:53 -04:00
Albert Juhé Lluveras f09367b62f Add 'Handpicked Products' block keyword (https://github.com/woocommerce/woocommerce-blocks/pull/2463) 2020-05-12 10:47:57 +02:00
Mike Jolley 1d154364cb Introduce ContainerQueryContextProvider - hide order summary on mobile (https://github.com/woocommerce/woocommerce-blocks/pull/2432)
* Add ContainerQueryContextProvider

* Implement ContainerQueryContextProvider

* Rename based on feedback

* Update assets/js/type-defs/contexts.js

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>

* Update assets/js/type-defs/contexts.js

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2020-05-11 17:07:22 +01:00
Darren Ethier 4ad741329b Fix saved payment method selection not working for purchases. (https://github.com/woocommerce/woocommerce-blocks/pull/2425)
* fix arguments

* only set payment status to pristine if it isn’t already successful

* add server side handling for saved tokens

* ensure correct gateway is selected when using saved card:
- reset the active payment method when user selects saved payment method
(card); this ensures that the correct gateway is used when switching
from another gateway to a saved card

* enhance radiocontrol to receive option specific change events.

* implement specific option change events

This commit:

- ensures selecting a saved payment option updates active payment method for the selected option.
- Sets the saved token key for the selected option correctly.

* remove unnecessary php side code

* fix bug with default saved payment option not applying:

When the payment options are initialised, we now call the onChange
handler for the default (`is_default`) option. This triggers payment
success() so checkout succeeds with default payment method, even if user
doesn't touch payment options.

* fix effect dependencies

Co-authored-by: Rua Haszard <rua.haszard@automattic.com>
2020-05-11 09:29:57 -04:00
Seghir Nadir 39199778f8 fix broken cart styles in Editor (https://github.com/woocommerce/woocommerce-blocks/pull/2448)
* fix broken cart styles in Editor

* remove rule.
2020-05-11 13:12:47 +01:00
Darren Ethier e7781ba407 Fixes regression with payment method validation (https://github.com/woocommerce/woocommerce-blocks/pull/2450)
* add typedefs for store notice context

* improve useStoreNotices hook so returned interfaces are fairly constant

* fix dependencies, defaults, and add types

* fix dependencies

* fix dependencies

* improve functions exposed on validation context so they are more constant

* fixing dependencies

* normalize tokenId to string everywhere

Assuming the token is a number is a bad idea because it is feasible that source for some payment methods could be a string. Also when retrieved as an input value, the id will be a string anyways.
2020-05-10 19:41:10 -04:00
Darren Ethier ea3d817db1 Fix multiple extra stripe createSource requests than necessary (https://github.com/woocommerce/woocommerce-blocks/pull/2444)
* refactor to move payment processing into it’s own effect

- this is the first step in trying to improve the createSource behaviour.

* memoize setValidationErrors so onPaymentProcessing event effect doesn’t re-run unnecessarily.

* Update assets/js/payment-method-extensions/payment-methods/stripe/credit-card/use-payment-processing.js

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>

* fix docs alignment

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2020-05-08 11:32:20 -04:00
Mike Jolley 657e5005ff Fix X-WC-Store-API-Nonce updates (https://github.com/woocommerce/woocommerce-blocks/pull/2429)
* Move store api nonce js to separate middleware entry

* Make middleware a depedency of block-data

* Build
2020-05-08 10:39:03 -04:00
Albert Juhé Lluveras 76878eff0d Fix wrong frontend error button class names (https://github.com/woocommerce/woocommerce-blocks/pull/2431) 2020-05-08 09:02:18 +02:00
Albert Juhé Lluveras e970e4e86f SCSS mixins cleanup (https://github.com/woocommerce/woocommerce-blocks/pull/2405)
* Cleanup some old mixins

* Make font-size() mixin use parameters with units

* Remove hover-state mixin

* Cleanup mixins file
2020-05-07 10:48:38 +02:00
Mike Jolley 4436bdd23f Allow text inputs to focus on mount (https://github.com/woocommerce/woocommerce-blocks/pull/2416) 2020-05-06 15:04:00 -04:00
Mike Jolley dd811b1491 Update Stripe/payment payment notices (https://github.com/woocommerce/woocommerce-blocks/pull/2417)
* Update notices to say `card` instead of `card's`

* Track isEmpty per field so placeholders are not visible when focusing and defocusing other fields

* Make payment notices non-dissmissable, and removed on payment method switch

* Don't add validation notices

* implement nullish coalescing operator

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-05-06 14:58:31 -04:00
Mike Jolley 74a4e55075 Remove API summaries in favour of client side code (https://github.com/woocommerce/woocommerce-blocks/pull/2387)
* Remove summary from API

* Add wordCountType to assets

* Update packages

* Remove summary from test data

* Featured product uses short desc

* Pass description instead of summary

* Use new Summary Component

* Component and tests

* Increased versititilty of methods

* Update assets/js/base/components/cart-checkout/product-summary/index.js

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>

* Extra tests for html tags

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-05-06 11:30:15 +01:00
Mike Jolley 87e8b26e6f Store billing address to local state and persist globally to prevent loss of data (https://github.com/woocommerce/woocommerce-blocks/pull/2374)
* Remove unused shippingAsBilling prop from billing data context

* Move functions out of component and add docblocks

* Local address state

* Refactor into new custom hook

* Remove TODO and code fixed in core

* useShallowEqual to prevent updates on all field changes

* Fix stale validation errors

* cleanup

* Should be setting local state not global state for email and phone

* Combine useEffects and pass correct deps

* Update assets/js/base/hooks/checkout/use-checkout-address.js

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>

* Prettier

* Move validation update check into updateValidationError

* Fix state updaters

* Fix context definition for setShippingAddress

* Fix validation updates

* errorId dep

* Reapply changes to checkout block

* Update equality checks

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
2020-05-06 11:21:30 +01:00
Rua Haszard 44346274d2 clarify various checkout block editor sidebar wording (https://github.com/woocommerce/woocommerce-blocks/pull/2401)
* tweak various checkout block editor sidebar wording

* fix accidental sentence-casing of Return to cart label
2020-05-06 09:25:41 +12:00
Rua Haszard 440ee2e3b1 move checkout submit & related elements into "main" element (https://github.com/woocommerce/woocommerce-blocks/pull/2400) 2020-05-05 14:19:47 +01:00
Albert Juhé Lluveras 30c281c524 Use container queries to load Cart and Checkout responsive styles (https://github.com/woocommerce/woocommerce-blocks/pull/2370)
* Use container queries to load Cart and Checkout responsive styles

* Update package-lock.json

* Make form-step react to container queries instead of media queries

* Make sidebar layout inner padding relative to the full-width

* Make container queries breakpoints smaller
2020-05-05 10:10:02 +02:00
Rua Haszard b7d4b48b57 remove radius from Checkout submit, consistent with theme buttons (https://github.com/woocommerce/woocommerce-blocks/pull/2390) 2020-05-05 08:13:13 +12:00
Rua Haszard 9d0217419c decode html entities in ProductName component (https://github.com/woocommerce/woocommerce-blocks/pull/2389) 2020-05-04 15:44:23 -04:00