woocommerce/plugins/woocommerce-blocks/assets/js/blocks
Niels Lange 9a1cd85779 Remove text decorations from product filter (https://github.com/woocommerce/woocommerce-blocks/pull/5384) 2021-12-22 15:33:37 +07:00
..
active-filters Limit CSS styles to WooCommerce Block icons only (https://github.com/woocommerce/woocommerce-blocks/pull/5363) 2021-12-10 21:32:44 +07:00
attribute-filter Remove text decorations from product filter (https://github.com/woocommerce/woocommerce-blocks/pull/5384) 2021-12-22 15:33:37 +07:00
cart-checkout Remove extra padding for cart sidebar (https://github.com/woocommerce/woocommerce-blocks/pull/5247) 2021-12-21 13:46:49 +00:00
featured-category Limit CSS styles to WooCommerce Block icons only (https://github.com/woocommerce/woocommerce-blocks/pull/5363) 2021-12-10 21:32:44 +07:00
featured-product Limit CSS styles to WooCommerce Block icons only (https://github.com/woocommerce/woocommerce-blocks/pull/5363) 2021-12-10 21:32:44 +07:00
handpicked-products Limit CSS styles to WooCommerce Block icons only (https://github.com/woocommerce/woocommerce-blocks/pull/5363) 2021-12-10 21:32:44 +07:00
legacy-template Add correct class to Legacy Template block icon (https://github.com/woocommerce/woocommerce-blocks/pull/5400) 2021-12-16 13:29:55 +01:00
price-filter Limit CSS styles to WooCommerce Block icons only (https://github.com/woocommerce/woocommerce-blocks/pull/5363) 2021-12-10 21:32:44 +07:00
product-best-sellers Limit CSS styles to WooCommerce Block icons only (https://github.com/woocommerce/woocommerce-blocks/pull/5363) 2021-12-10 21:32:44 +07:00
product-categories Limit CSS styles to WooCommerce Block icons only (https://github.com/woocommerce/woocommerce-blocks/pull/5363) 2021-12-10 21:32:44 +07:00
product-category Limit CSS styles to WooCommerce Block icons only (https://github.com/woocommerce/woocommerce-blocks/pull/5363) 2021-12-10 21:32:44 +07:00
product-new Limit CSS styles to WooCommerce Block icons only (https://github.com/woocommerce/woocommerce-blocks/pull/5363) 2021-12-10 21:32:44 +07:00
product-on-sale Limit CSS styles to WooCommerce Block icons only (https://github.com/woocommerce/woocommerce-blocks/pull/5363) 2021-12-10 21:32:44 +07:00
product-search Limit CSS styles to WooCommerce Block icons only (https://github.com/woocommerce/woocommerce-blocks/pull/5363) 2021-12-10 21:32:44 +07:00
product-tag Limit CSS styles to WooCommerce Block icons only (https://github.com/woocommerce/woocommerce-blocks/pull/5363) 2021-12-10 21:32:44 +07:00
product-top-rated Limit CSS styles to WooCommerce Block icons only (https://github.com/woocommerce/woocommerce-blocks/pull/5363) 2021-12-10 21:32:44 +07:00
products Limit CSS styles to WooCommerce Block icons only (https://github.com/woocommerce/woocommerce-blocks/pull/5363) 2021-12-10 21:32:44 +07:00
products-by-attribute Limit CSS styles to WooCommerce Block icons only (https://github.com/woocommerce/woocommerce-blocks/pull/5363) 2021-12-10 21:32:44 +07:00
reviews Limit CSS styles to WooCommerce Block icons only (https://github.com/woocommerce/woocommerce-blocks/pull/5363) 2021-12-10 21:32:44 +07:00
single-product Limit CSS styles to WooCommerce Block icons only (https://github.com/woocommerce/woocommerce-blocks/pull/5363) 2021-12-10 21:32:44 +07:00
stock-filter Remove text decorations from product filter (https://github.com/woocommerce/woocommerce-blocks/pull/5384) 2021-12-22 15:33:37 +07: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.