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

Feature Branch: Updated Shopper Notices #8659

Merged
merged 34 commits into from
Apr 5, 2023
Merged

Conversation

mikejolley
Copy link
Member

@mikejolley mikejolley commented Mar 7, 2023

This is a feature branch that introduces new components and styling for buyer notices. This includes standard banners, and snackbar notices (which share the same components).

Once in a complete state, we'll reach out to other product teams to ensure this meets our needs internally, and potentially move (or plan to move) these components to a package for wider adoption.

Some brief background; aside from the new look (which we aim to roll out to all notices used on the frontend across WooCommerce), the main change is the move away from @wordpress/components. This is because the WordPress component library is intended to be used in the editor, not on the frontend of the store. Therefore we're creating new components specifically for that purpose and removing the dependency. Functionally, they are very similar.

Todo:

  • Create a readme/documentation for the new components
  • Add usage documentation to Storybook
  • Test light vs dark mode doesn't break styling
  • Extract styles and apply to other core notices (this may be separate to this PR)
  • Code review from Rubik
  • Functionality review from other product teams

New Components

Note that there are new storybook entries for NoticeBanner and SnackbarList so feel free to review those there.

NoticeBanner

Drop in replacement for the Notice component from @wordpress/components with custom icons and new styles.

Docs

SnackbarList

Accepts an array of notice objects and renders as snackbars in the bottom left corner of the screen. Uses NoticeBanner for the notices themselves, but has its own wrapper that handles the styling tweaks and timeout.

Docs

Accessibility

Other Checks

  • This PR adds/removes a feature flag & I've updated this doc.
  • This PR adds/removes an experimental interfaces and I've updated this doc.
  • I tagged two reviewers because this PR makes queries to the database or I think it might have some security impact.

Screenshots

This is from Storybook:
Screenshot 2023-03-07 at 17 09 19

Testing

These new components can be seen in action in Storybook (run npm run storybook locally), or using the test cases below.

Automated Tests

  • Changes in this PR are covered by Automated Tests.
    • Unit tests
    • E2E tests

User Facing Testing

These test cases show how to trigger the new notices during certain activities.

Multiple packages notice

  1. Enable “Multiple Packages for WooCommerce” extension.
  2. Go to WooCommerce > Settings > Multiple packages
  3. Select "group by" product, then save changes.
  4. Add several items to your cart.
  5. Go to the cart page and choose “local pickup”
  6. See the “Multiple shipments must have the same pickup location” notice

Screenshot 2023-03-07 at 15 16 11

No Shipping Options

  1. Turn off multiple packages and disable all shipping rates
  2. Go to checkout
  3. See “There are no shipping options available. Please check your shipping address.” In the shipping options section.

Screenshot 2023-03-07 at 15 18 56

No Payment Methods and top level errors

  1. Go to payment settings
  2. Toggle of all payment methods
  3. Go to checkout
  4. See payment options section for the notice.
  5. Try to place an order
  6. See notice at the head of the checkout

Screenshot 2023-03-07 at 15 21 20
Screenshot 2023-03-07 at 15 35 23

Checkout Validation Errors

1. During checkout for a UK address, enter a numeric postcode
2. See notice after server refresh

Screenshot 2023-03-07 at 15 28 48

Cart shipping calculator validation errors

Repeat above test on the shipping calculator on the cart page.

Screenshot 2023-03-07 at 15 34 24

Coupon form snackbars

  1. Go to the cart page
  2. Apply a valid coupon. See snackbar. Snackbar should vanish on it’s own after 10000ms.
  3. Remove the coupon. See snackbar. Snackbar should vanish on it’s own after 10000ms.

Screenshot 2023-03-07 at 15 30 56
Screenshot 2023-03-07 at 15 30 19

WooCommerce Visibility

  • WooCommerce Core
  • Feature plugin
  • Experimental

Performance Impact

Dev Note

This update includes new designs/styles for store notices (errors, informational, success) as well as snack-bars, to give a uniform look and feel across all WooCommerce Blocks.

