woocommerce/plugins/woocommerce-blocks/assets/js/blocks
Albert Juhé Lluveras 4b6a5bf997 Fix remove button alignment in Filter by Attribute block (https://github.com/woocommerce/woocommerce-blocks/pull/7088) 2022-09-08 15:38:20 +02:00
..
active-filters Layout Updates to Active Filters Block (https://github.com/woocommerce/woocommerce-blocks/pull/6905) 2022-08-26 09:11:23 -04:00
attribute-filter Fix remove button alignment in Filter by Attribute block (https://github.com/woocommerce/woocommerce-blocks/pull/7088) 2022-09-08 15:38:20 +02:00
cart add side effect to package (https://github.com/woocommerce/woocommerce-blocks/pull/6904) 2022-08-16 16:21:26 +05:30
cart-checkout-shared Turn current page into the default Cart/Checkout page (https://github.com/woocommerce/woocommerce-blocks/pull/6867) 2022-08-29 09:35:05 +01:00
checkout Add _blank to terms link (https://github.com/woocommerce/woocommerce-blocks/pull/6908) 2022-08-16 15:59:21 +01:00
classic-template Fix corrupt Classic Template placeholders for specific products. (https://github.com/woocommerce/woocommerce-blocks/pull/7033) 2022-09-06 10:52:33 +01:00
featured-items Remove __experimentalDuotone from block.json. (https://github.com/woocommerce/woocommerce-blocks/pull/7000) 2022-08-31 13:03:21 -04:00
handpicked-products Upgrade wp-prettier to 2.6.2 and reformat the codebase (https://github.com/woocommerce/woocommerce-blocks/pull/6566) 2022-06-15 11:56:52 +02:00
mini-cart Add Style Attributes Hooks to blocks/hooks Directory. (https://github.com/woocommerce/woocommerce-blocks/pull/6870) 2022-08-10 20:04:12 -04:00
price-filter Update `filter by attribute` skeleton design (https://github.com/woocommerce/woocommerce-blocks/pull/6990) 2022-09-06 15:17:11 +02:00
product-best-sellers Set default orderby to popularity (https://github.com/woocommerce/woocommerce-blocks/pull/7025) 2022-08-31 12:38:48 +01:00
product-categories Add global styles to Product Categories List block in WC core (https://github.com/woocommerce/woocommerce-blocks/pull/6906) 2022-08-16 09:42:38 +02:00
product-category Start using `block.json` and convert to TS the `Product by Category` block (https://github.com/woocommerce/woocommerce-blocks/pull/6680) 2022-07-19 15:09:46 +02:00
product-new Remove custom `Icon` component in favour of `@wordpress/icons` where possible (https://github.com/woocommerce/woocommerce-blocks/pull/5599) 2022-02-01 16:54:38 +00:00
product-on-sale Remove custom `Icon` component in favour of `@wordpress/icons` where possible (https://github.com/woocommerce/woocommerce-blocks/pull/5599) 2022-02-01 16:54:38 +00:00
product-query Add to the Product Image block the support for the Product Query block (https://github.com/woocommerce/woocommerce-blocks/pull/6911) 2022-09-01 15:13:19 +02:00
product-search Product search block as core/search variation (https://github.com/woocommerce/woocommerce-blocks/pull/6191) 2022-08-23 23:06:17 +07:00
product-tag Upgrade wp-prettier to 2.6.2 and reformat the codebase (https://github.com/woocommerce/woocommerce-blocks/pull/6566) 2022-06-15 11:56:52 +02:00
product-top-rated Remove custom `Icon` component in favour of `@wordpress/icons` where possible (https://github.com/woocommerce/woocommerce-blocks/pull/5599) 2022-02-01 16:54:38 +00:00
products All Products block: Migrate to block.json (https://github.com/woocommerce/woocommerce-blocks/pull/6754) 2022-07-28 12:26:36 +02:00
products-by-attribute Upgrade wp-prettier to 2.6.2 and reformat the codebase (https://github.com/woocommerce/woocommerce-blocks/pull/6566) 2022-06-15 11:56:52 +02:00
reviews Remove the ToggleButtonControl in favor of ToggleGroupControl (https://github.com/woocommerce/woocommerce-blocks/pull/5967) 2022-04-11 13:33:46 +02:00
single-product Update @woocmmerce/eslint-plugin to 2.0.0 (https://github.com/woocommerce/woocommerce-blocks/pull/6203) 2022-04-08 14:47:19 +01:00
stock-filter Update `filter by attribute` skeleton design (https://github.com/woocommerce/woocommerce-blocks/pull/6990) 2022-09-06 15:17:11 +02:00
README.md Format Markdown files using wp-scripts (https://github.com/woocommerce/woocommerce-blocks/pull/6462) 2022-06-09 14:43:17 +02: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.