woocommerce/plugins/woocommerce-blocks/assets/js/blocks
Alexandre Lara 6459504f6f
Product Filters > Clear button: Refactor the Product Filters to use a function instead of the hook (#52678)
* refactor: move util functions to their own files

* refactor: replace hook with function

* Add changefile(s) from automation for the following project(s): woocommerce-blocks

* chore: remove unnecessary prop

* fix: default clear button attribute not being respected

* refactor: make the blocks respect the default clearButton attribute

* refactor: remove code duplication

* Rename getCSSVar util function

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-11-14 14:25:15 -03:00
..
active-filters Fix typo in useSetWraperVisibility function name (#52115) 2024-11-04 19:21:34 +00:00
attribute-filter Add flag to enable WC Blocks rendering with React 18 (#52473) 2024-11-11 10:17:06 +00:00
breadcrumbs Update all blocks to V3 (#48720) 2024-08-20 10:14:11 +00:00
cart [dev] Monorepo: validate blocks manifests as a build step. (#52767) 2024-11-14 14:30:04 +01:00
cart-checkout-shared Consistent payment and shipping options empty states (#52192) 2024-11-06 12:50:50 +00:00
cart-link Add/cart link in checkout header 44837 (#51948) 2024-10-17 16:50:12 +01:00
catalog-sorting Update all blocks to V3 (#48720) 2024-08-20 10:14:11 +00:00
checkout Checkout: Adjust paddings to align top of page order summary on mobile (#52604) 2024-11-12 23:39:04 +13:00
classic-shortcode Update all blocks to V3 (#48720) 2024-08-20 10:14:11 +00:00
classic-template Hide AbstractProductGrid blocks from inserter (soft-deprecation) (#52209) 2024-11-04 18:57:51 +01:00
coming-soon Fix coming soon template layout issue with tall images and header spacing (#52726) 2024-11-13 12:14:51 +08:00
customer-account Update all blocks to V3 (#48720) 2024-08-20 10:14:11 +00:00
featured-items Update all blocks to V3 (#48720) 2024-08-20 10:14:11 +00:00
filter-wrapper Fix typo in useSetWraperVisibility function name (#52115) 2024-11-04 19:21:34 +00:00
handpicked-products Hide AbstractProductGrid blocks from inserter (soft-deprecation) (#52209) 2024-11-04 18:57:51 +01:00
migration-products-to-product-collection Product Collection: Remove automatic migration code (#50440) 2024-08-13 11:29:07 +02:00
mini-cart Add flag to enable WC Blocks rendering with React 18 (#52473) 2024-11-11 10:17:06 +00:00
order-confirmation Delayed Account Creation: Remove experimental flag to enable feature (#52554) 2024-11-08 13:44:01 +00:00
page-content-wrapper Update all blocks to V3 (#48720) 2024-08-20 10:14:11 +00:00
price-filter Fix typo in useSetWraperVisibility function name (#52115) 2024-11-04 19:21:34 +00:00
product-best-sellers Hide AbstractProductGrid blocks from inserter (soft-deprecation) (#52209) 2024-11-04 18:57:51 +01:00
product-categories Fix visual issue in the Display Style of the Product Categories List block (#52609) 2024-11-06 09:25:30 +00:00
product-category Hide AbstractProductGrid blocks from inserter (soft-deprecation) (#52209) 2024-11-04 18:57:51 +01:00
product-collection Product Collection: Add "Related by" setting to Related Products collection (#52580) 2024-11-11 15:12:17 -03:00
product-elements/add-to-cart-form Tweak "Add to Cart" layout also for Variant products (#52702) 2024-11-11 12:57:19 +00:00
product-filters Product Filters > Clear button: Refactor the Product Filters to use a function instead of the hook (#52678) 2024-11-14 14:25:15 -03:00
product-gallery Fix fatal when adding the Product Gallery (Beta) block into a pattern (#51189) 2024-09-17 09:49:53 +02:00
product-new Hide AbstractProductGrid blocks from inserter (soft-deprecation) (#52209) 2024-11-04 18:57:51 +01:00
product-on-sale Hide AbstractProductGrid blocks from inserter (soft-deprecation) (#52209) 2024-11-04 18:57:51 +01:00
product-query Product Collection Telemetry: Convert Product to Product Collection and revert to Products (#52651) 2024-11-08 13:54:32 -03:00
product-results-count Update all blocks to V3 (#48720) 2024-08-20 10:14:11 +00:00
product-search Add inspector controls to Product Search block (#51247) 2024-09-13 18:52:12 -03:00
product-tag Hide AbstractProductGrid blocks from inserter (soft-deprecation) (#52209) 2024-11-04 18:57:51 +01:00
product-template Product Collection: Implement the Hand-Picked collection (#51141) 2024-09-21 20:10:10 +05:30
product-top-rated Hide AbstractProductGrid blocks from inserter (soft-deprecation) (#52209) 2024-11-04 18:57:51 +01:00
products Hide All Products from inserter (soft-deprecation) (#52207) 2024-10-23 09:32:42 +02:00
products-by-attribute Hide AbstractProductGrid blocks from inserter (soft-deprecation) (#52209) 2024-11-04 18:57:51 +01:00
rating-filter [dev] Monorepo: validate blocks manifests as a build step. (#52767) 2024-11-14 14:30:04 +01:00
reviews Update all blocks to V3 (#48720) 2024-08-20 10:14:11 +00:00
shared/styles Add logic of Upgrade Notice after upgrading Products to Product Collection (https://github.com/woocommerce/woocommerce-blocks/pull/10267) 2023-08-18 08:25:15 +02:00
single-product Deprecate single product block save (#51153) 2024-09-11 09:54:43 -03:00
stock-filter [dev] Monorepo: validate blocks manifests as a build step. (#52767) 2024-11-14 14:30:04 +01:00
store-notices Update all blocks to V3 (#48720) 2024-08-20 10:14:11 +00:00
README.md Remove propTypes definitions from Newest Products block (https://github.com/woocommerce/woocommerce-blocks/pull/9613) 2023-05-29 13:12:36 +07:00

README.md

Blocks

Our blocks are generally made up of up to 4 files:

|- block.js
|- editor.scss
|- index.js
|- style.scss

The only required file is index.js, this sets up the block using registerBlockType. Each block has edit and save functions.

The scss files are split so that things in style are added to the editor and frontend, while styles in editor are only added to the editor. Most of our blocks should use core components that won't need CSS though.

Editing

A simple edit function can live in index.js, but most blocks are a little more complicated, so the edit function instead returns a Block component, which lives in block.js. By using a component, we can use React lifecycle methods to fetch data or save state.

The Newest Products block is a good example to read over, this is a simple block that fetches the products and renders them using the ProductPreview component.

We include settings in the sidebar, called the Inspector in gutenberg. See an example of this.

Other blocks have the concept of an "edit state", like when you need to pick a product in the Featured Product block, or pick a category in the Products by Category block.