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

Add to Featured Product block option to remove custom image #5886

Merged
merged 2 commits into from
Feb 23, 2022

Conversation

tomasztunik
Copy link
Contributor

@tomasztunik tomasztunik commented Feb 17, 2022

This adds ability to remove custom image from Featured Product block. Removing custom image will reset it back to the default product image if available. This follows solution from #5719 which added this option to Featured Category block.

Fixes #5725

Accessibility

  • I've tested using only a keyboard (no mouse)

UPDATE: "Remove" label replaced with "Reset"

Screenshots

Screenshot 2022-02-18 at 00 02 37

Manual Testing

How to test the changes in this Pull Request:

  1. Add a Featured Product block to a page, post, or template.
  2. Add custom background media.
  3. The button to remove the image should be available.
  4. If clicked it should remove the custom media.
  5. If the product had an image it should display it again.

User Facing Testing

These are steps for user testing (where "user" is someone interacting with this change that is not editing any code).

  • Same as above, or
  • See steps below.

Note

misaligned "Shop Now" is an unrelated issue

Changelog

Featured Product block: add the ability to reset to a previously set custom background image.

removing custom image will reset it back to the default
product image if available
@rubikuserbot rubikuserbot requested review from a team and dinhtungdu and removed request for a team February 17, 2022 23:13
@github-actions
Copy link
Contributor

github-actions bot commented Feb 17, 2022

Size Change: +1.24 kB (0%)

Total Size: 817 kB

