woocommerce-blocks icon indicating copy to clipboard operation
woocommerce-blocks copied to clipboard

Add Style Attributes Hooks to blocks/hooks Directory.

Open danielwrobert opened this issue 2 years ago â€ĸ 2 comments

By adding the hooks in assets/js/blocks/hooks to assets/js/base/hooks where the other hooks live, we can utilize the @woocommerce/base-hooks alias and avoid using relative paths for importing and using these hooks.

Note: Apologies for all of the changed files in this PR but they are all directly related to the refactor.

Sub Tasks:

  • [x] Make a copy of the style-attributes file in the desired directory.
  • [x] Adjust the imports in the style-attributes file to utilize existing aliases.
  • [x] Adjust imports that pull in the style attributes hooks to use the @woocommerce/base-hooks alias and confirm no unintended side-effects.
  • [x] Remove the hooks dir in assets/js/blocks/hooks and confirm no unintended side-effects.
  • [x] Split out the style attributes hooks into separate files for consistency with the rest of the custom hooks in our project.

Fixes #6866.

Testing

  1. Test all of the Product Elements blocks and confirm they work as expected (note that there is an existing bug that is unrelated to this change).
  2. Test the Attribute Filter block and confirm it works as expected.
  3. Test the Mini Cart block and confirm it works as expected.
  4. Confirm no JS or PHP errors on any of the above blocks.
  5. Run unit tests (npm run test) and confirm they all pass.
  • [x] Do not include in the Testing Notes

WooCommerce Visibility

  • [ ] WooCommerce Core
  • [ ] Feature plugin
  • [x] Experimental

Changelog

Refactor style-attributes hooks to add as global custom imports and remove relative import paths.

danielwrobert avatar Aug 08 '22 20:08 danielwrobert

The release ZIP for this PR is accessible via:

https://wcblocks.wpcomstaging.com/wp-content/uploads/woocommerce-gutenberg-products-block-6870.zip

github-actions[bot] avatar Aug 08 '22 20:08 github-actions[bot]

Size Change: +360 B (0%)

Total Size: 872 kB

