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

Add storybook story for icon library #2787

Merged
merged 6 commits into from Jun 26, 2020
Merged

Add storybook story for icon library #2787

merged 6 commits into from Jun 26, 2020

Conversation

nerrad
Copy link
Contributor

@nerrad nerrad commented Jun 25, 2020

This pull adds a storybook story for the @woocommerce/icons library.

Image 2020-06-25 at 5 36 45 PM

This is pretty much a direct take from the equivalent Gutenberg implementation except I modified the styling a bit so more icons display on the screen. The story is setup so that any new icons added to the library will automatically display with the story.

In the process of doing this pull the story revealed the following:

  • There was direct use of wp global for filters we were using instead of importing from the package (external)
  • The dashIcon replacements we were injecting in lieu of the full dashicon library were being exported as react elements instead of nodes from the icon library which was inconsistent with other icons in the library. I switched that to export node, and then updated the dashicon module replacement to use cloneElement instead of createElement.
  • The woo icon used for our block category was also being exported as a react element instead of node. So I fixed that too. It also needed updated to correctly receive width, height and other props (so cloning to pass those values through would work). I updated the implementation where the category is registered so that it's implemented using the Icon component pattern used for all icons in the library.
  • The arrowBack icon from the library didn't have viewBox set, so that meant it wasn't reflecting changes in size properly.

To Test

The story can be tested by running npm run storybook and viewing the story for the icons. When this pull is merged to master they should show up in the generated storybook as well.

Due to the changes in other files, there should be some smoke testing of the impacted code:

wp global to package import

So the interesting thing here is that this code is related to the work don in this pull. However, I discovered while testing, that although the grid blocks are initializing with the expected defaults, all attributes are not getting saved with the blocks as expected. This is also happening on master too. So I'm not sure if there was another change that impacted this (maybe filters loading too late?) but if this behaviour is unexpected we'll likely need to investigate via a follow-up issue (cc @mikejolley).

Dashicon replacements.

The affected icons are the chevron on our selects (in checkout):

Image 2020-06-25 at 5 11 26 PM

...and the "x" dismiss icon in notifications:

Image 2020-06-25 at 5 50 26 PM

  • Verify that they icons appear and there are no errors in the console in both the frontend and backend.

Woo Icon

Verify that the woo icon displays correctly for the WooCommerce Blocks category in the Block picker.

arrowBack icon.

This icon is used with the "Return to Cart" item in the checkout block:

Image 2020-06-25 at 5 13 32 PM

  • Verify that the arrowBack icon displays as expected.

This also involved modifying the dashicon module replacement to use `cloneElement` instead of `createElement`.
The Woo category icon was not using the Icon system and not exported consistent with other icons.
@nerrad nerrad requested a review from a team as a code owner June 25, 2020 21:44
@nerrad nerrad requested review from mikejolley and removed request for a team June 25, 2020 21:44
@nerrad nerrad self-assigned this Jun 25, 2020
@nerrad nerrad added tools Used for work on build or release tools. type: enhancement The issue is a request for an enhancement. type: bug The issue/PR concerns a confirmed bug. labels Jun 25, 2020
@nerrad nerrad added this to the 2.9.0 milestone Jun 25, 2020
@github-actions
Copy link
Contributor

github-actions bot commented Jun 25, 2020

Size Change: +819 B (0%)

Total Size: 1.59 MB

