woocommerce/plugins/woocommerce-blocks/assets/js/blocks
Christopher Allford 1d056b3b37 Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
..
active-filters Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
attribute-filter Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
breadcrumbs Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
cart Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
cart-checkout-shared Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
catalog-sorting Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
checkout Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
classic-shortcode Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
classic-template replace old props with variant prop (https://github.com/woocommerce/woocommerce-blocks/pull/11933) 2023-12-09 00:30:33 +01:00
collection-filters Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
customer-account Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
featured-items Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
filter-wrapper Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
handpicked-products Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
migration-products-to-product-collection Simplify Product Collection query attributes by removing attributes which are never used (https://github.com/woocommerce/woocommerce-blocks/pull/11259) 2023-10-18 12:47:55 +02:00
mini-cart Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
order-confirmation Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
page-content-wrapper Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
price-filter Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
product-best-sellers Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
product-categories Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
product-category Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
product-collection Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
product-gallery Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
product-new Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
product-on-sale Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
product-query Translate Related Products heading in Single Product template (https://github.com/woocommerce/woocommerce-blocks/pull/11693) 2023-11-09 09:00:23 +01:00
product-results-count Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
product-search Remove `propTypes` definitions from Product Search block (https://github.com/woocommerce/woocommerce-blocks/pull/9565) 2023-05-24 19:24:08 +07:00
product-tag Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
product-template Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
product-top-rated Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
products Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
products-by-attribute Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
rating-filter Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
reviews Update Blocks Text Domain 2023-12-09 05:44:54 -08: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 Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
stock-filter Update Blocks Text Domain 2023-12-09 05:44:54 -08:00
store-notices Update Blocks Text Domain 2023-12-09 05:44:54 -08: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.