Filename Size Change
build/active-filters-frontend.js 7.32 kB -9 B (0%)
build/active-filters.js 7.99 kB -24 B (0%)
build/all-products-frontend.js 18.1 kB +4 B (0%)
build/all-products.js 33.8 kB +57 B (0%)
build/all-reviews.js 7.79 kB -9 B (0%)
build/attribute-filter-frontend.js 21.9 kB -136 B (-1%)
build/attribute-filter.js 12.9 kB -214 B (-2%)
build/cart-blocks/cart-accepted-payment-methods-frontend.js 1.16 kB -2 B (0%)
build/cart-blocks/cart-express-payment-frontend.js 5.09 kB +1 B (0%)
build/cart-blocks/cart-line-items--mini-cart-contents-block/products-table-frontend.js 5.27 kB +2 B (0%)
build/cart-blocks/cart-line-items-frontend.js 430 B +1 B (0%)
build/cart-blocks/cart-order-summary-frontend.js 1.1 kB -1 B (0%)
build/cart-blocks/cart-totals-frontend.js 321 B -2 B (-1%)
build/cart-blocks/empty-cart-frontend.js 347 B +1 B (0%)
build/cart-blocks/filled-cart-frontend.js 782 B +1 B (0%)
build/cart-blocks/order-summary-coupon-form-frontend.js 2.65 kB -2 B (0%)
build/cart-blocks/order-summary-discount-frontend.js 2.14 kB +2 B (0%)
build/cart-blocks/order-summary-heading-frontend.js 456 B +2 B (0%)
build/cart-blocks/order-summary-shipping--checkout-blocks/order-summary-shipping-frontend.js 6.38 kB -2 B (0%)
build/cart-blocks/order-summary-taxes-frontend.js 433 B +1 B (0%)
build/cart-frontend.js 47 kB +11 B (0%)
build/cart.js 43.2 kB +8 B (0%)
build/checkout-blocks/actions-frontend.js 1.41 kB -5 B (0%)
build/checkout-blocks/billing-address--checkout-blocks/shipping-address-frontend.js 4.12 kB +4 B (0%)
build/checkout-blocks/billing-address-frontend.js 892 B -1 B (0%)
build/checkout-blocks/contact-information-frontend.js 2.84 kB +3 B (0%)
build/checkout-blocks/express-payment-frontend.js 5.39 kB +3 B (0%)
build/checkout-blocks/fields-frontend.js 345 B +1 B (0%)
build/checkout-blocks/order-note-frontend.js 1.08 kB -2 B (0%)
build/checkout-blocks/order-summary-cart-items-frontend.js 3.66 kB +2 B (0%)
build/checkout-blocks/order-summary-coupon-form-frontend.js 2.8 kB -1 B (0%)
build/checkout-blocks/order-summary-frontend.js 1.1 kB -1 B (0%)
build/checkout-blocks/order-summary-shipping-frontend.js 602 B -1 B (0%)
build/checkout-blocks/order-summary-taxes-frontend.js 432 B +1 B (0%)
build/checkout-blocks/payment-frontend.js 7.7 kB +3 B (0%)
build/checkout-blocks/shipping-address-frontend.js 1.03 kB +1 B (0%)
build/checkout-blocks/shipping-methods-frontend.js 4.78 kB -1 B (0%)
build/checkout-blocks/totals-frontend.js 325 B +1 B (0%)
build/checkout-frontend.js 49.2 kB +12 B (0%)
build/checkout.js 44.6 kB +16 B (0%)
build/featured-category.js 13.2 kB +1 B (0%)
build/featured-product.js 13.5 kB +2 B (0%)
build/handpicked-products.js 7.37 kB -11 B (0%)
build/legacy-template.js 2.8 kB +3 B (0%)
build/mini-cart-component-frontend.js 16.8 kB -132 B (-1%)
build/mini-cart-contents-block/empty-cart-frontend.js 365 B -1 B (0%)
build/mini-cart-contents-block/filled-cart-frontend.js 229 B -1 B (0%)
build/mini-cart-contents-block/footer--mini-cart-contents-block/products-table-frontend.js 4.69 kB +2 B (0%)
build/mini-cart-contents-block/footer-frontend.js 6.98 kB -5 B (0%)
build/mini-cart-frontend.js 1.72 kB +2 B (0%)
build/mini-cart.js 4.59 kB -121 B (-3%)
build/price-filter-frontend.js 13.1 kB -12 B (0%)
build/price-filter.js 9.02 kB -14 B (0%)
build/product-add-to-cart--product-button--product-category-list--product-image--product-price--product-r--a0326d00.js 223 B +1 B (0%)
build/product-add-to-cart--product-button--product-image--product-title.js 2.66 kB -1 B (0%)
build/product-add-to-cart--product-button.js 0 B -564 B (removed) 🏆
build/product-add-to-cart-frontend.js 6.95 kB +5 B (0%)
build/product-add-to-cart.js 6.88 kB +250 B (+4%)
build/product-button--product-category-list--product-image--product-price--product-rating--product-sale-b--e17c7c01.js 437 B -63 B (-13%) 👏
build/product-button-frontend.js 1.87 kB +31 B (+2%)
build/product-button.js 1.57 kB +485 B (+45%) 🚨
build/product-categories.js 2.78 kB -2 B (0%)
build/product-category-list-frontend.js 879 B -45 B (-5%) ✅
build/product-category-list.js 503 B +3 B (+1%)
build/product-category.js 8.68 kB -4 B (0%)
build/product-image-frontend.js 1.88 kB +42 B (+2%)
build/product-image.js 1.59 kB +520 B (+48%) 🚨
build/product-new.js 7.71 kB -7 B (0%)
build/product-on-sale.js 8.02 kB -9 B (0%)
build/product-price-frontend.js 1.9 kB -31 B (-2%)
build/product-price.js 1.51 kB +4 B (0%)
build/product-rating-frontend.js 1.16 kB +15 B (+1%)
build/product-rating.js 741 B +7 B (+1%)
build/product-sale-badge-frontend.js 1.13 kB +36 B (+3%)
build/product-sale-badge.js 801 B +121 B (+18%) ⚠ī¸
build/product-search.js 2.18 kB -2 B (0%)
build/product-sku.js 380 B -1 B (0%)
build/product-stock-indicator-frontend.js 993 B -39 B (-4%)
build/product-stock-indicator.js 624 B +5 B (+1%)
build/product-summary-frontend.js 1.29 kB -44 B (-3%)
build/product-summary.js 921 B +4 B (0%)
build/product-tag-list-frontend.js 873 B -46 B (-5%) ✅
build/product-tag-list.js 499 B +4 B (+1%)
build/product-tag.js 8.08 kB -9 B (0%)
build/product-title-frontend.js 1.31 kB +15 B (+1%)
build/product-title.js 918 B +8 B (+1%)
build/product-top-rated.js 7.95 kB -2 B (0%)
build/products-by-attribute.js 8.63 kB -10 B (0%)
build/reviews-by-category.js 11.2 kB -12 B (0%)
build/reviews-by-product.js 12.3 kB -5 B (0%)
build/reviews-frontend.js 7.02 kB -1 B (0%)
build/single-product-frontend.js 21.4 kB -2 B (0%)
build/single-product.js 10.1 kB -2 B (0%)
build/stock-filter-frontend.js 7.38 kB -11 B (0%)
build/stock-filter.js 7.29 kB -14 B (0%)
build/vendors--cart-blocks/cart-line-items--checkout-blocks/order-summary-cart-items--mini-cart-contents---233ab542-frontend.js 3.14 kB -1 B (0%)
build/vendors--cart-blocks/order-summary-shipping--checkout-blocks/billing-address--checkout-blocks/order--5b8feb0b-frontend.js 4.85 kB -1 B (0%)
build/vendors--cart-blocks/order-summary-shipping--checkout-blocks/billing-address--checkout-blocks/order--decc3dc6-frontend.js 19.1 kB +2 B (0%)
build/vendors--mini-cart-contents-block/footer-frontend.js 6.86 kB +2 B (0%)
build/vendors--product-add-to-cart-frontend.js 7.53 kB -3 B (0%)
build/wc-blocks-vendors.js 54.5 kB -9 B (0%)
build/product-button--product-image--product-rating--product-sale-badge--product-title.js 302 B +302 B (new file) 🆕
ℹī¸ View Unchanged
Filename Size
build/blocks-checkout.js 17.4 kB
build/cart-blocks/cart-items-frontend.js 299 B
build/cart-blocks/order-summary-fee-frontend.js 273 B
build/cart-blocks/order-summary-shipping-frontend.js 426 B
build/cart-blocks/order-summary-subtotal-frontend.js 274 B
build/cart-blocks/proceed-to-checkout-frontend.js 1.15 kB
build/checkout-blocks/order-summary-discount-frontend.js 2.27 kB
build/checkout-blocks/order-summary-fee-frontend.js 276 B
build/checkout-blocks/order-summary-subtotal-frontend.js 274 B
build/checkout-blocks/terms-frontend.js 1.22 kB
build/general-style-rtl.css 1.29 kB
build/general-style.css 1.29 kB
build/mini-cart-contents-block/items-frontend.js 237 B
build/mini-cart-contents-block/products-table-frontend.js 289 B
build/mini-cart-contents-block/shopping-button-frontend.js 288 B
build/mini-cart-contents-block/title-frontend.js 367 B
build/mini-cart-contents.js 22.9 kB
build/price-format.js 1.19 kB
build/product-best-sellers.js 7.71 kB
build/product-sku-frontend.js 380 B
build/vendors--cart-blocks/cart-line-items--cart-blocks/cart-order-summary--cart-blocks/order-summary-shi--c02aad66-frontend.js 5.26 kB
build/wc-blocks-data.js 9.87 kB
build/wc-blocks-editor-style-rtl.css 5.04 kB
build/wc-blocks-editor-style.css 5.04 kB
build/wc-blocks-google-analytics.js 1.56 kB
build/wc-blocks-middleware.js 930 B
build/wc-blocks-registry.js 2.7 kB
build/wc-blocks-shared-context.js 1.52 kB
build/wc-blocks-shared-hocs.js 1.14 kB
build/wc-blocks-style-rtl.css 22.8 kB
build/wc-blocks-style.css 22.7 kB
build/wc-blocks-vendors-style-rtl.css 1.95 kB
build/wc-blocks-vendors-style.css 1.95 kB
build/wc-blocks.js 2.62 kB
build/wc-payment-method-bacs.js 816 B
build/wc-payment-method-cheque.js 811 B
build/wc-payment-method-cod.js 909 B
build/wc-payment-method-paypal.js 837 B
build/wc-settings.js 2.6 kB

compressed-size-action

github-actions[bot] avatar Aug 08 '22 21:08 github-actions[bot]