Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Add style to the Mini Cart buttons #8776

Merged
merged 24 commits into from
Mar 23, 2023
Merged

Conversation

albarin
Copy link
Contributor

@albarin albarin commented Mar 17, 2023

This PR converts the View my cart and Go to checkout buttons to inner blocks and adds the ability to style them.

Fixes #8736

Testing

Automated Tests

User Facing Testing

  1. Add the Mini cart block to the header template of your site.
  2. Go to the Site Editor and edit the Mini cart template part.
  3. Open the List view and select the Filled Mini Cart view.
  4. Click on the View my cart button and check that you can change the background and text colors of the button.
  5. Click on the Go to checkout button and check that you can change the background and text colors of the button.
  6. Save, go to the frontend, and check the buttons have the colors you just picked on the editor.

WooCommerce Visibility

  • WooCommerce Core
  • Feature plugin
  • Experimental

Changelog

Add styles to the Mini Cart buttons

@albarin albarin added type: enhancement The issue is a request for an enhancement. focus: global styles Issues that involve styles/css/layout structure. block: mini-cart Issues related to the Mini-Cart block. labels Mar 17, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Mar 17, 2023

The release ZIP for this PR is accessible via:

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

Script Dependencies Report

There is no changed script dependency between this branch and trunk.

This comment was automatically generated by the ./github/compare-assets action.

TypeScript Errors Report

  • Files with errors: 479
  • Total errors: 2300

⚠️ ⚠️ This PR introduces new TS errors on 2 files:

assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-footer-block/block.tsx

assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-footer-block/edit.tsx

comments-aggregator

@github-actions
Copy link
Contributor

github-actions bot commented Mar 17, 2023

Size Change: -59.4 kB (-5%) ✅

Total Size: 1.06 MB

