woocommerce/plugins/woocommerce-blocks/assets/js/blocks
Tom Cafferkey c967f72507 Products by Category: Move renderEmptyResponsePlaceholder to separate method (https://github.com/woocommerce/woocommerce-blocks/pull/4751)
* Move renderEmptyResponsePlaceholder to separate method

* Move EmptyResponsePlaceholder to its own separate component
2021-09-16 12:13:37 +01:00
..
active-filters Twenty Twenty: Adjust font styles for filter and product grid blocks (https://github.com/woocommerce/woocommerce-blocks/pull/4749) 2021-09-15 13:35:06 +02:00
attribute-filter Twenty Twenty: Adjust font styles for filter and product grid blocks (https://github.com/woocommerce/woocommerce-blocks/pull/4749) 2021-09-15 13:35:06 +02:00
cart-checkout Add Typescript to /blocks-registry/payment-methods (https://github.com/woocommerce/woocommerce-blocks/pull/4702) 2021-09-15 18:36:02 +02:00
featured-category Replace deprecated divisions with math.div($size, $base) (https://github.com/woocommerce/woocommerce-blocks/pull/4550) 2021-08-24 13:37:43 +02:00
featured-product Replace deprecated divisions with math.div($size, $base) (https://github.com/woocommerce/woocommerce-blocks/pull/4550) 2021-08-24 13:37:43 +02:00
handpicked-products Update @woocommerce/components (https://github.com/woocommerce/woocommerce-blocks/pull/4100) 2021-05-20 10:58:59 +02:00
price-filter Twenty Twenty: Adjust font styles for filter and product grid blocks (https://github.com/woocommerce/woocommerce-blocks/pull/4749) 2021-09-15 13:35:06 +02:00
product-best-sellers Move Block Type Settings into Block Type Classes (https://github.com/woocommerce/woocommerce-blocks/pull/4059) 2021-04-22 12:37:27 +01:00
product-categories Make Product Categories List links unclickable in the editor (https://github.com/woocommerce/woocommerce-blocks/pull/4339) 2021-06-15 07:33:16 +02:00
product-category Products by Category: Move renderEmptyResponsePlaceholder to separate method (https://github.com/woocommerce/woocommerce-blocks/pull/4751) 2021-09-16 12:13:37 +01:00
product-new Move Block Type Settings into Block Type Classes (https://github.com/woocommerce/woocommerce-blocks/pull/4059) 2021-04-22 12:37:27 +01:00
product-on-sale Move Block Type Settings into Block Type Classes (https://github.com/woocommerce/woocommerce-blocks/pull/4059) 2021-04-22 12:37:27 +01:00
product-search Fix unfiltered html usage of blocks (https://github.com/woocommerce/woocommerce-blocks/pull/4551) 2021-08-12 17:39:38 +01:00
product-tag Update @woocommerce/components (https://github.com/woocommerce/woocommerce-blocks/pull/4100) 2021-05-20 10:58:59 +02:00
product-top-rated Move Block Type Settings into Block Type Classes (https://github.com/woocommerce/woocommerce-blocks/pull/4059) 2021-04-22 12:37:27 +01:00
products Add "Filter Products by Stock" block (https://github.com/woocommerce/woocommerce-blocks/pull/4145) 2021-08-20 16:56:14 +01:00
products-by-attribute Add camelcase rule to eslint config (https://github.com/woocommerce/woocommerce-blocks/pull/4382) 2021-07-09 17:53:45 +01:00
reviews Update Reviews blocks so they use block styles (https://github.com/woocommerce/woocommerce-blocks/pull/4323) 2021-09-16 11:32:48 +02:00
single-product Refactor Render Parent Block (https://github.com/woocommerce/woocommerce-blocks/pull/4325) 2021-06-11 09:54:18 +01:00
stock-filter Twenty Twenty: Adjust font styles for filter and product grid blocks (https://github.com/woocommerce/woocommerce-blocks/pull/4749) 2021-09-15 13:35:06 +02:00
README.md Remove deprecated shortcode save handling from SSR Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/4010) 2021-04-08 13:42:03 +01: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.