Filename Size Change
build/active-filters.js 7.95 kB +1 B
build/all-products-frontend.js 41.4 kB +21 B (0%)
build/all-products.js 24.9 kB +149 B (0%)
build/all-reviews.js 9.61 kB +2 B (0%)
build/attribute-filter.js 11.6 kB -2 B (0%)
build/blocks-legacy.js 3.21 kB +291 B (9%) 🔍
build/blocks.js 3.22 kB +293 B (9%) 🔍
build/cart-frontend.js 63.8 kB +9 B (0%)
build/cart.js 33.1 kB +19 B (0%)
build/checkout-frontend.js 80.4 kB +27 B (0%)
build/checkout.js 38.6 kB +14 B (0%)
build/custom-select-control-style.js 783 B +1 B
build/featured-category-legacy.js 7.25 kB -14 B (0%)
build/featured-category.js 7.6 kB +2 B (0%)
build/featured-product-legacy.js 9.51 kB -4 B (0%)
build/featured-product.js 9.85 kB -1 B
build/handpicked-products-legacy.js 6.91 kB -2 B (0%)
build/handpicked-products.js 7.24 kB -1 B
build/price-filter.js 10.1 kB +1 B
build/product-best-sellers-legacy.js 6.99 kB -2 B (0%)
build/product-best-sellers.js 7.3 kB -2 B (0%)
build/product-categories-legacy.js 3.22 kB -6 B (0%)
build/product-category-legacy.js 7.91 kB -4 B (0%)
build/product-category.js 8.25 kB -4 B (0%)
build/product-new-legacy.js 7.14 kB -2 B (0%)
build/product-new.js 7.47 kB -3 B (0%)
build/product-on-sale-legacy.js 7.52 kB +6 B (0%)
build/product-on-sale.js 7.87 kB -2 B (0%)
build/product-search-legacy.js 3.13 kB -6 B (0%)
build/product-search.js 3.43 kB -2 B (0%)
build/product-tag-legacy.js 6.08 kB +1 B
build/product-tag.js 6.39 kB -1 B
build/product-top-rated-legacy.js 7.11 kB -4 B (0%)
build/product-top-rated.js 7.44 kB -1 B
build/reviews-by-category.js 11.6 kB +3 B (0%)
build/reviews-by-product-legacy.js 12.8 kB -3 B (0%)
build/reviews-by-product.js 13.1 kB +8 B (0%)
build/single-product-frontend.js 44.2 kB +20 B (0%)
build/single-product.js 18.3 kB +16 B (0%)
build/spinner-style-legacy.js 771 B -1 B
build/vendors-legacy.js 367 kB +3 B (0%)
build/vendors.js 415 kB +4 B (0%)
build/wc-payment-method-stripe.js 11.9 kB -2 B (0%)
build/wc-settings.js 2.14 kB -3 B (0%)
ℹ️ View Unchanged
Filename Size Change
build/active-filters-frontend.js 7.23 kB 0 B
build/all-reviews-legacy.js 9.29 kB 0 B
build/attribute-filter-frontend.js 16.8 kB 0 B
build/block-error-boundary-legacy.js 775 B 0 B
build/block-error-boundary.js 775 B 0 B
build/custom-select-control-style-legacy.js 782 B 0 B
build/editor-legacy-rtl.css 12.5 kB 0 B
build/editor-legacy.css 12.5 kB 0 B
build/editor-rtl.css 13.5 kB 0 B
build/editor.css 13.5 kB 0 B
build/price-filter-frontend.js 14.1 kB 0 B
build/product-categories.js 3.22 kB 0 B
build/product-list-style-legacy.js 775 B 0 B
build/products-by-attribute-legacy.js 7.88 kB 0 B
build/products-by-attribute.js 8.2 kB 0 B
build/reviews-by-category-legacy.js 11.3 kB 0 B
build/reviews-frontend-legacy.js 8.16 kB 0 B
build/reviews-frontend.js 9.01 kB 0 B
build/snackbar-notice-style-legacy.js 778 B 0 B
build/snackbar-notice-style.js 779 B 0 B
build/spinner-style.js 772 B 0 B
build/style-legacy-rtl.css 5.56 kB 0 B
build/style-legacy.css 5.57 kB 0 B
build/style-rtl.css 18.1 kB 0 B
build/style.css 18.1 kB 0 B
build/vendors-style-legacy-rtl.css 1.03 kB 0 B
build/vendors-style-legacy.css 1.03 kB 0 B
build/vendors-style-legacy.js 102 B 0 B
build/vendors-style-rtl.css 1.03 kB 0 B
build/vendors-style.css 1.03 kB 0 B
build/vendors-style.js 102 B 0 B
build/wc-blocks-data.js 7.09 kB 0 B
build/wc-blocks-middleware.js 932 B 0 B
build/wc-blocks-registry.js 2.19 kB 0 B
build/wc-payment-method-cheque.js 794 B 0 B
build/wc-payment-method-paypal.js 830 B 0 B
build/wc-shared-context.js 1.51 kB 0 B

compressed-size-action

@nerrad nerrad requested a review from Aljullu June 26, 2020 12:18
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.

Everything is testing well and code looks good.

I discovered while testing, that although the grid blocks are initializing with the expected defaults, all attributes are not getting saved with the blocks as expected.

Should we open an issue to investigate that?

/>
<div
style={ {
display: 'flex',
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the benefit of having inline styles instead of a style.scss file? The QuantitySelector component has a stories/style.scss file, so it might be good to decide what's the best approach and be consistent with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just a story and not a component we use so I'm just using inline styles for the purpose of the story :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The QuantitySelector component has a stories/style.scss file, so it might be good to decide what's the best approach and be consistent with it.

In that case the css class is being modified for the selector on the component. Personally I think we should avoid styles on actual components as much as possible in stories (favoring what the default look for the component is). That will help us catch potential issues with the default not being usable.

assets/js/icons/stories/index.js Outdated Show resolved Hide resolved
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
@nerrad
Copy link
Contributor Author

nerrad commented Jun 26, 2020

Should we open an issue to investigate that?

Yup, see #2789.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
tools Used for work on build or release tools. type: bug The issue/PR concerns a confirmed bug. 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

3 participants