Filename Size Change
build/active-filters-frontend.js 7.98 kB +11 B (0%)
build/active-filters-wrapper-frontend.js 5.97 kB -18 B (0%)
build/active-filters.js 7.49 kB +21 B (0%)
build/all-products-frontend.js 11.8 kB +66 B (+1%)
build/all-products.js 36.7 kB -996 B (-3%)
build/all-reviews.js 7.65 kB -4 B (0%)
build/attribute-filter-frontend.js 22.4 kB -39 B (0%)
build/attribute-filter-wrapper--stock-filter-wrapper-frontend.js 0 B -3.35 kB (removed) 🏆
build/attribute-filter-wrapper-frontend.js 7.1 kB +2.61 kB (+58%) 🆘
build/attribute-filter.js 13.2 kB +18 B (0%)
build/blocks-checkout.js 44 kB +32 B (0%)
build/breadcrumbs.js 2.04 kB -1 B (0%)
build/cart-blocks/cart-accepted-payment-methods-frontend.js 1.38 kB -1 B (0%)
build/cart-blocks/cart-cross-sells-products-frontend.js 9.72 kB -33 B (0%)
build/cart-blocks/cart-express-payment--checkout-blocks/express-payment-frontend.js 5.2 kB +2 B (0%)
build/cart-blocks/cart-express-payment-frontend.js 717 B -3 B (0%)
build/cart-blocks/cart-line-items--mini-cart-contents-block/products-table-frontend.js 5.36 kB -4 B (0%)
build/cart-blocks/cart-line-items-frontend.js 1.07 kB -2 B (0%)
build/cart-blocks/cart-order-summary-frontend.js 1.24 kB -2 B (0%)
build/cart-blocks/empty-cart-frontend.js 345 B -1 B (0%)
build/cart-blocks/filled-cart-frontend.js 653 B -1 B (0%)
build/cart-blocks/order-summary-discount-frontend.js 2.12 kB +1 B (0%)
build/cart-blocks/order-summary-fee-frontend.js 272 B -2 B (-1%)
build/cart-blocks/order-summary-shipping-frontend.js 10.7 kB -478 B (-4%)
build/cart-blocks/order-summary-subtotal-frontend.js 273 B -2 B (-1%)
build/cart-blocks/order-summary-taxes-frontend.js 433 B -1 B (0%)
build/cart-blocks/proceed-to-checkout-frontend.js 1.33 kB -3 B (0%)
build/cart-frontend.js 29.3 kB +368 B (+1%)
build/cart.js 48.1 kB +157 B (0%)
build/catalog-sorting.js 1.7 kB -2 B (0%)
build/checkout-blocks/actions-frontend.js 1.85 kB +3 B (0%)
build/checkout-blocks/billing-address-frontend.js 4.18 kB -5 B (0%)
build/checkout-blocks/contact-information-frontend.js 2.05 kB -2 B (0%)
build/checkout-blocks/express-payment-frontend.js 1.14 kB +1 B (0%)
build/checkout-blocks/fields-frontend.js 331 B +1 B (0%)
build/checkout-blocks/order-note-frontend.js 1.14 kB -2 B (0%)
build/checkout-blocks/order-summary-cart-items-frontend.js 3.68 kB -4 B (0%)
build/checkout-blocks/order-summary-coupon-form-frontend.js 1.79 kB -1 B (0%)
build/checkout-blocks/order-summary-fee-frontend.js 275 B -2 B (-1%)
build/checkout-blocks/order-summary-shipping-frontend.js 10.8 kB -467 B (-4%)
build/checkout-blocks/order-summary-subtotal-frontend.js 273 B -2 B (-1%)
build/checkout-blocks/order-summary-taxes-frontend.js 433 B -2 B (0%)
build/checkout-blocks/payment-frontend.js 8.39 kB -33 B (0%)
build/checkout-blocks/pickup-options-frontend.js 4.04 kB +2 B (0%)
build/checkout-blocks/shipping-method-frontend.js 2.61 kB +133 B (+5%) 🔍
build/checkout-blocks/shipping-methods-frontend.js 4.82 kB -439 B (-8%)
build/checkout-frontend.js 30.9 kB +370 B (+1%)
build/checkout.js 45.7 kB +170 B (0%)
build/customer-account.js 3.16 kB -1 B (0%)
build/featured-category.js 14 kB +80 B (+1%)
build/featured-product.js 14.4 kB +160 B (+1%)
build/filter-wrapper-frontend.js 14 kB -50 B (0%)
build/filter-wrapper.js 2.39 kB -1 B (0%)
build/handpicked-products.js 7.92 kB +16 B (0%)
build/legacy-template.js 5.32 kB +1 B (0%)
build/mini-cart-component-frontend.js 28.2 kB +146 B (+1%)
build/mini-cart-contents-block/footer-frontend.js 3.11 kB +251 B (+9%) 🔍
build/mini-cart-contents-block/shopping-button-frontend.js 573 B +1 B (0%)
build/mini-cart-contents-block/title-frontend.js 368 B +1 B (0%)
build/mini-cart-contents.js 17.1 kB +267 B (+2%)
build/mini-cart-frontend.js 2.02 kB -5 B (0%)
build/mini-cart.js 4.49 kB -3 B (0%)
build/price-filter-frontend.js 13.9 kB +12 B (0%)
build/price-filter-wrapper-frontend.js 6.96 kB -32 B (0%)
build/price-filter.js 8.4 kB +20 B (0%)
build/product-add-to-cart--product-button--product-category-list--product-image--product-price--product-r--a0326d00.js 0 B -253 B (removed) 🏆
build/product-add-to-cart--product-button--product-image--product-rating--product-title.js 0 B -151 B (removed) 🏆
build/product-add-to-cart-frontend.js 6.43 kB -264 B (-4%)
build/product-add-to-cart.js 178 B -8.44 kB (-98%) 🏆
build/product-best-sellers.js 8.26 kB +9 B (0%)
build/product-button--product-category-list--product-image--product-price--product-rating--product-sale-b--e17c7c01.js 0 B -500 B (removed) 🏆
build/product-button--product-image--product-price--product-rating--product-sale-badge--product-title.js 0 B -262 B (removed) 🏆
build/product-button-frontend.js 1.92 kB -302 B (-14%) 👏
build/product-button.js 0 B -4.01 kB (removed) 🏆
build/product-categories.js 2.36 kB +7 B (0%)
build/product-category-list-frontend.js 0 B -1.19 kB (removed) 🏆
build/product-category-list.js 0 B -502 B (removed) 🏆
build/product-category.js 9.25 kB +8 B (0%)
build/product-image-frontend.js 1.77 kB -449 B (-20%) 🎉
build/product-image.js 178 B -3.94 kB (-96%) 🏆
build/product-new.js 8.26 kB +12 B (0%)
build/product-on-sale.js 8.59 kB +10 B (0%)
build/product-price-frontend.js 2.08 kB -309 B (-13%) 👏
build/product-price.js 0 B -1.64 kB (removed) 🏆
build/product-query.js 11 kB +16 B (0%)
build/product-rating-frontend.js 1.33 kB -314 B (-19%) 👏
build/product-rating.js 0 B -919 B (removed) 🏆
build/product-results-count.js 1.66 kB +2 B (0%)
build/product-sale-badge-frontend.js 977 B -474 B (-33%) 🎉
build/product-sale-badge.js 0 B -820 B (removed) 🏆
build/product-search.js 2.63 kB +1 B (0%)
build/product-sku-frontend.js 454 B -253 B (-36%) 🎉
build/product-sku.js 0 B -452 B (removed) 🏆
build/product-stock-indicator-frontend.js 1.01 kB -311 B (-24%) 🎉
build/product-stock-indicator.js 0 B -646 B (removed) 🏆
build/product-summary-frontend.js 1.29 kB -291 B (-18%) 👏
build/product-summary.js 0 B -920 B (removed) 🏆
build/product-tag-list-frontend.js 0 B -1.18 kB (removed) 🏆
build/product-tag-list.js 0 B -498 B (removed) 🏆
build/product-tag.js 8.74 kB +8 B (0%)
build/product-title-frontend.js 1.37 kB -274 B (-17%) 👏
build/product-title.js 178 B -3.3 kB (-95%) 🏆
build/product-top-rated.js 8.5 kB +11 B (0%)
build/products-by-attribute.js 9.58 kB -4 B (0%)
build/rating-filter-frontend.js 20.8 kB -26 B (0%)
build/rating-filter-wrapper-frontend.js 5.58 kB -28 B (0%)
build/rating-filter.js 6.98 kB -433 B (-6%)
build/reviews-by-category.js 11.9 kB +1 B (0%)
build/reviews-by-product.js 13 kB +82 B (+1%)
build/reviews-frontend.js 7.11 kB -22 B (0%)
build/single-product-frontend.js 0 B -17.9 kB (removed) 🏆
build/single-product.js 0 B -10.6 kB (removed) 🏆
build/stock-filter-frontend.js 21 kB -23 B (0%)
build/stock-filter-wrapper-frontend.js 5.82 kB +2.67 kB (+85%) 🆘
build/stock-filter.js 7.7 kB -426 B (-5%)
build/store-notices.js 1.69 kB +3 B (0%)
build/vendors--attribute-filter-wrapper--cart-blocks/cart-cross-sells-products--cart-blocks/order-summary--82e4ed06-frontend.js 0 B -6.86 kB (removed) 🏆
build/vendors--attribute-filter-wrapper--rating-filter-wrapper--stock-filter-wrapper-frontend.js 7.7 kB +2 B (0%)
build/vendors--cart-blocks/cart-cross-sells-products--cart-blocks/cart-line-items--cart-blocks/cart-order--3c5fe802-frontend.js 5.26 kB +1 B (0%)
build/vendors--cart-blocks/cart-cross-sells-products--cart-blocks/order-summary-shipping--checkout-blocks--18f9376a-frontend.js 19.4 kB -18 B (0%)
build/vendors--cart-blocks/cart-cross-sells-products--product-add-to-cart-frontend.js 7.25 kB -6 B (0%)
build/vendors--checkout-blocks/billing-address--checkout-blocks/shipping-address-frontend.js 5.44 kB +4 B (0%)
build/wc-blocks-data.js 21.8 kB -1 B (0%)
build/wc-blocks-editor-style-rtl.css 5.78 kB -35 B (-1%)
build/wc-blocks-editor-style.css 5.78 kB -36 B (-1%)
build/wc-blocks-shared-hocs.js 1.73 kB -1 B (0%)
build/wc-blocks-style-rtl.css 26.9 kB -14 B (0%)
build/wc-blocks-style.css 26.9 kB -14 B (0%)
build/wc-blocks-vendors.js 64.2 kB -170 B (0%)
build/wc-blocks.js 2.63 kB +1 B (0%)
build/wc-shipping-method-pickup-location.js 29.9 kB +12 B (0%)
build/mini-cart-contents-block/cart-button-frontend.js 703 B +703 B (new file) 🆕
build/mini-cart-contents-block/checkout-button-frontend.js 696 B +696 B (new file) 🆕
build/vendors--attribute-filter-wrapper--cart-blocks/cart-cross-sells-products--cart-blocks/order-summary--ef6753df-frontend.js 6.85 kB +6.85 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size
build/cart-blocks/cart-cross-sells-frontend.js 253 B
build/cart-blocks/cart-items-frontend.js 302 B
build/cart-blocks/cart-totals-frontend.js 307 B
build/cart-blocks/order-summary-coupon-form-frontend.js 1.62 kB
build/cart-blocks/order-summary-heading-frontend.js 455 B
build/checkout-blocks/order-summary-discount-frontend.js 2.29 kB
build/checkout-blocks/order-summary-frontend.js 1.24 kB
build/checkout-blocks/shipping-address-frontend.js 4.14 kB
build/checkout-blocks/terms-frontend.js 1.56 kB
build/checkout-blocks/totals-frontend.js 310 B
build/general-style-rtl.css 1.31 kB
build/general-style.css 1.31 kB
build/mini-cart-contents-block/empty-cart-frontend.js 360 B
build/mini-cart-contents-block/filled-cart-frontend.js 268 B
build/mini-cart-contents-block/items-frontend.js 237 B
build/mini-cart-contents-block/products-table-frontend.js 589 B
build/price-format.js 1.19 kB
build/vendors--cart-blocks/cart-line-items--checkout-blocks/order-summary-cart-items--mini-cart-contents---233ab542-frontend.js 3.14 kB
build/vendors--cart-blocks/order-summary-shipping--checkout-blocks/order-summary-shipping--checkout-block--24d3fc0c-frontend.js 8.24 kB
build/vendors--checkout-blocks/shipping-method-frontend.js 12 kB
build/wc-blocks-google-analytics.js 1.56 kB
build/wc-blocks-middleware.js 930 B
build/wc-blocks-registry.js 3.15 kB
build/wc-blocks-shared-context.js 1.52 kB
build/wc-blocks-vendors-style-rtl.css 1.96 kB
build/wc-blocks-vendors-style.css 1.96 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
build/woo-directives-runtime.js 2.73 kB
build/woo-directives-vendors.js 7.91 kB

