woocommerce/plugins/woocommerce-blocks/assets/js/blocks
Niels Lange 59c8ddc531 Show single express payment button in full width (https://github.com/woocommerce/woocommerce-blocks/pull/5601)
* Show single express payment button in full width

* Change :first-child:nth-last-child(1) to :only-child
2022-01-24 10:22:02 +07:00
..
active-filters Add global style for Active Filters block (https://github.com/woocommerce/woocommerce-blocks/pull/5465) 2022-01-03 10:41:19 +01:00
attribute-filter Add E2E tests for Filter blocks (Price, Attribute, and Active Filters) (https://github.com/woocommerce/woocommerce-blocks/pull/4562) 2021-12-23 17:26:10 +01:00
cart-checkout Show single express payment button in full width (https://github.com/woocommerce/woocommerce-blocks/pull/5601) 2022-01-24 10:22:02 +07: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 Allow LegacyTemplate block to be reinserted, only on WooCommerce block templates. (https://github.com/woocommerce/woocommerce-blocks/pull/5545) 2022-01-17 10:50:57 +00:00
price-filter Price Filter block: enable global style woocommerce/woocommerce-blocks#4965 (https://github.com/woocommerce/woocommerce-blocks/pull/5559) 2022-01-17 10:10:26 +01: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 Fix default `stockStatusOptions` in tag and attribute blocks (https://github.com/woocommerce/woocommerce-blocks/pull/5590) 2022-01-19 11:42:21 +00:00
product-new Add stock level filter to product blocks (https://github.com/woocommerce/woocommerce-blocks/pull/4943) 2022-01-10 13:39:24 +00:00
product-on-sale Fix default `stockStatusOptions` in tag and attribute blocks (https://github.com/woocommerce/woocommerce-blocks/pull/5590) 2022-01-19 11:42:21 +00: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 Fix default `stockStatusOptions` in tag and attribute blocks (https://github.com/woocommerce/woocommerce-blocks/pull/5590) 2022-01-19 11:42:21 +00:00
product-top-rated Fix default `stockStatusOptions` in tag and attribute blocks (https://github.com/woocommerce/woocommerce-blocks/pull/5590) 2022-01-19 11:42:21 +00:00
products Default all product images to "cropped" and actual image width (https://github.com/woocommerce/woocommerce-blocks/pull/5551) 2022-01-12 17:50:48 +00:00
products-by-attribute Fix default `stockStatusOptions` in tag and attribute blocks (https://github.com/woocommerce/woocommerce-blocks/pull/5590) 2022-01-19 11:42:21 +00: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.