635524b481
* Replace Products (Beta) with Product Collection block in blockified template * Add necessary attributes that influences the look of blocks * Replace Products (Beta) with Product Collection block in product search results * Replace Products (Beta) with Product Collection block in products by attribute * Replace Products (Beta) with Product Collection block in products by category * Replace Products (Beta) with Product Collection block in products by tag * Replace Products (Beta) with Product Collection when transforming from classic product archive * Change the no results content in blockified search results template * Replace Products (Beta) with Product Collection block in product search results * Add product search in no results content of blockified product search result * Add ts-ignore before createBlocksFromInnerBlocksTemplate imports * Add changelog * Remove step of replacing Products (Beta) with Product Collection in compatibility layer tests * Remove step of replacing Products (Beta) with Product Collection in Product Collection tests * Fix lint * Update E2E tests of Product Collection * Adjust Products (Beta) E2E tests * Add Product Collection focus step in E2E tests * Improve the way PC block is focused * Further tests adjustments and new tests comparing classic template with Product Collection * Bring back the click on body * Include tips from reviewer * Enter edit mode, step that I accidentally removde * Bring the E2E test flow with updating product catalog * Change the way of removing focus from PC block in tests * Fix lint * Improve the layout of search in No Results * Use previous patterns in Product Search No Results to preserve translations * Add Search button label in product search form pattern * Fix lint * Improve comment explanation * Extract No Results content to separate pattern in order to make the content translatable * Lint fix * Add missing footer to the blockified Products by Tag template * Exclude woocommerce/patterns from phpcs rules that dont apply there * Make PC block responsive by default in product archive templates * Fix typo * Fix typo --------- Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com> |
||
---|---|---|
.. | ||
active-filters | ||
attribute-filter | ||
breadcrumbs | ||
cart | ||
cart-checkout-shared | ||
catalog-sorting | ||
checkout | ||
classic-shortcode | ||
classic-template | ||
coming-soon | ||
customer-account | ||
featured-items | ||
filter-wrapper | ||
handpicked-products | ||
migration-products-to-product-collection | ||
mini-cart | ||
order-confirmation | ||
page-content-wrapper | ||
price-filter | ||
product-best-sellers | ||
product-categories | ||
product-category | ||
product-collection | ||
product-elements/add-to-cart-form | ||
product-filter | ||
product-filters | ||
product-gallery | ||
product-new | ||
product-on-sale | ||
product-query | ||
product-results-count | ||
product-search | ||
product-tag | ||
product-template | ||
product-top-rated | ||
products | ||
products-by-attribute | ||
rating-filter | ||
reviews | ||
shared/styles | ||
single-product | ||
stock-filter | ||
store-notices | ||
README.md |
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.