In addition to this, if your store uses either the Cart Block or Checkout Block on the main cart and checkout pages, styles will also transfer to core notices. These new styles should take precedence over any existing theme styles due to the new markup and CSS being applied.

The basic HTML structure of the new notices is as follows:

<div class="wc-block-components-notice-banner is-error">
     <svg />
     <div class="wc-block-components-notice-banner__content">MESSAGE</div>
</div>

There are different styles based on the notice status which include error, success, info, default, warning.

If you're not using the Cart or Checkout Blocks (if you're still using the shortcode based cart and checkout for example), existing notices rendered by WooCommerce will not be affected.

Changelog

New styles for error, info, and success notices across notices created by blocks. Additionally, existing notices in core receive new styles when Cart and Checkout Blocks are in use.

@mikejolley mikejolley added block: cart Issues related to the cart block. block: checkout Issues related to the checkout block. labels Mar 7, 2023
@mikejolley mikejolley self-assigned this Mar 7, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Mar 7, 2023

The release ZIP for this PR is accessible via:

https://wcblocks.wpcomstaging.com/wp-content/uploads/woocommerce-gutenberg-products-block-8659.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: 450
  • Total errors: 2208

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

packages/checkout/components/store-notices-container/index.tsx

packages/checkout/components/store-notices-container/snackbar-notices.tsx

comments-aggregator

@github-actions
Copy link
Contributor

github-actions bot commented Mar 7, 2023

Size Change: -4.31 kB (0%)

Total Size: 1.06 MB

