-
Notifications
You must be signed in to change notification settings - Fork 219
Experiment: Replace style hooks coming from @wordpress/block-editor
#9251
Conversation
The release ZIP for this PR is accessible via:
Script Dependencies ReportThe
This comment was automatically generated by the TypeScript Errors Report
assets/js/atomic/blocks/product-elements/image/block.tsx
assets/js/atomic/blocks/product-elements/price/block.tsx assets/js/atomic/blocks/product-elements/rating/block.tsx assets/js/atomic/blocks/product-elements/sale-badge/block.tsx assets/js/atomic/blocks/product-elements/sku/block.tsx assets/js/atomic/blocks/product-elements/stock-indicator/block.tsx assets/js/atomic/blocks/product-elements/summary/block.tsx assets/js/atomic/blocks/product-elements/title/block.tsx assets/js/blocks/active-filters/block-wrapper.tsx assets/js/blocks/attribute-filter/block-wrapper.tsx assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-cart-button-block/block.tsx assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-checkout-button-block/block.tsx assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-title-items-counter-block/block.tsx assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-title-label-block/block.tsx assets/js/blocks/price-filter/block-wrapper.tsx assets/js/blocks/rating-filter/block-wrapper.tsx assets/js/blocks/stock-filter/block-wrapper.tsx |
Size Change: -32.6 kB (-3%) Total Size: 1.08 MB
ℹ️ View Unchanged
|
Looks like it didn't remove all dependencies in the report, but I don't see them in my local build. Will investigate, should this be the approach we want to take. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code LGTM and it works!
The downside is maintaining the utils inherited from Gutenberg.
This is my concern too. If some logic will change in the future on Gutenberg/WordPress side, we have to update the logic too :/
a21bfad
to
128a8a9
Compare
@nerrad I've hesitating pushing too hard because this is work that affects mostly FSE rather than Rubik, but it would be nice to resolve. I assume next steps are to get another review from a FSE team, and raise the issue upstream to make those hooks available. Is that correct? |
Yes. |
Logged here: WordPress/gutenberg#50334 |
112e1e1
to
8164c12
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this and it seems to be working fine, I played with a bunch of styling options on the products block and the filter blocks, it seems global styles are working fine for all of them.
I did not do a deep code review as I am very unfamiliar with this side of the project, but I looked at all files and didn't find anything that seems obviously problematic. Maybe one of the store editing teams could do a deeper review of the actual code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking great, thanks for working on this, @mikejolley!
I left some inline comments in places where we can avoid spreading objects. It's a minor change but thought I would mention anyway because it keeps code simpler.
Besides that, the only regression I found is when changing the background color of the Product Title inner block in the All Products block:
trunk |
This branch |
---|---|
...ts/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-title-label-block/block.tsx
Outdated
Show resolved
Hide resolved
...ts/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-cart-button-block/block.tsx
Outdated
Show resolved
Hide resolved
...s/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-checkout-button-block/block.tsx
Outdated
Show resolved
Hide resolved
...ocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-title-items-counter-block/block.tsx
Outdated
Show resolved
Hide resolved
…i-cart-cart-button-block/block.tsx Co-authored-by: Tom Cafferkey <[email protected]>
cd6add0
to
cb108e6
Compare
Thanks for the reviews @opr @Aljullu @tjcafferkey — I've adjusted those spreads, fixed the missing styles in atomic blocks, and retested. Tests are green so merging! |
* Empty commit for release pull request * Empty commit for release pull request * Add 10.0.6 changelog * Update versions to 10.0.6 * Fix Mini-Cart block check to see whether a script has already been enqueued (#9649) * Add 10.0.6 testing steps * Partially uplift #9251 to 10.0.x (#9654) * Update testing ZIP --------- Co-authored-by: github-actions <[email protected]> Co-authored-by: Albert Juhé Lluveras <[email protected]>
…#9251) * Replace all style hooks with useStyleProps hook * Remove border/color/spacing hooks * Style Props Hook * Make use of `change-case` package * Tidy up block wrappers * Attribute filter does not use frontend.ts nor styles within block * Remove frontend from filter blocks and unused styleprops usage * Tidy up variable names so its clearer attributes are not required specifically from blocks * Update assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-title-label-block/block.tsx Co-authored-by: Albert Juhé Lluveras <[email protected]> * Update assets/js/blocks/attribute-filter/block-wrapper.tsx Co-authored-by: Albert Juhé Lluveras <[email protected]> * Update assets/js/blocks/active-filters/block-wrapper.tsx Co-authored-by: Albert Juhé Lluveras <[email protected]> * Update assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-checkout-button-block/block.tsx Co-authored-by: Tom Cafferkey <[email protected]> * Update assets/js/blocks/rating-filter/block-wrapper.tsx Co-authored-by: Tom Cafferkey <[email protected]> * Update assets/js/blocks/stock-filter/block-wrapper.tsx Co-authored-by: Tom Cafferkey <[email protected]> * Update assets/js/blocks/price-filter/block-wrapper.tsx Co-authored-by: Tom Cafferkey <[email protected]> * Update assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-cart-button-block/block.tsx Co-authored-by: Tom Cafferkey <[email protected]> * Simplify styleprop * Styleprops simplify * Fix withFeaturedItem styles * Like the original hook, flatten props and combine with parsed styles --------- Co-authored-by: Albert Juhé Lluveras <[email protected]> Co-authored-by: Tom Cafferkey <[email protected]>
…#9251) * Replace all style hooks with useStyleProps hook * Remove border/color/spacing hooks * Style Props Hook * Make use of `change-case` package * Tidy up block wrappers * Attribute filter does not use frontend.ts nor styles within block * Remove frontend from filter blocks and unused styleprops usage * Tidy up variable names so its clearer attributes are not required specifically from blocks * Update assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-title-label-block/block.tsx Co-authored-by: Albert Juhé Lluveras <[email protected]> * Update assets/js/blocks/attribute-filter/block-wrapper.tsx Co-authored-by: Albert Juhé Lluveras <[email protected]> * Update assets/js/blocks/active-filters/block-wrapper.tsx Co-authored-by: Albert Juhé Lluveras <[email protected]> * Update assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-checkout-button-block/block.tsx Co-authored-by: Tom Cafferkey <[email protected]> * Update assets/js/blocks/rating-filter/block-wrapper.tsx Co-authored-by: Tom Cafferkey <[email protected]> * Update assets/js/blocks/stock-filter/block-wrapper.tsx Co-authored-by: Tom Cafferkey <[email protected]> * Update assets/js/blocks/price-filter/block-wrapper.tsx Co-authored-by: Tom Cafferkey <[email protected]> * Update assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-cart-button-block/block.tsx Co-authored-by: Tom Cafferkey <[email protected]> * Simplify styleprop * Styleprops simplify * Fix withFeaturedItem styles * Like the original hook, flatten props and combine with parsed styles --------- Co-authored-by: Albert Juhé Lluveras <[email protected]> Co-authored-by: Tom Cafferkey <[email protected]>
* Empty commit for release pull request * Empty commit for release pull request * Add 10.2.2 changelog * Update versions to 10.2.2 * Fix Mini-Cart block check to see whether a script has already been enqueued (#9649) * Experiment: Replace style hooks coming from `@wordpress/block-editor` (#9251) * Replace all style hooks with useStyleProps hook * Remove border/color/spacing hooks * Style Props Hook * Make use of `change-case` package * Tidy up block wrappers * Attribute filter does not use frontend.ts nor styles within block * Remove frontend from filter blocks and unused styleprops usage * Tidy up variable names so its clearer attributes are not required specifically from blocks * Update assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-title-label-block/block.tsx Co-authored-by: Albert Juhé Lluveras <[email protected]> * Update assets/js/blocks/attribute-filter/block-wrapper.tsx Co-authored-by: Albert Juhé Lluveras <[email protected]> * Update assets/js/blocks/active-filters/block-wrapper.tsx Co-authored-by: Albert Juhé Lluveras <[email protected]> * Update assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-checkout-button-block/block.tsx Co-authored-by: Tom Cafferkey <[email protected]> * Update assets/js/blocks/rating-filter/block-wrapper.tsx Co-authored-by: Tom Cafferkey <[email protected]> * Update assets/js/blocks/stock-filter/block-wrapper.tsx Co-authored-by: Tom Cafferkey <[email protected]> * Update assets/js/blocks/price-filter/block-wrapper.tsx Co-authored-by: Tom Cafferkey <[email protected]> * Update assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-cart-button-block/block.tsx Co-authored-by: Tom Cafferkey <[email protected]> * Simplify styleprop * Styleprops simplify * Fix withFeaturedItem styles * Like the original hook, flatten props and combine with parsed styles --------- Co-authored-by: Albert Juhé Lluveras <[email protected]> Co-authored-by: Tom Cafferkey <[email protected]> * Add 10.2.2 testing steps * Fix colors not being applied to Mini-Cart Proceed to Checkout Button in the editor (#9661) * Update 10.2.2 testing steps --------- Co-authored-by: github-actions <[email protected]> Co-authored-by: Albert Juhé Lluveras <[email protected]> Co-authored-by: Mike Jolley <[email protected]> Co-authored-by: Tom Cafferkey <[email protected]>
This PR Fixes #8071 by pulling in style functions from the
@wordpress/block-editor
package for use on our frontend. Style rules come from blockattributes
—we just need to translate them to CSS.While this does duplicate methods from Gutenberg, it does:
@wordpress/block-editor
dependency which is unsuitable for frontend use and largeuseStyleProps
hookThe downside is maintaining the utils inherited from Gutenberg.
While working on this and cleaning up style usage, I came across 3 blocks which had defined frontend scripts that were not used/needed. These need testing also (in instructions below).
Fixes #8071
Other Checks
Testing
Automated Tests
User Facing Testing
WooCommerce Visibility
Performance Impact
This will have a positive impact on the size of dependencies on the frontend.
Changelog