Commit Graph

104 Commits

Author SHA1 Message Date
Alba Rincón 6ca9f90c44 Fix ESLint errors (https://github.com/woocommerce/woocommerce-blocks/pull/7556)
* Add type to imports that need it

* Add type to imports that need it

* Fix the sanitize lint error

* Include missing dep

* Remove check from deps

* bot: update checkstyle.xml

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-11-02 17:46:14 +01:00
Luigi Teschio 6bbf96d06a Add CI for monitoring TypeScript errors (https://github.com/woocommerce/woocommerce-blocks/pull/6106)
* Add a action that monitors TypeScript errors woocommerce/woocommerce-blocks#6068

Add a action that monitors TypeScript errors

* address feedback

* bot: update checkstyle.xml

* add @bartekbp/typescript-checkstyle as devDeps

* bot: update checkstyle.xml

* bot: update checkstyle.xml

* bot: update checkstyle.xml

* fix

* add checkstyle to .distignore

* add missing import

* address feedback

* fix error

* remove import

* fix name variable

* fix sort function

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2022-11-02 11:41:10 +01:00
Alex Florisca 4a82b73baf Fix failing filter test (https://github.com/woocommerce/woocommerce-blocks/pull/7253) 2022-09-30 08:38:34 +07:00
Niels Lange c360c5654a Add filter for place order button label (https://github.com/woocommerce/woocommerce-blocks/pull/7154)
* WIP add filter for place order button label

* Solve TS issue

* Add display priority

* Refactor display priority

* WIP Implement useMemo()

* Try using a global cache

* Add docs for placeOrderLabel filter

* Update docs/third-party-developers/extensibility/checkout-block/available-filters.md

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

* Adjust docs

* Rename “placeOrderLabel” to “placeOrderButtonLabel”

* Update assets/js/types/type-defs/payments.ts

Co-authored-by: Alex Florisca <alex.florisca@automattic.com>

Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
Co-authored-by: Lucio Giannotta <lucio.giannotta@a8c.com>
2022-09-29 15:46:10 +07:00
Niels Lange 3d55668983 Create Cross-Sells product list (https://github.com/woocommerce/woocommerce-blocks/pull/6645)
* Create Cross-Sells product list

* Show “Read more” button for out-of-stock cross-sells products

* Update assets/js/blocks/cart/inner-blocks/cart-cross-sells-products/block.tsx

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

* Update assets/js/blocks/cart/cart-cross-sells-product-list/index.tsx

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

* Remove obsolete isLoading and placeholderRows

* Fix TS errors

* Rename crossSellsProduct to product

* Fix critical error

* Lock “Cart Cross-Sells products” inner block

* Update assets/js/blocks/cart/inner-blocks/cart-cross-sells-products/block.json

Co-authored-by: Saad Tarhi <saad.trh@gmail.com>

* Prevent moving of the Cross-Sells block

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-09-21 13:04:15 +07:00
Niels Lange 2f52565c75 Correct broken *.md links (https://github.com/woocommerce/woocommerce-blocks/pull/7108) 2022-09-12 11:29:24 +07:00
Tom Cafferkey a07cc3c978 Update Filter by Stock block (https://github.com/woocommerce/woocommerce-blocks/pull/6883)
* Update Filter by Stock controls and UI to include custom checkbox and settings.

* Include and style Filter by Stock reset button

* Make checkbox accessible via keyboard

* Update snapshot tests for Filter Products by Stock component

* Update E2E tests with new label value

* Update label test for Apply Filters in E2E tests

* Specify checkbox type so styles are not overridden in the editor

* Update E2E test label for filter button

* Update label selector to search for containing text rather than exact match

* Escape quotation marks for label query in E2E shopper tests for Filter by Stock

* Correct typo on Filter by Stock controls

* Replace custom checkbox with CheckboxControl component from the checkout package.

* Remove opacity on product count for checkbox label so its the same color as the label.

* Update snapshot tests with new component usage for filter by stock

* Update block title from Filter Products by Stock to Filter by Stock

* Update reset button behaviour to clear selections immediately regardless of whether the Apply Filters button is active or not.

* Pass option value as ID to satisfy E2E tests

* Update snapshot tests for stock filter

* Reset checked state on reset for when they have filters checked but not applied.
2022-08-19 09:04:04 +01:00
Thomas Roberts 0fc1ee46bd Ensure package names display correctly if only one item is in package (https://github.com/woocommerce/woocommerce-blocks/pull/6815)
* Check package length >= 1 to show package name

* Check shipping rates length in order shipping packages slot

* Fix TS error where boolean value could be undefined

* Show items if there is more than one shipping rate
2022-08-02 04:51:21 -07:00
Seghir Nadir 2ebb166b41 add new action for customer updates (https://github.com/woocommerce/woocommerce-blocks/pull/6792) 2022-08-01 09:56:28 +01:00
Michael P. Pfeiffer 521f93619b Upgrade wp-prettier to 2.6.2 and reformat the codebase (https://github.com/woocommerce/woocommerce-blocks/pull/6566)
* Remove mixed tabs and spaces in tsconfig.json

* Update formatting in json files

* Upgrade wp-prettier to 2.6.2
2022-06-15 11:56:52 +02:00
Tung Du 6531c4cb0b Fix: Convert Filter Products by Price Block to TypeScript (https://github.com/woocommerce/woocommerce-blocks/pull/6514) 2022-06-14 15:48:49 +07:00
Niels Lange 3208da551b Improve the structure of the WooCommerce Blocks Handbook (https://github.com/woocommerce/woocommerce-blocks/pull/6429)
* Improve the structure of the WooCommerce Blocks Handbook

Co-authored-by: Rania Lang <rania.langouretou@automattic.com>
2022-06-09 17:52:19 +02:00
Niels Lange a748f533a8 Format Markdown files using wp-scripts (https://github.com/woocommerce/woocommerce-blocks/pull/6462)
* Format Markdown files using Prettier

* Format Markdown files using wp-scripts

* Adjust MD linting
2022-06-09 14:43:17 +02:00
Raluca Stan d22ce7cd0b Fix/order summary sidebar css (https://github.com/woocommerce/woocommerce-blocks/pull/6231)
* Add box sizing to Totals item

* Add some unit tests for Order summary blocks

* Fix Proceed to checkout button size
2022-04-12 17:13:43 +02:00
Alex Florisca 0c7c2db6c0 Update @woocmmerce/eslint-plugin to 2.0.0 (https://github.com/woocommerce/woocommerce-blocks/pull/6203)
* Update @woocmmerce/eslint-plugin to 2.0.0

* Fixed some eslint errors

* Fix syntax errors

* Fix most linting errors

* Feedback changes

* Fix one more eslint issue
2022-04-08 14:47:19 +01:00
Alex Florisca e15d516163 Revert "Move cart and mini-cart blocks into their own folders (https://github.com/woocommerce/woocommerce-blocks/pull/6126)" (https://github.com/woocommerce/woocommerce-blocks/pull/6190)
This reverts commit d005dbd2cf.
2022-04-05 11:14:32 +01:00
Alex Florisca d005dbd2cf Move cart and mini-cart blocks into their own folders (https://github.com/woocommerce/woocommerce-blocks/pull/6126)
* Move cart and mini-cart into their own folders

* Update other references of cart-checkout
2022-04-04 12:34:29 +01:00
Mike Jolley eb196226d8 WIP: Add Inner blocks to order summary (https://github.com/woocommerce/woocommerce-blocks/pull/6065)
* Sub/Total/Fee inner blocks

* Row blocks within the inner block

* Update icons

* Resolve stying issues

* Remove old block

* Pin totals row

* Locking logic update

* Heading inner block

* Refactor where inner blocks are defined

* Add todos

* Todo for Consider deprecating OrderMetaSlotFill and DiscountSlotFill in favour of inner block areas.

* Improve frontend registration of components using new entrypoint

* Experiment- external block context

* Revert "Experiment- external block context"

This reverts commit 4b75668ec7eb62f065c6a488cd942a666e26204f.

* Duplicate inner blocks to avoid conflicts with context

* Remove todo

* Rename block dir

* Some test fixes

* Fix import

* fix import

* linting

* Remove unused attributes

* Optional classname

* fix coupons import

* fix shipping mocks

* Styling

* Fix selectors in e2e tests

* Add back the wc-block-components-totals-wrapper class that was used for each segment in the totals Order summary

Because, removing them was:
-  a breaking change for the old structure
- was making it harder to target the inner blocks. Before the class was used to target each segment
- it was making the wc-block-components-totals-item behave as a child or parent depending on the inner block, inconsitency

* Reuse the TotalsWrapper component for C& C blocks inner blocks

This component was removed in this PR, but  we wrap components in the Cart and Checkout sidebar in a TotalsWrapper. This will ensure consistent spacing and borders are applied to items in the sidebar.

Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
Co-authored-by: Raluca Stan <ralucastn@gmail.com>
2022-04-01 15:45:18 +02:00
Thomas Roberts 5cc165d7a8 Allow memoized filters to re-run if `defaultArg` changes (https://github.com/woocommerce/woocommerce-blocks/pull/6102)
* Check the last defaultArg to decide whether we re-run filters

* Fake commit to make CI run

* Revert change to .gitignore to make CI run
2022-03-28 12:10:36 +01:00
Thomas Roberts 719c7f7c23 [Experiment] Try to memoize/cache filter results so that we don't call third party filters too often (https://github.com/woocommerce/woocommerce-blocks/pull/5143)
* Add memoized/cached filter runs

* Add function to check equality of object's members

* Add function to check equality of arg and extensions vs prev values for a filter name

* Memoize/Cache values of previously run filters

* Add docs and null check to shallow equality check

* Update packages/checkout/filter-registry/index.ts

Co-authored-by: Raluca Stan <ralucastn@gmail.com>

Co-authored-by: Raluca Stan <ralucastn@gmail.com>
2022-03-04 14:42:38 +00:00
Daniel Dudzic 5a3c7be9a4 Revise Storybook entries for Checkout Blocks/totals components (https://github.com/woocommerce/woocommerce-blocks/pull/5853)
* Revise Storybook entries for Checkout Blocks/totals components

Revise Storybook entries for Checkout Blocks/totals components

Co-authored-by: Luigi Teschio <gigitux@gmail.com>

* Fix a typo in the Item label value

* set disable value for description and disable control for 'showRateAfterTaxName' prop

Co-authored-by: Luigi Teschio <gigitux@gmail.com>
2022-02-25 09:58:09 +01:00
Mike Jolley 0714fa41bd Customer Data Store and revised handling for Shipping As Billing (https://github.com/woocommerce/woocommerce-blocks/pull/5817)
* Add address-related items to wc/store/cart data store

* include shippingAsBilling in return value of useCustomerData

* Add useUpdateCustomerData hook

This allows us to have a single hook responsible for updating the customer information on the server.

* Add useUpdateCustomerData hook in Checkout block

* Remove the updating customer data work from the useCustomerData hook

* Remove shippingAsBilling from previousCustomerData ref type

* Add useShippingAsBillingCheckbox hook

* Control shippingAsBilling from single hook

* Remove checkbox handling from useCheckoutAddress

* Remove CustomerDataContext typedef

* Merge with woocommerce/woocommerce-blocks#5810 changes

* Move shipping as billing to checkout state context provider

* Unused import

* Subscribe to changes

* Only receiveCartContents when updating customer data via checkout

* Cache customerDataToUpdate

* rename debounced function

* Combine customerDataType and customerDataContextType

* Change case of CustomerDataType

* debouncedUpdateCustomerData typo

* Fix notice context

* Clean up inline docs for push changes

* Comment on dirty state

* Phone is always set

* shippingAddress is never undefined

* setBillingPhone

* receiveCartContents explanation

* Tweak customerData to avoid null

* useShippingAsBilling

Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2022-02-22 17:45:01 +00:00
Raluca Stan 858fffd697 Pass context information about parent block to the existing Slots (https://github.com/woocommerce/woocommerce-blocks/pull/5885)
* Pass context information about containing block to the existing Slots

* Fix images added to the Slots docs

* Use the parent's block name for the context prop passed to Slot fills
2022-02-22 10:33:52 +01:00
Albert Juhé Lluveras 0008e8b7f1 Update some Cart and Checkout extensibility docs to include the Mini Cart block (https://github.com/woocommerce/woocommerce-blocks/pull/5815)
* Update some Cart and Checkout extensibility docs to include the Mini Cart block

* Add Mini Cart to blocks-registry docs
2022-02-21 16:29:29 +01:00
Alex Florisca 9b3fdbb0b0 Ts blocks (https://github.com/woocommerce/woocommerce-blocks/pull/5668)
* filter-element-label -> ts

* filter-submit-button -> ts

* form -> ts

* load-more-button -> ts

* loading-mask -> ts

* pagination -> ts

* ProductList -> ts (in progress)

* ProductList -> ts continued

* ProductList -> ts - done + fix some ts errors

* ProductList -> ts continued

* ProductList -> ts

* Tidy up

* Extract type for RegisteredBlockComponent

* Feedback from Mike

* Fix unit tests
2022-02-07 09:34:30 +00:00
Mike Jolley 81bb982c5e Include issue submission link in the footer of all documention (.md files) (https://github.com/woocommerce/woocommerce-blocks/pull/5655)
* Add links to single routes in main index woocommerce/woocommerce-blocks#4473

* Footer

* Feedback template

* Remove footer from existing MD files

* Add doc footer script

* Apply script to all docs

* Fix examples
2022-02-02 14:27:46 +00:00
Mike Jolley 2b5f115d41 Remove custom `Icon` component in favour of `@wordpress/icons` where possible (https://github.com/woocommerce/woocommerce-blocks/pull/5599)
* Remove atom icon

* Swap icon usage to WordPress package

* remove unused icons from library

* Use @wordpress/primitives

* Product cats block to listView

* On-sale to use percent instead of tag icon

* add to cart button use button icon

* on sale products block icon

* Handpicked products use stack icon

* Products by stock box icon

* Make sparkles woo purple

* Fix icon name

* Correct more tag name

* fix path to icons

* Update snaps

* Update readme to explain updated usage

* Import SVG and path from primitives

* Missing isFeaturePluginBuild

* Update assets/js/icons/README.md

Co-authored-by: Raluca Stan <raluca.stan@automattic.com>

* Update assets/js/icons/README.md

Co-authored-by: Raluca Stan <raluca.stan@automattic.com>

* Update assets/js/icons/README.md

Co-authored-by: Raluca Stan <raluca.stan@automattic.com>

* update lock

Co-authored-by: Raluca Stan <raluca.stan@automattic.com>
2022-02-01 16:54:38 +00:00
Tung Du 4b159f0fcd Allow inserting blocks to filled mini cart (https://github.com/woocommerce/woocommerce-blocks/pull/5527) 2022-01-08 07:51:20 +07:00
Lucio Giannotta 35adae3fa4 Add Storybook documentation and remove deprecated knobs (https://github.com/woocommerce/woocommerce-blocks/pull/5407)
* Remove Storybook knobs

They are now fully replaced by controls

* Update Storybook to 6.4.9
* Add Storybook documentation and VSCode snippets
* Add VSCode snippets
* Convert stories from checkout packages and include them in Storybook
2021-12-21 18:08:57 +01:00
Tung Du 50066455c0 Fix: Mini Cart block: divide contents into three inner blocks (https://github.com/woocommerce/woocommerce-blocks/pull/5386)
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2021-12-20 14:57:55 +07:00
Luigi Teschio 13deb1b09e Mini Cart Block: render the empty state set on template parts (https://github.com/woocommerce/woocommerce-blocks/pull/5338)
* add view switcher for mini cart contents block

* editor view switcher

* update mini cart template file

* render the empty state template parts for the Mini Cart Block woocommerce/woocommerce-blocks#4674

render the empty state template parts for the Mini Cart Block woocommerce/woocommerce-blocks#4674

* update selector

* allow empty mini cart block to add all blocks

* fix tests; improve code style

* install @wordpress/block-editor package

* fix warning on frontend side

* block-editor package is not necessary

* merge attributes object

Co-authored-by: Tung Du <dinhtungdu@gmail.com>
2021-12-10 12:11:59 +01:00
Tung Du 90a54b6cf0 Mini Cart Contents block: implement view switcher in editor (https://github.com/woocommerce/woocommerce-blocks/pull/5304) 2021-12-07 21:07:53 +07:00
Luigi Teschio c2ebf26c1c Enable stylelint for the entire project woocommerce/woocommerce-blocks#5262 (https://github.com/woocommerce/woocommerce-blocks/pull/5298)
Enable stylelint for the entire project
2021-12-03 10:07:51 +01:00
Alex Florisca d9bf1ba94c Convert components to Typescript (https://github.com/woocommerce/woocommerce-blocks/pull/5241)
* Convert ReturnToCartButton component to TS

* Convert FormStep component to TS

* Remoe proptypes from FormStep and AddressFormn components

* Converted order-summary component to TS

* Convert product-price component to TS

* alias path to type-defs

* Fix errors

* Changes from Thomas feedback

* Change minPrice maxPrice logic to be more robust

* Changed types from inline to interface in ReturnToCartButton component

* Check for string type in order-summary-item

* add missing isString check
2021-11-26 17:03:12 +00:00
M. L. Giannotta 57fcb28720 Checkbox Control: Fix squished checkboxes when label text wraps (https://github.com/woocommerce/woocommerce-blocks/pull/5192) (https://github.com/woocommerce/woocommerce-blocks/pull/5206)
On the front-end, checkboxes with labels would look squished when the labels wrapped
on a second line. That was due to the flex container taking too much space for the label
as the checkbox minimum dimensions was set in `px` rather than `em`, making it work
differently depending on the relative font size.
2021-11-25 15:31:47 +01:00
Niels Lange 29d0cd0b64 Display decimals if intended by the merchant (https://github.com/woocommerce/woocommerce-blocks/pull/5219) 2021-11-24 20:21:40 +07:00
Mike Jolley 3b1bedd15f Checkbox Component Styling Fix (https://github.com/woocommerce/woocommerce-blocks/pull/5164)
* Wrap label in div to prevent clickable area growing too large

* Prevent pointer events on svg

* Double gap in editor
2021-11-22 09:52:43 +01:00
Darren Ethier 620cf8aebc In `@woocommerce/blocks-checkout` package documentation - reference WCDEWP instead of WPDEWP (https://github.com/woocommerce/woocommerce-blocks/pull/5154)
* Reference the WooCommerce DEWP instead of WPDEWP

* Apply suggestions from code review

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
2021-11-20 07:08:58 -05:00
Mike Jolley c2fb8751be Add support for decimal and thousand separators in the `formatPrice` function (https://github.com/woocommerce/woocommerce-blocks/pull/5188)
* Format with decimal and thousands, with tests

* Update packages/prices/utils/price.ts

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

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2021-11-19 12:32:37 +00:00
Thomas Roberts c35819272d Switch variables round in mustContain error (https://github.com/woocommerce/woocommerce-blocks/pull/5155)
This is because the error messaged printed to the user  was incorrect.
2021-11-19 12:31:16 +00:00
Mike Jolley a76e00bd83 Move checkbox control to checkout package (https://github.com/woocommerce/woocommerce-blocks/pull/5045)
* Move checkbox control to checkout package

* Revert import change in editor
2021-11-09 16:47:46 +00:00
Raluca Stan 43a235fb36 Update README.md 2021-10-29 15:12:11 +01:00
Seghir Nadir 2408e34faa Migrate Cart i1 to Cart i2 (https://github.com/woocommerce/woocommerce-blocks/pull/4973)
* move empty cart

* remove Cart and rename Cart i2 to Cart

* graduate blocks

* setup template migration from Cart i1 to Cart i2

* back to js so we have a good diff

* add migration

* fix bug in empty cart template

* add useForceLayout hook to edit

* migrate from old block to new block

* migrate styles

* respect align

* add tests

* Include latest cart line item improvements from cart-i1

* Missing changes from cart-i1

* Line items table should be disabled

* Fix e2e tests for cart i2

* update tests to adapt for inner blocks

* update select to resolveSelect to remove warning checker

* rename test/block to test/index

* move blocks to their own file

* undo rename to keep diff clean

* remove .tsx and update jest config

* Revert "update select to resolveSelect to remove warning checker"

This reverts commit 79d55de30edcfe36bbdfe7506df7a09460824f03.

* revert resolveControl

* Fix empty cart editor E2E test by scrolling to the view switch

* parse attributes for order summary block

* migrate attributes when resaving

* Update documentation

Automatic update after running npm run build:docs

* add align options to filled cart and empty cart

* append instead of replcae

* import style.scss in frontend

Co-authored-by: Mike Jolley <mike.jolley@me.com>
Co-authored-by: Raluca Stan <ralucastn@gmail.com>
2021-10-25 15:46:34 +01:00
Mike Jolley c4be7ca307 Styling (margin and padding) tweaks (https://github.com/woocommerce/woocommerce-blocks/pull/4974) 2021-10-20 17:02:05 +01:00
Seghir Nadir 91296b09cc Update blocks-registry docs (https://github.com/woocommerce/woocommerce-blocks/pull/4946)
* add handleMap

* remove useValidation from cart blocks

* add namespace options to docs

* Update packages/checkout/blocks-registry/README.md

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

* expand on the docblock

* Update packages/checkout/blocks-registry/README.md

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

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Mike Jolley <mike.jolley@me.com>
2021-10-19 14:05:26 +01:00
Mike Jolley 61e5a4c55e Add Checkout Package and Checkout i2 Documentation (https://github.com/woocommerce/woocommerce-blocks/pull/4892)
* Move components

* Main index for docs

* Block registry documentation

* filter registry docs

* Utility docs

* Doc for components

* Link to package docs

* fix import
2021-10-12 15:23:52 +01:00
Ovidiu Liuta ae603f3e82 WordPress Coding Standards fix for .scss files (https://github.com/woocommerce/woocommerce-blocks/pull/4918)
* adding timerange limit

* woocommerce/woocommerce-blocks#3739 fixing scss coding standard and removing spaces from parantheses values

* removing unrelated changes

* fixing further instances for parantheses
2021-10-11 14:18:32 +01:00
Tung Du edce72e2fb Mini Cart block: improve button accessibility (https://github.com/woocommerce/woocommerce-blocks/pull/4852) 2021-10-04 10:54:28 +07:00
Seghir Nadir b6167bc179 Cart i2: Render filled and empty Carts on frontend (https://github.com/woocommerce/woocommerce-blocks/pull/4802)
* WIP getting to work on frontend

* restore frontend.tsx

* fix layout

* remove unit tests living where they shouldn't be living

* remove skeleton

* support emtpy cart in frontend

* remove extra todo

* use fragment instead of div

* Add empty cart event

* Remove extra fragment
2021-09-23 16:38:30 +01:00
Mike Jolley 2af90f301c Add/empty and fillted cart wrapper (https://github.com/woocommerce/woocommerce-blocks/pull/4803)
* Update area/types

* Add empty and filled block wrappers

* Add missing useBlockProps

* Add templates and inner block structure
2021-09-21 16:41:09 +01:00