Filename Size Change
build/active-filters-frontend.js 7.99 kB +2 B (0%)
build/all-products-frontend.js 11.8 kB -1 B (0%)
build/all-products.js 37.4 kB -3 B (0%)
build/all-reviews.js 7.65 kB +1 B (0%)
build/attribute-filter-frontend.js 22.5 kB +65 B (0%)
build/attribute-filter-wrapper-frontend.js 7.1 kB -1 B (0%)
build/attribute-filter.js 13.2 kB +7 B (0%)
build/blocks-checkout.js 35.1 kB -8.89 kB (-20%) 🎉
build/breadcrumbs.js 2.04 kB -2 B (0%)
build/cart-blocks/cart-accepted-payment-methods-frontend.js 1.38 kB +4 B (0%)
build/cart-blocks/cart-cross-sells-products-frontend.js 9.72 kB +4 B (0%)
build/cart-blocks/cart-express-payment--checkout-blocks/express-payment-frontend.js 5.2 kB -1 B (0%)
build/cart-blocks/cart-line-items--mini-cart-contents-block/products-table-frontend.js 5.36 kB +2 B (0%)
build/cart-blocks/cart-line-items-frontend.js 1.06 kB -1 B (0%)
build/cart-blocks/cart-order-summary-frontend.js 1.24 kB +2 B (0%)
build/cart-blocks/filled-cart-frontend.js 654 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 273 B +1 B (0%)
build/cart-blocks/order-summary-shipping-frontend.js 11.5 kB +801 B (+7%) 🔍
build/cart-blocks/proceed-to-checkout-frontend.js 1.33 kB +2 B (0%)
build/cart-frontend.js 29.3 kB +1 B (0%)
build/cart.js 48.7 kB +405 B (+1%)
build/checkout-blocks/actions-frontend.js 1.84 kB -4 B (0%)
build/checkout-blocks/billing-address-frontend.js 4.19 kB +7 B (0%)
build/checkout-blocks/contact-information-frontend.js 2.05 kB +2 B (0%)
build/checkout-blocks/express-payment-frontend.js 1.13 kB -3 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.69 kB +5 B (0%)
build/checkout-blocks/order-summary-coupon-form-frontend.js 1.78 kB -1 B (0%)
build/checkout-blocks/order-summary-frontend.js 1.24 kB +2 B (0%)
build/checkout-blocks/order-summary-shipping-frontend.js 11.6 kB +791 B (+7%) 🔍
build/checkout-blocks/order-summary-taxes-frontend.js 434 B +1 B (0%)
build/checkout-blocks/payment-frontend.js 8.78 kB +388 B (+5%) 🔍
build/checkout-blocks/pickup-options-frontend.js 4.11 kB +5 B (0%)
build/checkout-blocks/shipping-address-frontend.js 4.14 kB +4 B (0%)
build/checkout-blocks/shipping-method-frontend.js 2.61 kB +2 B (0%)
build/checkout-blocks/shipping-methods-frontend.js 5.81 kB +998 B (+21%) 🚨
build/checkout-frontend.js 30.9 kB +4 B (0%)
build/checkout.js 46.3 kB +363 B (+1%)
build/customer-account.js 3.17 kB +1 B (0%)
build/featured-category.js 14 kB +6 B (0%)
build/featured-product.js 14.4 kB -1 B (0%)
build/filter-wrapper-frontend.js 14 kB +6 B (0%)
build/filter-wrapper.js 2.39 kB +3 B (0%)
build/handpicked-products.js 7.92 kB -3 B (0%)
build/legacy-template.js 5.57 kB +3 B (0%)
build/mini-cart-component-frontend.js 28.3 kB +45 B (0%)
build/mini-cart-contents-block/cart-button-frontend.js 818 B +2 B (0%)
build/mini-cart-contents-block/checkout-button-frontend.js 819 B +1 B (0%)
build/mini-cart-contents-block/empty-cart-frontend.js 361 B +1 B (0%)
build/mini-cart-contents-block/footer-frontend.js 3.18 kB -3 B (0%)
build/mini-cart-contents-block/shopping-button-frontend.js 704 B -1 B (0%)
build/mini-cart-contents.js 17.4 kB -1 B (0%)
build/mini-cart-frontend.js 2.02 kB +1 B (0%)
build/price-filter-frontend.js 13.9 kB +3 B (0%)
build/price-filter-wrapper-frontend.js 6.96 kB +1 B (0%)
build/price-filter.js 8.4 kB -3 B (0%)
build/price-format.js 1.19 kB -1 B (0%)
build/product-add-to-cart-frontend.js 6.43 kB -2 B (0%)
build/product-best-sellers.js 8.26 kB -2 B (0%)
build/product-button-frontend.js 1.91 kB +1 B (0%)
build/product-categories.js 2.36 kB +1 B (0%)
build/product-image-frontend.js 1.76 kB -6 B (0%)
build/product-new.js 8.26 kB -1 B (0%)
build/product-on-sale.js 8.59 kB -1 B (0%)
build/product-price-frontend.js 2.08 kB -3 B (0%)
build/product-rating-frontend.js 1.33 kB -8 B (-1%)
build/product-sale-badge-frontend.js 974 B -3 B (0%)
build/product-search.js 2.63 kB -3 B (0%)
build/product-sku-frontend.js 454 B +1 B (0%)
build/product-stock-indicator-frontend.js 1.01 kB +1 B (0%)
build/product-title-frontend.js 1.37 kB -2 B (0%)
build/products-by-attribute.js 9.58 kB -4 B (0%)
build/rating-filter-frontend.js 20.8 kB +37 B (0%)
build/rating-filter.js 6.98 kB -6 B (0%)
build/reviews-by-category.js 11.9 kB +2 B (0%)
build/reviews-by-product.js 13 kB +2 B (0%)
build/reviews-frontend.js 7.1 kB -2 B (0%)
build/stock-filter-frontend.js 21.1 kB +65 B (0%)
build/stock-filter-wrapper-frontend.js 5.82 kB -2 B (0%)
build/stock-filter.js 7.7 kB +2 B (0%)
build/vendors--attribute-filter-wrapper--cart-blocks/cart-cross-sells-products--cart-blocks/order-summary--ef6753df-frontend.js 0 B -6.85 kB (removed) 🏆
build/vendors--cart-blocks/cart-cross-sells-products--cart-blocks/order-summary-shipping--checkout-blocks--18f9376a-frontend.js 19.4 kB -4 B (0%)
build/vendors--cart-blocks/cart-cross-sells-products--product-add-to-cart-frontend.js 7.25 kB +2 B (0%)
build/vendors--checkout-blocks/billing-address--checkout-blocks/shipping-address-frontend.js 5.44 kB -3 B (0%)
build/vendors--checkout-blocks/shipping-method-frontend.js 12 kB -1 B (0%)
build/wc-blocks-data.js 21.8 kB +13 B (0%)
build/wc-blocks-middleware.js 933 B +3 B (0%)
build/wc-blocks-registry.js 3.15 kB -2 B (0%)
build/wc-blocks-shared-context.js 1.52 kB -1 B (0%)
build/wc-blocks-shared-hocs.js 1.73 kB -2 B (0%)
build/wc-blocks-style-rtl.css 27.6 kB +455 B (+2%)
build/wc-blocks-style.css 27.5 kB +453 B (+2%)
build/wc-blocks-vendors.js 63.9 kB -293 B (0%)
build/wc-blocks.js 2.62 kB -2 B (0%)
build/vendors--attribute-filter-wrapper--cart-blocks/cart-cross-sells-products--cart-blocks/order-summary--82e4ed06-frontend.js 6.84 kB +6.84 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size
build/active-filters-wrapper-frontend.js 5.97 kB
build/active-filters.js 7.49 kB
build/cart-blocks/cart-cross-sells-frontend.js 253 B
build/cart-blocks/cart-express-payment-frontend.js 718 B
build/cart-blocks/cart-items-frontend.js 301 B
build/cart-blocks/cart-totals-frontend.js 307 B
build/cart-blocks/empty-cart-frontend.js 345 B
build/cart-blocks/order-summary-coupon-form-frontend.js 1.62 kB
build/cart-blocks/order-summary-heading-frontend.js 455 B
build/cart-blocks/order-summary-subtotal-frontend.js 273 B
build/cart-blocks/order-summary-taxes-frontend.js 433 B
build/catalog-sorting.js 1.7 kB
build/checkout-blocks/fields-frontend.js 331 B
build/checkout-blocks/order-summary-discount-frontend.js 2.29 kB
build/checkout-blocks/order-summary-fee-frontend.js 275 B
build/checkout-blocks/order-summary-subtotal-frontend.js 273 B
build/checkout-blocks/terms-frontend.js 1.56 kB
build/checkout-blocks/totals-frontend.js 309 B
build/general-style-rtl.css 1.31 kB
build/general-style.css 1.31 kB
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/mini-cart-contents-block/title-frontend.js 368 B
build/mini-cart.js 4.49 kB
build/product-add-to-cart.js 178 B
build/product-category.js 9.25 kB
build/product-image.js 178 B
build/product-query.js 11 kB
build/product-results-count.js 1.66 kB
build/product-summary-frontend.js 1.29 kB
build/product-tag.js 8.74 kB
build/product-title.js 178 B
build/product-top-rated.js 8.49 kB
build/rating-filter-wrapper-frontend.js 5.58 kB
build/store-notices.js 1.69 kB
build/vendors--attribute-filter-wrapper--rating-filter-wrapper--stock-filter-wrapper-frontend.js 7.7 kB
build/vendors--cart-blocks/cart-cross-sells-products--cart-blocks/cart-line-items--cart-blocks/cart-order--3c5fe802-frontend.js 5.26 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.25 kB
build/wc-blocks-editor-style-rtl.css 5.79 kB
build/wc-blocks-editor-style.css 5.79 kB
build/wc-blocks-google-analytics.js 1.56 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/wc-shipping-method-pickup-location.js 29.9 kB
build/woo-directives-runtime.js 2.73 kB
build/woo-directives-vendors.js 7.91 kB