compressed-size-action

@albarin albarin force-pushed the 8736/add-styles-to-mini-cart-buttons branch from 239c946 to 3256614 Compare March 17, 2023 12:44
@albarin albarin marked this pull request as ready for review March 20, 2023 08:28
@woocommercebot woocommercebot requested review from a team and roykho and removed request for a team March 20, 2023 08:29
@albarin albarin requested a review from Aljullu March 20, 2023 08:29
Copy link
Contributor

@Aljullu Aljullu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is overall working well, thanks for working on this, @albarin! I noticed one issue that should be fixed, though. To reproduce: make some edits to the button texts in trunk, then, check out this branch and build. If you go to the frontend, you will see the buttons are not displayed at all (as the new Mini Cart footer block only renders inner blocks, but in the saved template there are no inner blocks!):

imatge

In the editor, the buttons are displayed, but the text modifications that were done are lost.

I'm not sure, but we might need to add a deprecation to make the legacy mode 'transition' to the new one?

Besides that, a minor one: we should preload the new frontend scripts: https://github.com/woocommerce/woocommerce-blocks/blob/trunk/src/BlockTypes/MiniCart.php#L276-L283. (I wonder if there is a way to make it simpler, so every time we create a new block we don't need to add it to this list 🤔 )

@albarin
Copy link
Contributor Author

albarin commented Mar 20, 2023

I'm not sure, but we might need to add a deprecation to make the legacy mode 'transition' to the new one?

Ouch, great catch 👌 I'll explore if we can use the deprecation thing to fix this.

@albarin
Copy link
Contributor Author

albarin commented Mar 21, 2023

@Aljullu could you have another look? I think I fixed the issue using the block deprecation approach.

Copy link
Contributor

@Aljullu Aljullu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is shaping up nicely. Overall the deprecation works well, but I found some edge cases.

If the theme has a custom template part for the Mini Cart, I think the deprecation is not running (so the same issue happens; no buttons in the frontend). You can reproduce as follows:

  1. Add a /parts/mini-cart.html file to your block theme with the contents of the previous Mini Cart template part.
  2. Go to the frontend, the buttons are not visible.

imatge

@albarin
Copy link
Contributor Author

albarin commented Mar 22, 2023

@Aljullu I've changed the migrate function and the way children/buttons are rendered. I'm not particularly fond of the way to check if there are children, but I haven't been able to find another way so far.

@albarin albarin requested a review from Aljullu March 23, 2023 08:58
Copy link
Contributor

@Aljullu Aljullu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed the migrate function and the way children/buttons are rendered. I'm not particularly fond of the way to check if there are children, but I haven't been able to find another way so far.

Yeah... I have been for some hours running in circles trying different approaches but couldn't find a better one. We will probably hit the same problem in #6259 and in any other issue where we want to break blocks into smaller pieces.

I think it's ok for now and we can iterate on it later if we find a better approach. I left some comments below, but pre-approving. Good job, @albarin, this issue was a tricky one!

@github-actions github-actions bot added this to the 9.9.0 milestone Mar 23, 2023
@albarin albarin merged commit 3e54e96 into trunk Mar 23, 2023
@albarin albarin deleted the 8736/add-styles-to-mini-cart-buttons branch March 23, 2023 15:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
block: mini-cart Issues related to the Mini-Cart block. focus: global styles Issues that involve styles/css/layout structure. type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mini Cart block: add global styles to inner buttons
2 participants