woocommerce/plugins/woocommerce-blocks/assets/js/blocks
Alex Florisca a8d979c47b Default all product images to "cropped" and actual image width (https://github.com/woocommerce/woocommerce-blocks/pull/5551)
* Default imageSizing for the all products block to 'cropped'

* set max-width:100%, width: auto on product grid images
2022-01-12 17:50:48 +00: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 Mini Cart block: re-enable background support woocommerce/woocommerce-blocks#4965 (https://github.com/woocommerce/woocommerce-blocks/pull/5539) 2022-01-11 15:08:16 +01: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 wide and full alignment support for legacy template block (https://github.com/woocommerce/woocommerce-blocks/pull/5433) 2022-01-07 10:47:48 +01:00
price-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
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 All Products Block Tests due to incorrect Stock Filter addition (https://github.com/woocommerce/woocommerce-blocks/pull/5541) 2022-01-11 11:25:05 +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 Add stock level filter to product blocks (https://github.com/woocommerce/woocommerce-blocks/pull/4943) 2022-01-10 13:39:24 +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 Add stock level filter to product blocks (https://github.com/woocommerce/woocommerce-blocks/pull/4943) 2022-01-10 13:39:24 +00:00
product-top-rated Add stock level filter to product blocks (https://github.com/woocommerce/woocommerce-blocks/pull/4943) 2022-01-10 13:39:24 +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 Add stock level filter to product blocks (https://github.com/woocommerce/woocommerce-blocks/pull/4943) 2022-01-10 13:39:24 +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.