compressed-size-action

@mikejolley
Copy link
Member Author

I have some tasks around testing but it would be great to get an early review from @woocommerce/rubik before I ask other teams to approve this work. I'll mark the PR as needing review, but please do not merge anything.

@mikejolley mikejolley marked this pull request as ready for review March 8, 2023 16:57
@woocommercebot woocommercebot requested review from a team and tarunvijwani and removed request for a team March 8, 2023 16:57
@mikejolley mikejolley requested a review from opr March 8, 2023 16:57
opr
opr previously requested changes Mar 9, 2023
Copy link
Contributor

@opr opr left a comment

Choose a reason for hiding this comment

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

Hey @mikejolley - I did an initial review and tested the functionality, here are some notes:

There are a few TS issues I mentioned inline.

Snackbar List

  • Not sure if it's possible, but it would be great to add some actions to storybook to allow adding additional snackbar entries, and also make removing the snackbar items possible, to show off the full functionality.
  • Tested in storybook and in the block, also tested with reduced motion, seems to be working OK.

Notice Banner

  • Added a few comments for formatting the README, feel free to discard if you don't like the code formatting I suggested.
  • Code for component looks good!
  • Storybook looks good, though you can't add JSX elements as children via the controls, and when you load the Error summary element, the children prop is red and invalid, i don't think this is too serious though.
  • image
  • Tested in the blocks and found an issue when the server returns HTML
  • image

