woocommerce/plugins/woocommerce-blocks/assets/js/blocks
Alex Florisca 006fbc6714
Add new buttonAttributes API to style express checkout buttons coherently (#47899)
* Expose buttonAttributes to the express payment methods

* Add size and label attributes to the express checkout area

* Remove defaultHeight

* default button Label

* Remove the button label attribute

* Remove px from height

* Change large button height to 55px

* Load express checkout block with attributes

* Add toggle and borderRadius controls and remove getting border radius from the theme

* Remove extra border radius text

* Only pass buttonAttributes if toggled on

* Move express payment block attribute logic into a Provider

* Tidy up editor grid and parse attributes into context on frontend

* Add px to border-radius input

* Express payment methods not selectable

* Add a test

* lint fixes

* default button height is 48 not 4

* Add changefile(s) from automation for the following project(s): woocommerce-blocks

* Update docs

* Add tests for express payment methods

* Center images within the express payment area in the editor

* Apply the buttonAttributes to the li container in the editor regardless of showButtonStyles

* Fix style issue

* fix linting

* fix lint again

* Update manifest

* Update docs manifest

* Resize images in editor

* lint fix

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-08-14 11:02:58 +01:00
..
active-filters [Performance]: Replace `classnames` usage with `clsx` (#47760) 2024-05-31 05:49:36 +02:00
attribute-filter [React 18] Use `createRoot().render()` instead of `render()` (#48843) 2024-07-26 09:18:48 +02:00
breadcrumbs Remove isFeaturePlugin and flag code from FeatureGating class (#47866) 2024-05-30 02:50:09 +12:00
cart Add new buttonAttributes API to style express checkout buttons coherently (#47899) 2024-08-14 11:02:58 +01:00
cart-checkout-shared Add new buttonAttributes API to style express checkout buttons coherently (#47899) 2024-08-14 11:02:58 +01:00
catalog-sorting Fixed Blocks Linting Errors (#42727) 2023-12-12 15:05:20 -08:00
checkout Add new buttonAttributes API to style express checkout buttons coherently (#47899) 2024-08-14 11:02:58 +01:00
classic-shortcode Update docs links blocks documentation (#50239) 2024-08-09 16:27:04 +01:00
classic-template Fix Classic Template block registration on WP 6.6 (#48730) 2024-06-26 12:20:22 +02:00
coming-soon Deprecate and create new coming soon block version (#49786) 2024-07-24 15:12:38 +08:00
customer-account Customer Account - Maintain the size of the icon in smaller screens (#50410) 2024-08-07 17:45:16 +02:00
featured-items [Performance]: Replace `classnames` usage with `clsx` (#47760) 2024-05-31 05:49:36 +02:00
filter-wrapper [Experimental] Filter block: replace custom upgrade panel by Transforms API (#44024) 2024-01-25 15:28:09 +07:00
handpicked-products Fixed Blocks Linting Errors (#42727) 2023-12-12 15:05:20 -08:00
migration-products-to-product-collection Product Collection: Remove automatic migration code (#50440) 2024-08-13 11:29:07 +02:00
mini-cart [Accessibility] Remove opacity from the hover style of the mini cart button (#50240) 2024-08-05 15:58:48 +02:00
order-confirmation [Performance]: Replace `classnames` usage with `clsx` (#47760) 2024-05-31 05:49:36 +02:00
page-content-wrapper update text domain in plugins/woocommerce-blocks (#42717) 2023-12-12 14:12:36 -08:00
price-filter [Performance]: Replace `classnames` usage with `clsx` (#47760) 2024-05-31 05:49:36 +02:00
product-best-sellers Fixed Blocks Linting Errors (#42727) 2023-12-12 15:05:20 -08:00
product-categories Fixed Blocks Linting Errors (#42727) 2023-12-12 15:05:20 -08:00
product-category Fixed Blocks Linting Errors (#42727) 2023-12-12 15:05:20 -08:00
product-collection Product Collection: Trigger `wc-blocks_product_list_rendered` JS event (#50166) 2024-08-13 12:29:04 +02:00
product-filter [Experimental]Attribute Filter: Dynamic title and description. (#50234) 2024-08-09 19:57:40 +07:00
product-filters [Experimental] Attribute Filter: Update Inspector Control Settings (#49751) 2024-07-25 09:13:56 +07:00
product-filters-overlay [Experimental] Product Filters Overlay Navigation block (#48677) 2024-06-28 08:16:21 +00:00
product-filters-overlay-navigation [Experimental]: Update: new title and icon for the Overlay Navigation block (#50011) 2024-07-31 12:56:53 +07:00
product-gallery [Performance]: Replace `classnames` usage with `clsx` (#47760) 2024-05-31 05:49:36 +02:00
product-new Fixed Blocks Linting Errors (#42727) 2023-12-12 15:05:20 -08:00
product-on-sale Fixed Blocks Linting Errors (#42727) 2023-12-12 15:05:20 -08:00
product-query Hide Products (Beta) from inserter (#48204) 2024-06-12 15:45:27 +02:00
product-results-count Added Result Count Client Navigation (#45556) 2024-03-14 09:48:02 -07:00
product-search [Performance]: Replace `classnames` usage with `clsx` (#47760) 2024-05-31 05:49:36 +02:00
product-tag Fixed Blocks Linting Errors (#42727) 2023-12-12 15:05:20 -08:00
product-template Product Collection: sync with current query doesnt display the correct products in the specific category templates (#49889) 2024-07-29 14:21:44 +02:00
product-top-rated Fixed Blocks Linting Errors (#42727) 2023-12-12 15:05:20 -08:00
products Refactor: migrate the All Products block to functional component (#50203) 2024-08-09 14:42:45 +07:00
products-by-attribute Fix sidebar attribute control in Products by Attribute block (#49351) 2024-07-11 15:52:57 +02:00
rating-filter CheckboxList and CheckboxControl: Label htmlFor and Input id should be unique (#50566) 2024-08-12 12:33:17 -04:00
reviews [Performance]: Replace `classnames` usage with `clsx` (#47760) 2024-05-31 05:49:36 +02: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 Fix `Single product` translations on edit mode (#50599) 2024-08-14 10:43:15 +02:00
stock-filter CheckboxList and CheckboxControl: Label htmlFor and Input id should be unique (#50566) 2024-08-12 12:33:17 -04:00
store-notices update text domain in plugins/woocommerce-blocks (#42717) 2023-12-12 14:12:36 -08: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.