Filename Size Change
build/active-filters-frontend.js 6.27 kB -103 B (-2%)
build/active-filters.js 6.95 kB -106 B (-2%)
build/all-products-frontend.js 18.7 kB -77 B (0%)
build/all-products.js 34.2 kB -36 B (0%)
build/all-reviews.js 8.06 kB +6 B (0%)
build/atomic-block-components/add-to-cart--atomic-block-components/button--atomic-block-components/catego--214e300a.js 152 B -103 B (-40%) 🎉
build/atomic-block-components/add-to-cart--atomic-block-components/button--atomic-block-components/image---a7e2bb9b.js 2.72 kB +19 B (+1%)
build/atomic-block-components/add-to-cart--atomic-block-components/button.js 0 B -1.48 kB (removed) 🏆
build/atomic-block-components/add-to-cart-frontend.js 7 kB +62 B (+1%)
build/atomic-block-components/add-to-cart.js 7.5 kB +996 B (+15%) ⚠️
build/atomic-block-components/button-frontend.js 1.54 kB -3 B (0%)
build/atomic-block-components/button.js 2.15 kB +1.24 kB (+136%) 🆘
build/atomic-block-components/category-list--atomic-block-components/image--atomic-block-components/ratin--2614069e.js 470 B +4 B (+1%)
build/atomic-block-components/category-list-frontend.js 896 B +70 B (+8%) 🔍
build/atomic-block-components/image-frontend.js 1.84 kB +71 B (+4%)
build/atomic-block-components/image.js 1.49 kB +396 B (+36%) 🚨
build/atomic-block-components/price-frontend.js 1.74 kB +1 B (0%)
build/atomic-block-components/price.js 1.7 kB +3 B (0%)
build/atomic-block-components/rating-frontend.js 1.11 kB +69 B (+7%) 🔍
build/atomic-block-components/sale-badge-frontend.js 1.07 kB +68 B (+7%) 🔍
build/atomic-block-components/sale-badge.js 686 B +1 B (0%)
build/atomic-block-components/stock-indicator-frontend.js 1.01 kB +69 B (+7%) 🔍
build/atomic-block-components/stock-indicator.js 624 B +2 B (0%)
build/atomic-block-components/summary-frontend.js 1.31 kB +69 B (+6%) 🔍
build/atomic-block-components/tag-list-frontend.js 895 B +70 B (+8%) 🔍
build/atomic-block-components/title-frontend.js 1.28 kB +72 B (+6%) 🔍
build/atomic-block-components/title.js 933 B -1 B (0%)
build/attribute-filter-frontend.js 16.8 kB -51 B (0%)
build/attribute-filter.js 13 kB -5 B (0%)
build/cart-blocks/accepted-payment-methods-frontend.js 1.15 kB +1 B (0%)
build/cart-blocks/checkout-button-frontend.js 1.15 kB -2 B (0%)
build/cart-blocks/express-payment-frontend.js 5.19 kB +6 B (0%)
build/cart-blocks/filled-cart-frontend.js 767 B +1 B (0%)
build/cart-blocks/items-frontend.js 298 B -1 B (0%)
build/cart-blocks/line-items-frontend.js 5.51 kB +14 B (0%)
build/cart-blocks/order-summary-frontend.js 8.87 kB -3 B (0%)
build/cart-blocks/totals-frontend.js 321 B +1 B (0%)
build/cart-frontend.js 45.5 kB -53 B (0%)
build/cart.js 43.7 kB +30 B (0%)
build/checkout-blocks/actions-frontend.js 1.41 kB +1 B (0%)
build/checkout-blocks/billing-address--checkout-blocks/shipping-address-frontend.js 4.22 kB +3 B (0%)
build/checkout-blocks/billing-address-frontend.js 887 B -1 B (0%)
build/checkout-blocks/contact-information-frontend.js 2.94 kB +2 B (0%)
build/checkout-blocks/express-payment-frontend.js 5.48 kB +14 B (0%)
build/checkout-blocks/order-note-frontend.js 1.13 kB +2 B (0%)
build/checkout-blocks/order-summary-frontend.js 11.3 kB +6 B (0%)
build/checkout-blocks/payment-frontend.js 7.76 kB +10 B (0%)
build/checkout-blocks/shipping-address-frontend.js 974 B -2 B (0%)
build/checkout-blocks/terms-frontend.js 1.22 kB -1 B (0%)
build/checkout-blocks/totals-frontend.js 323 B -1 B (0%)
build/checkout-frontend.js 47.7 kB -50 B (0%)
build/checkout.js 45.2 kB +18 B (0%)
build/featured-category.js 8.61 kB +2 B (0%)
build/featured-product.js 9.71 kB +94 B (+1%)
build/mini-cart-component-frontend.js 14.4 kB +91 B (+1%)
build/mini-cart-contents.js 3.84 kB +7 B (0%)
build/mini-cart-frontend.js 1.71 kB -95 B (-5%)
build/mini-cart.js 6.39 kB -2 B (0%)
build/price-filter-frontend.js 12.6 kB -58 B (0%)
build/price-filter.js 8.47 kB -31 B (0%)
build/product-best-sellers.js 7.36 kB -4 B (0%)
build/product-categories.js 3.17 kB -2 B (0%)
build/product-new.js 7.66 kB +2 B (0%)
build/product-on-sale.js 7.98 kB -4 B (0%)
build/product-search.js 2.18 kB -1 B (0%)
build/product-tag.js 7.81 kB +1 B (0%)
build/products-by-attribute.js 8.38 kB -3 B (0%)
build/reviews-by-category.js 11.5 kB +2 B (0%)
build/reviews-by-product.js 12.6 kB +3 B (0%)
build/reviews-frontend.js 7.34 kB -1 B (0%)
build/single-product-frontend.js 22.1 kB -78 B (0%)
build/single-product.js 10 kB +3 B (0%)
build/stock-filter-frontend.js 6.5 kB -104 B (-2%)
build/stock-filter.js 6.57 kB -115 B (-2%)
build/vendors--atomic-block-components/add-to-cart--cart-blocks/order-summary--checkout-blocks/billing-ad--c5eb4dcd-frontend.js 19 kB +8 B (0%)
build/vendors--atomic-block-components/add-to-cart-frontend.js 7.51 kB +1 B (0%)
build/wc-blocks.js 2.62 kB +1 B (0%)
build/atomic-block-components/add-to-cart--atomic-block-components/category-list--atomic-block-components--68f6c1c4.js 203 B +203 B (new file) 🆕
ℹ️ View Unchanged
Filename Size
build/atomic-block-components/category-list.js 500 B
build/atomic-block-components/rating.js 719 B
build/atomic-block-components/sku-frontend.js 386 B
build/atomic-block-components/sku.js 386 B
build/atomic-block-components/summary.js 923 B
build/atomic-block-components/tag-list.js 499 B
build/blocks-checkout.js 17.6 kB
build/cart-blocks/empty-cart-frontend.js 345 B
build/checkout-blocks/fields-frontend.js 344 B
build/checkout-blocks/shipping-methods-frontend.js 4.81 kB
build/handpicked-products.js 7.09 kB
build/legacy-template.js 2.18 kB
build/price-format.js 1.18 kB
build/product-category.js 8.49 kB
build/product-top-rated.js 7.9 kB
build/vendors--atomic-block-components/price--cart-blocks/line-items--cart-blocks/order-summary--checkout--8a3571de-frontend.js 5.71 kB
build/vendors--cart-blocks/line-items--checkout-blocks/order-summary-frontend.js 3.14 kB
build/vendors--cart-blocks/order-summary--checkout-blocks/billing-address--checkout-blocks/order-summary---eb4d2cec-frontend.js 4.74 kB
build/wc-blocks-data.js 8.84 kB
build/wc-blocks-editor-style-rtl.css 4.85 kB
build/wc-blocks-editor-style.css 4.85 kB
build/wc-blocks-google-analytics.js 1.56 kB
build/wc-blocks-middleware.js 949 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.2 kB
build/wc-blocks-style.css 22.2 kB
build/wc-blocks-vendors-style-rtl.css 1.28 kB
build/wc-blocks-vendors-style.css 1.28 kB
build/wc-blocks-vendors.js 69.7 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.61 kB

compressed-size-action

Copy link
Member