Store notices container

  • You didn't change this line, but line 70 in packages/checkout/components/store-notices-container/index.tsx complains because the getNotices action returns Notice[] but additionalNotices is NoticeType[] so trying to concat the two arrays results in an error, since they apparently don't intersect. There's an issue with the status type. Not sure on a fix for now, we could just ignore the error, but I don't feel like we should have to.
  • Seems to be working fine, as NoticeBanner tested out (mostly) OK in the main notice area and the subcontexts.

assets/js/base/components/snackbar-list/README.md Outdated Show resolved Hide resolved
assets/js/base/components/snackbar-list/README.md Outdated Show resolved Hide resolved
assets/js/base/components/snackbar-list/index.tsx Outdated Show resolved Hide resolved
assets/js/base/components/notice-banner/README.md Outdated Show resolved Hide resolved
assets/js/base/components/notice-banner/index.tsx Outdated Show resolved Hide resolved
assets/js/base/components/notice-banner/test/index.js Outdated Show resolved Hide resolved
@mikejolley
Copy link
Member Author

I've taken care of that feedback I think @opr. I'll post about this on p2. Cheers.

@tarunvijwani
Copy link

@mikejolley Is this PR ready for review?

@mikejolley
Copy link
Member Author

@tarunvijwani yes, I just rebased.

@mikejolley mikejolley requested a review from opr March 23, 2023 11:27
@ralucaStan ralucaStan requested review from a team and nefeline and removed request for a team March 23, 2023 16:09
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 really like the new styles, good job! It also works great in light and dark themes. 💯

I did some testing with the Mini Cart and Cart blocks and everything is working great. Leaving some notes below and inline: 👇

  • I see build/blocks-checkout.js increased its size by 50%. I guess there is not much that we can do, but wanted to mention just in case.
  • We should add a changelog entry to the PR.
  • It might also be good to add the Mini Cart label to the PR; as the Mini Cart can also display notices.

assets/js/base/components/snackbar-list/README.md Outdated Show resolved Hide resolved
assets/js/base/components/notice-banner/style.scss Outdated Show resolved Hide resolved
@ralucaStan
Copy link
Contributor

@mikejolley it would be great to include in the docs a couple of images for each notification type so that it's easier for developers to make the connection between them

@mikejolley
Copy link
Member Author

@ralucaStan Is that not the point of the storybook entries? There you can toggle between the various types.

mikejolley and others added 15 commits April 5, 2023 12:23
* Add templates for legacy core notices

* Update src/Domain/Services/Notices.php

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>

* Remove debugging code

* DRY get_notices_template

* Simplify error template

* Fix padding

* Only include new notices if using block cart/checkout

---------

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
block: cart Issues related to the cart block. block: checkout Issues related to the checkout block. needs: dev note PR that has some text that needs to be included in the release notes. type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants