woocommerce/plugins/woocommerce-blocks/assets/js/blocks
Niels Lange 21e30a2956 Convert product-elements/image to TypeScript (https://github.com/woocommerce/woocommerce-blocks/pull/7572)
* Updated package-lock.json

* fixed method sig

* PHP versions matrix

* removed extra space

* renamed step

* Update E2E and coding standards to use PHP 8.0

* Un-linted unit-tests.yml. Github flows use 4 spaces indent, while our .editorconfig file enforces 2 spaces.

* Refactor unit-tests.yml

* Linted unit-tests.yml to proper 2 space indents

* Removed composer caching

* Test without hacky permissions step

* Concurrency disable.
Jobs renaming.

* Add step to install wp-env for PHP unit tests.

* Another try at fixing perms for wp-env

* Another try at fixing perms for wp-env

* Restore missing steps

* Convert product-elements/image to TypeScript

* bot: update checkstyle.xml

* Refactor edit.tsx

* bot: update checkstyle.xml

* Add interface to attributes.ts

* Convert product-elements/image to TypeScript

* bot: update checkstyle.xml

* bot: update checkstyle.xml

* Refactor edit.tsx

* Add interface to attributes.ts

* bot: update checkstyle.xml

* bot: update checkstyle.xml

* Solve TS error

* Solve TS error

* bot: update checkstyle.xml

* Solve TS errors

* bot: update checkstyle.xml

* Solve TS errors

* bot: update checkstyle.xml

* Document types

* Adjust TS interface

* Correct merge mistakes

* bot: update checkstyle.xml

* Solve TS errors

* bot: update checkstyle.xml

* Fix broken JS unit test

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-11-18 13:52:37 +07:00
..
active-filters Active Filters: Fix active filter grouping for Ratings and Stock Status (https://github.com/woocommerce/woocommerce-blocks/pull/7577) 2022-11-04 13:30:33 +01:00
attribute-filter Prevent padding from placeholder instructions to be overriden (https://github.com/woocommerce/woocommerce-blocks/pull/7552) 2022-11-04 15:22:40 -03:00
cart Convert product-elements/image to TypeScript (https://github.com/woocommerce/woocommerce-blocks/pull/7572) 2022-11-18 13:52:37 +07:00
cart-checkout-shared Move `StoreNoticesContainer` to `@woocommerce/blocks-checkout` package and add tests (https://github.com/woocommerce/woocommerce-blocks/pull/7558) 2022-11-17 05:33:58 -08:00
checkout Move `StoreNoticesContainer` to `@woocommerce/blocks-checkout` package and add tests (https://github.com/woocommerce/woocommerce-blocks/pull/7558) 2022-11-17 05:33:58 -08:00
classic-template Create the `Products by Attribute` template (https://github.com/woocommerce/woocommerce-blocks/pull/7660) 2022-11-16 14:37:41 +01:00
featured-items Improve public-facing texts and labels (https://github.com/woocommerce/woocommerce-blocks/pull/7045) 2022-09-12 10:39:26 +02:00
filter-wrapper Filter by Rating: Remove the Feature Plugin flag (https://github.com/woocommerce/woocommerce-blocks/pull/7580) 2022-11-04 15:53:16 +01:00
handpicked-products Fix ESLint errors (https://github.com/woocommerce/woocommerce-blocks/pull/7556) 2022-11-02 17:46:14 +01:00
mini-cart Fix Mini Cart Block global styles woocommerce/woocommerce-blocks#7379 (https://github.com/woocommerce/woocommerce-blocks/pull/7515) 2022-10-31 11:47:01 +01:00
price-filter [Product Query] Fix filter block data counter (https://github.com/woocommerce/woocommerce-blocks/pull/7257) 2022-11-02 10:03:23 +01: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 Improve public-facing texts and labels (https://github.com/woocommerce/woocommerce-blocks/pull/7045) 2022-09-12 10:39:26 +02:00
product-category Improve public-facing texts and labels (https://github.com/woocommerce/woocommerce-blocks/pull/7045) 2022-09-12 10:39:26 +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 Fix ESLint errors (https://github.com/woocommerce/woocommerce-blocks/pull/7556) 2022-11-02 17:46:14 +01:00
product-search Improve public-facing texts and labels (https://github.com/woocommerce/woocommerce-blocks/pull/7045) 2022-09-12 10:39:26 +02:00
product-tag Improve public-facing texts and labels (https://github.com/woocommerce/woocommerce-blocks/pull/7045) 2022-09-12 10:39:26 +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 Move `StoreNoticesContainer` to `@woocommerce/blocks-checkout` package and add tests (https://github.com/woocommerce/woocommerce-blocks/pull/7558) 2022-11-17 05:33:58 -08:00
products-by-attribute Fix ESLint errors (https://github.com/woocommerce/woocommerce-blocks/pull/7556) 2022-11-02 17:46:14 +01:00
rating-filter Filter by Rating: Remove the Feature Plugin flag (https://github.com/woocommerce/woocommerce-blocks/pull/7580) 2022-11-04 15:53:16 +01:00
reviews Improve public-facing texts and labels (https://github.com/woocommerce/woocommerce-blocks/pull/7045) 2022-09-12 10:39:26 +02:00
single-product Move `StoreNoticesContainer` to `@woocommerce/blocks-checkout` package and add tests (https://github.com/woocommerce/woocommerce-blocks/pull/7558) 2022-11-17 05:33:58 -08:00
stock-filter Fix ESLint errors (https://github.com/woocommerce/woocommerce-blocks/pull/7556) 2022-11-02 17:46:14 +01: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.