@dinhtungdu dinhtungdu left a comment

Choose a reason for hiding this comment

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

@tomasztunik This is working great on my end. I have two minor issues, otherwise, this is looking good to me.

  • For the button label, I think Reset is better to describe the function of that button than Remove. When users click that button, if the product has a featured image, the button doesn't really "remove" the image from the users' perspective. If the label of the button is Remove custom featured image, then using Remove makes sense, but it'd be too long.
  • For the buttons group containing only icons, we don't need a separator between buttons, but for buttons with text labels, I think a separator should be used to distinguish buttons.

image

@dinhtungdu dinhtungdu added type: good first issue The issue is a good candidate for the first community contribution/for a newcomer to the team. type: enhancement The issue is a request for an enhancement. block: featured product Issues related to the Featured Product block. labels Feb 18, 2022
@tomasztunik
Copy link
Contributor Author

tomasztunik commented Feb 18, 2022

Valid points @dinhtungdu. Tried to just implement existing flow but maybe we could improve this and Featured Category blocks.

With the separator I think it wasn't added there to highlight that these two actions are related to the same background image selector context. Not sure what is the definitive way to go here.

In general I feel like the dominating "Replace" button especially if category on Featured Category block or Product is selected these seem to refer to the context of a block so feature or product rather than the image.

Maybe we should use icons there? Went with undo as trash felt too destructive and "remove" like a stop sign :)

Screenshot 2022-02-18 at 12 35 09

Screenshot 2022-02-18 at 12 33 51

VS current with text labels

Screenshot 2022-02-18 at 12 38 43

@vivialice what do you think? Should we stick to current solution? go with icons? else?

(Used Featured Category block as ref as I had it at hand, but they follow the same patterns)

@vivialice
Copy link

Hey team, I like these solutions and I think it makes sense to make that portion of the toolbar more useful. I like the icon solution but I think it could be a safer bet to follow what Gutenberg have in image blocks and keep replace rather than the picture icon for consistency. I like the reset arrow icon but since we are adding something "new" we might need to check with Gutenberg if that is okay. I agree we should group these two functions in the toolbar.

Another idea:
Screenshot 2022-02-18 at 12 34 15
This is from the Cover block. There is a clear media CTA in the sidebar settings but we could change the label to reset changes.

went with just Reset as it is commonly used in WordPress
and will have translation available
@tomasztunik
Copy link
Contributor Author

Updated with "Reset" label and retained no buttons separation to keep the context of working with background media. I've seen this mentioned elsewhere that it would be nice if these were more unified with Cover block and I think any bigger changes for Categories and Product blocks should probably include this consideration. The UI on editing cover block is more clear and more user friendly and provides more options in the sidebar than we have available here.

Copy link
Member

@dinhtungdu dinhtungdu left a comment

Choose a reason for hiding this comment

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

LGTM :shipit:

@github-actions github-actions bot added this to the 7.1.0 milestone Feb 23, 2022
@tomasztunik tomasztunik merged commit 82ff784 into trunk Feb 23, 2022
@tomasztunik tomasztunik deleted the fix/5725-featured-product-custom-image-remove branch February 23, 2022 07:16
@Aljullu
Copy link
Contributor

Aljullu commented Feb 23, 2022

@tomasztunik could you create a good-first-issue (or directly a PR) to make sure the button label is aligned between both blocks? Currently it's Reset in Featured Product but Remove in Featured Category, ideally I think they should be the same. Do you agree?

@tomasztunik
Copy link
Contributor Author

@Aljullu was planning to but the alignment issue got fixed by #5867 already!

Regarding the reset/remove - here it resets to product image - so we still have an image, there it removes the image completely and uses a background color as selected with styles. Should we unify these despite slightly different behaviour?

@Aljullu
Copy link
Contributor

Aljullu commented Feb 23, 2022

there it removes the image completely and uses a background color as selected with styles

Does it? It seems to reset the image to whatever the category image is for me:

Kooha-02-23-2022-12-02-52.mp4

(Notice that if the category doesn't have an image, then yes, a background color is used)

@tomasztunik
Copy link
Contributor Author

Ah I see, had a category without image when testing. Will update it to reflect that if image is present it will say reset else remove? or always reset?

@Aljullu
Copy link
Contributor

Aljullu commented Feb 23, 2022

Ah I see, had a category without image when testing. Will update it to reflect that if image is present it will say reset else remove? or always reset?

IMO always reset is good enough. To me, it makes sense in both contexts.

tarhi-saad pushed a commit that referenced this pull request Feb 26, 2022
* adds toolbar option to remove custom image

removing custom image will reset it back to the default
product image if available

* update copy as per discussion

went with just Reset as it is commonly used in WordPress
and will have translation available
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
block: featured product Issues related to the Featured Product block. type: enhancement The issue is a request for an enhancement. type: good first issue The issue is a good candidate for the first community contribution/for a newcomer to the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Image on Featured Product block cannot be removed
4 participants