woocommerce/plugins/woocommerce-blocks/assets/js/blocks
Manish Menaria 53944beeb3 [Product Collection] Fix: HTML entity decoding for product names in Hand-Picked Products (https://github.com/woocommerce/woocommerce-blocks/pull/11927)
* Add HTML entity decoding for product names in Hand-Picked Products control

In the Hand-Picked Products control within the product-collection inspector controls, a function for decoding HTML entities in product names has been added.

- A new utility function `decodeHTMLEntities` has been implemented. This function decodes HTML entities in a string, ensuring that special characters are correctly displayed in their human-readable form.
- The `transformTokenIntoProductName` function has been updated to utilize `decodeHTMLEntities`. Now, when a product name is fetched (either directly as a token or via a product ID), the HTML entities within the name are decoded.
- This enhancement ensures that product names containing characters like ampersands or other HTML entities are accurately displayed in the UI.

This change improves the readability and accuracy of product names within the Hand-Picked Products control, enhancing the user experience for store managers using WooCommerce Blocks.

* Update label and hide description

This commit updates the `HandPickedProductsControl` component. Specifically, the user-facing label for product selection has been changed from 'Pick some products' to 'Hand-picked Products'. Additionally, the `__experimentalShowHowTo` property has been added with a `false` value, to hide description. Corresponding changes have been made in the E2E test file `product-collection.block_theme.spec.ts`, where the filter name is updated to match the new label.

* Refactor: Replace custom HTML entity decoder with `@wordpress/html-entities`

Rationale:
- The shift to `@wordpress/html-entities` aligns with standard WordPress practices, ensuring consistency across the platform.
- Enhances maintainability by relying on a well-supported library rather than custom code.
- Simplifies the codebase by removing a redundant utility function.

This change enhances the robustness of our code and aligns with best practices in WordPress development.
2023-11-27 12:27:04 +05:30
..
active-filters Move `Label` component to components package (https://github.com/woocommerce/woocommerce-blocks/pull/11275) 2023-10-20 07:03:00 -07:00
attribute-filter Move `CheckboxList` and create new `blocksComponents` package (https://github.com/woocommerce/woocommerce-blocks/pull/11214) 2023-10-17 02:47:34 -07:00
breadcrumbs Fix icon color when block is selected in List View (https://github.com/woocommerce/woocommerce-blocks/pull/10652) 2023-08-18 18:03:53 +00:00
cart Move all totals components into components package (https://github.com/woocommerce/woocommerce-blocks/pull/11773) 2023-11-20 12:53:41 +00:00
cart-checkout-shared Move `CheckboxControl` to components package and leave alias in checkout package (https://github.com/woocommerce/woocommerce-blocks/pull/11662) 2023-11-21 10:55:42 +00:00
catalog-sorting Per block stylesheets (https://github.com/woocommerce/woocommerce-blocks/pull/9831) 2023-07-04 13:06:48 +02:00
checkout Move `CheckboxControl` to components package and leave alias in checkout package (https://github.com/woocommerce/woocommerce-blocks/pull/11662) 2023-11-21 10:55:42 +00:00
classic-shortcode Cart and Checkout block transforms for classic shortcodes (https://github.com/woocommerce/woocommerce-blocks/pull/11228) 2023-10-19 16:43:43 +01:00
classic-template Cart and Checkout block transforms for classic shortcodes (https://github.com/woocommerce/woocommerce-blocks/pull/11228) 2023-10-19 16:43:43 +01:00
collection-filters Migrate interactivity stock filter to new store API, add improvements and bugfixes (https://github.com/woocommerce/woocommerce-blocks/pull/11827) 2023-11-27 17:26:01 +13:00
customer-account Fix customer account icon not scaling in certain environments (https://github.com/woocommerce/woocommerce-blocks/pull/10533) 2023-09-02 16:07:01 +02:00
featured-items Fix wcSettings inconsistent property naming style (https://github.com/woocommerce/woocommerce-blocks/pull/10439) 2023-08-07 11:30:53 +01:00
filter-wrapper Refactor Filter Wrapper to remove usage of useInnerBlocksProps (https://github.com/woocommerce/woocommerce-blocks/pull/8095) 2023-01-04 17:31:17 +07:00
handpicked-products Fix wcSettings inconsistent property naming style (https://github.com/woocommerce/woocommerce-blocks/pull/10439) 2023-08-07 11:30:53 +01:00
migration-products-to-product-collection Simplify Product Collection query attributes by removing attributes which are never used (https://github.com/woocommerce/woocommerce-blocks/pull/11259) 2023-10-18 12:47:55 +02:00
mini-cart Move all totals components into components package (https://github.com/woocommerce/woocommerce-blocks/pull/11773) 2023-11-20 12:53:41 +00:00
order-confirmation Add universal border radius for form elements and components (https://github.com/woocommerce/woocommerce-blocks/pull/11193) 2023-10-11 17:04:45 +01:00
page-content-wrapper Feature Branch: Blockified Order Confirmation (https://github.com/woocommerce/woocommerce-blocks/pull/10056) 2023-09-20 13:56:00 +01:00
price-filter Add universal border radius for form elements and components (https://github.com/woocommerce/woocommerce-blocks/pull/11193) 2023-10-11 17:04:45 +01:00
product-best-sellers Fix wcSettings inconsistent property naming style (https://github.com/woocommerce/woocommerce-blocks/pull/10439) 2023-08-07 11:30:53 +01:00
product-categories Enable declaration-block-no-duplicate-properties stylelint rule (https://github.com/woocommerce/woocommerce-blocks/pull/10163) 2023-07-11 13:03:05 +00:00
product-category Fix wcSettings inconsistent property naming style (https://github.com/woocommerce/woocommerce-blocks/pull/10439) 2023-08-07 11:30:53 +01:00
product-collection [Product Collection] Fix: HTML entity decoding for product names in Hand-Picked Products (https://github.com/woocommerce/woocommerce-blocks/pull/11927) 2023-11-27 12:27:04 +05:30
product-gallery Product Gallery Thumbnails: Add support for cropping (https://github.com/woocommerce/woocommerce-blocks/pull/11718) 2023-11-24 23:49:44 +01:00
product-new Bump @wordpress/icons from 6.1.1 to 9.36.0 (https://github.com/woocommerce/woocommerce-blocks/pull/11611) 2023-11-16 17:40:53 +00:00
product-on-sale Fix wcSettings inconsistent property naming style (https://github.com/woocommerce/woocommerce-blocks/pull/10439) 2023-08-07 11:30:53 +01:00
product-query Translate Related Products heading in Single Product template (https://github.com/woocommerce/woocommerce-blocks/pull/11693) 2023-11-09 09:00:23 +01:00
product-results-count Per block stylesheets (https://github.com/woocommerce/woocommerce-blocks/pull/9831) 2023-07-04 13:06:48 +02:00
product-search Remove `propTypes` definitions from Product Search block (https://github.com/woocommerce/woocommerce-blocks/pull/9565) 2023-05-24 19:24:08 +07:00
product-tag Convert product tag control to functional component (https://github.com/woocommerce/woocommerce-blocks/pull/10529) 2023-08-15 17:40:05 +01:00
product-template Remove authors filter from Product Collection block (https://github.com/woocommerce/woocommerce-blocks/pull/11427) 2023-10-25 19:11:56 +02:00
product-top-rated Fix wcSettings inconsistent property naming style (https://github.com/woocommerce/woocommerce-blocks/pull/10439) 2023-08-07 11:30:53 +01:00
products Move Button, StoreNotice and StoreNoticesContainer components into the components package (https://github.com/woocommerce/woocommerce-blocks/pull/11766) 2023-11-14 16:32:53 +00:00
products-by-attribute Fix wcSettings inconsistent property naming style (https://github.com/woocommerce/woocommerce-blocks/pull/10439) 2023-08-07 11:30:53 +01:00
rating-filter Filter By Rating: fix overlapping stars (https://github.com/woocommerce/woocommerce-blocks/pull/11644) 2023-11-07 10:59:36 +00:00
reviews Fix an issue that caused the Order by select in Reviews blocks to always be disabled (https://github.com/woocommerce/woocommerce-blocks/pull/11918) 2023-11-23 12:59:14 +01:00
shared/styles Add logic of Upgrade Notice after upgrading Products to Product Collection (https://github.com/woocommerce/woocommerce-blocks/pull/10267) 2023-08-18 08:25:15 +02:00
single-product Pattern: fetch product id on the JS side (https://github.com/woocommerce/woocommerce-blocks/pull/11138) 2023-10-05 07:30:50 +00:00
stock-filter Move `CheckboxList` and create new `blocksComponents` package (https://github.com/woocommerce/woocommerce-blocks/pull/11214) 2023-10-17 02:47:34 -07:00
store-notices Refactor Cart and Checkout Page Templates (https://github.com/woocommerce/woocommerce-blocks/pull/10773) 2023-09-19 10:58:18 +01:00
README.md Remove propTypes definitions from Newest Products block (https://github.com/woocommerce/woocommerce-blocks/pull/9613) 2023-05-29 13:12:36 +07: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.