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

Ensure Cart block supports the WCBlock level global styles for Blocks » Product Title #8939

Conversation

tarunvijwani
Copy link

@tarunvijwani tarunvijwani commented Apr 3, 2023

Fixes #8829
Fixes #8830
Fixes #8831

Currently, the Cart block partially supports the WCBlock level global styles for Blocks » Product Title.
This PR ensures the Cart block fully supports the WCBlock level global styles.

Screenshots

Note
The following screenshots, show the results of this PR. Please note that the product titles do not inherit the margin settings from Blocks » Product Title » Layout to prevent the layout from breaking.

Blocks » Product Title » Typography

Screen Shot 2023-04-05 at 15 48 03

Blocks » Product Title » Color

Screen Shot 2023-04-05 at 15 49 19

Blocks » Product Title » Layout

Screen Shot 2023-04-05 at 15 50 59

Testing

Automated Tests

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

User Facing Testing

  1. Install and activate the Beaumont theme.
  2. Create a test page with the Checkout block.
  3. Go to WP Admin » Settings » Reading.
  4. Define the test page from step 2. as a static page.

Screenshot 2023-03-29 at 11 15 29

  1. Go to WP Admin » Apperance » Editor.
  2. Open the Styles sidebar.
  3. Open the Blocks section.
  4. Search for the Product Title block.

Screen Shot 2023-04-05 at 15 27 51

  1. Open the Blocks » Product Title » Typography settings.
  2. Adjust FONT, SIZE, FONT WEIGHT, LINE HEIGHT and LETTER SPACE.
  3. Open the test page from step 2. both in the post editor and the frontend.
  4. Verify that the product titles show the typography settings as defined in step 10.
  5. Open the Blocks » Product Title » Colors settings.
  6. Adjust Background and Text colors. (Note that Headings color is not used in this block.)
  7. Open the test page from step 2. both in the post editor and the frontend.
  8. Verify that the product titles show the colors as defined in step 14.
  9. Open the Blocks » Product Title » Layout settings.
  10. Adjust the MARGIN.
  11. Verify that the product titles do not inherit the margin settings from step 18.

Note: Cart product title styles should match the product titles in the products block so that product titles look consistent throughout the site.

  • Do not include in the Testing Notes

WooCommerce Visibility

  • WooCommerce Core
  • Feature plugin
  • Experimental

Changelog

Ensure Cart block supports the WCBlock level global styles for Blocks » Product Title

- Add a span with product title class to fix the global style of product title.
- Inherit font-weight for product title.
@tarunvijwani tarunvijwani changed the title Ensure Cart block supports the WCblock global styles for Blocks » Product Title Ensure Cart block supports the WCBlock level global styles for Blocks » Product Title Apr 3, 2023
@tarunvijwani tarunvijwani changed the base branch from trunk to add/global-style-for-cart-checkout April 3, 2023 20:22
@tarunvijwani tarunvijwani self-assigned this Apr 3, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Apr 3, 2023

The release ZIP for this PR is accessible via:

https://wcblocks.wpcomstaging.com/wp-content/uploads/woocommerce-gutenberg-products-block-8939.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: 2207

🎉 🎉 This PR does not introduce new TS errors.

comments-aggregator

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

github-actions bot commented Apr 3, 2023

Size Change: +4.76 kB (0%)

Total Size: 1.1 MB

Filename Size Change
build/active-filters-frontend.js 8.07 kB +89 B (+1%)
build/active-filters-wrapper-frontend.js 5.97 kB +2 B (0%)
build/active-filters.js 7.49 kB +6 B (0%)
build/all-products-frontend.js 11.9 kB +96 B (+1%)
build/all-products.js 38.6 kB +206 B (+1%)
build/all-reviews.js 7.75 kB +94 B (+1%)
build/attribute-filter-frontend.js 22.6 kB +91 B (0%)
build/attribute-filter.js 13.3 kB +101 B (+1%)
build/breadcrumbs.js 2.14 kB +89 B (+4%)
build/cart-blocks/cart-cross-sells-products-frontend.js 5.42 kB +103 B (+2%)
build/cart-blocks/cart-line-items--mini-cart-contents-block/products-table-frontend.js 5.7 kB +323 B (+6%) 🔍
build/cart-blocks/cart-totals-frontend.js 307 B -1 B (0%)
build/cart-blocks/empty-cart-frontend.js 345 B +1 B (0%)
build/cart-blocks/filled-cart-frontend.js 656 B +3 B (0%)
build/cart-blocks/order-summary-coupon-form-frontend.js 1.62 kB +4 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 -1 B (0%)
build/cart-blocks/order-summary-shipping-frontend.js 11.8 kB +1 B (0%)
build/cart-frontend.js 29.4 kB +86 B (0%)
build/cart.js 44.6 kB +169 B (0%)
build/checkout-blocks/actions-frontend.js 1.85 kB -2 B (0%)
build/checkout-blocks/billing-address-frontend.js 4.19 kB +1 B (0%)
build/checkout-blocks/contact-information-frontend.js 2.05 kB -1 B (0%)
build/checkout-blocks/express-payment-frontend.js 1.13 kB -2 B (0%)
build/checkout-blocks/order-summary-cart-items-frontend.js 3.7 kB +1 B (0%)
build/checkout-blocks/order-summary-coupon-form-frontend.js 1.78 kB +2 B (0%)
build/checkout-blocks/order-summary-fee-frontend.js 274 B -1 B (0%)
build/checkout-blocks/order-summary-frontend.js 1.27 kB +1 B (0%)
build/checkout-blocks/order-summary-shipping-frontend.js 11.8 kB -1 B (0%)
build/checkout-blocks/payment-frontend.js 8.27 kB -1 B (0%)
build/checkout-blocks/shipping-address-frontend.js 4.15 kB +1 B (0%)
build/checkout-blocks/shipping-method-frontend.js 2.64 kB +2 B (0%)
build/checkout-blocks/shipping-methods-frontend.js 5.84 kB +2 B (0%)
build/checkout-frontend.js 31 kB +101 B (0%)
build/checkout.js 46.4 kB +79 B (0%)
build/featured-category.js 14 kB +89 B (+1%)
build/featured-product.js 14.3 kB +91 B (+1%)
build/filter-wrapper-frontend.js 14.1 kB +95 B (+1%)
build/filter-wrapper.js 2.39 kB -1 B (0%)
build/handpicked-products.js 8.02 kB +95 B (+1%)
build/legacy-template.js 5.66 kB +91 B (+2%)
build/mini-cart-component-frontend.js 28.4 kB +93 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 820 B -3 B (0%)
build/mini-cart-contents-block/filled-cart-frontend.js 267 B -1 B (0%)
build/mini-cart-contents-block/footer-frontend.js 3.18 kB +1 B (0%)
build/mini-cart-contents-block/products-table-frontend.js 589 B +1 B (0%)
build/mini-cart-contents-block/title-frontend.js 368 B +1 B (0%)
build/mini-cart-contents.js 17.8 kB +410 B (+2%)
build/mini-cart.js 4.57 kB +84 B (+2%)
build/price-filter-frontend.js 14 kB +92 B (+1%)
build/price-filter.js 8.55 kB +95 B (+1%)
build/product-add-to-cart-frontend.js 6.42 kB +6 B (0%)
build/product-best-sellers.js 8.35 kB +95 B (+1%)
build/product-button-frontend.js 1.91 kB -1 B (0%)
build/product-button.js 4.17 kB +1 B (0%)
build/product-categories.js 2.36 kB +2 B (0%)
build/product-category.js 9.35 kB +97 B (+1%)
build/product-image-frontend.js 1.78 kB +1 B (0%)
build/product-image.js 4.28 kB -1 B (0%)
build/product-new.js 8.35 kB +98 B (+1%)
build/product-on-sale.js 8.68 kB +100 B (+1%)
build/product-price-frontend.js 2.11 kB +2 B (0%)
build/product-price.js 1.67 kB +3 B (0%)
build/product-query.js 11.3 kB +98 B (+1%)
build/product-rating-frontend.js 1.33 kB -3 B (0%)
build/product-search.js 2.63 kB -3 B (0%)
build/product-sku-frontend.js 1 kB -1 B (0%)
build/product-sku.js 577 B -1 B (0%)
build/product-stock-indicator-frontend.js 1.01 kB -3 B (0%)
build/product-summary-frontend.js 1.29 kB +3 B (0%)
build/product-summary.js 922 B +1 B (0%)
build/product-tag.js 8.84 kB +96 B (+1%)
build/product-title-frontend.js 1.48 kB +113 B (+8%) 🔍
build/product-title.js 3.85 kB +118 B (+3%)
build/product-top-rated.js 8.59 kB +101 B (+1%)
build/products-by-attribute.js 9.69 kB +97 B (+1%)
build/rating-filter-frontend.js 20.9 kB +92 B (0%)
build/rating-filter.js 6.98 kB -1 B (0%)
build/reviews-by-category.js 12 kB +94 B (+1%)
build/reviews-by-product.js 13.1 kB +92 B (+1%)
build/reviews-frontend.js 7.18 kB +81 B (+1%)
build/single-product.js 11 kB +111 B (+1%)
build/stock-filter-frontend.js 21.2 kB +92 B (0%)
build/stock-filter-wrapper-frontend.js 5.83 kB +2 B (0%)
build/store-notices.js 1.69 kB -1 B (0%)
build/vendors--attribute-filter-wrapper--rating-filter-wrapper--stock-filter-wrapper-frontend.js 7.7 kB +1 B (0%)
build/vendors--cart-blocks/order-summary-shipping--checkout-blocks/billing-address--checkout-blocks/order--decc3dc6-frontend.js 19.4 kB +6 B (0%)
build/vendors--checkout-blocks/billing-address--checkout-blocks/shipping-address-frontend.js 5.44 kB +1 B (0%)
build/wc-blocks-data.js 22 kB +131 B (+1%)
build/wc-blocks-editor-style-rtl.css 5.84 kB +8 B (0%)
build/wc-blocks-editor-style.css 5.84 kB +7 B (0%)
build/wc-blocks-style-rtl.css 27.6 kB +21 B (0%)
build/wc-blocks-style.css 27.6 kB +21 B (0%)
build/wc-blocks-vendors.js 63.8 kB +3 B (0%)
build/wc-shipping-method-pickup-location.js 30.1 kB +104 B (0%)
ℹ️ View Unchanged
Filename Size
build/attribute-filter-wrapper-frontend.js 7.11 kB
build/blocks-checkout.js 35.1 kB
build/cart-blocks/cart-accepted-payment-methods-frontend.js 1.38 kB
build/cart-blocks/cart-cross-sells-frontend.js 253 B
build/cart-blocks/cart-express-payment--checkout-blocks/express-payment-frontend.js 5.16 kB
build/cart-blocks/cart-express-payment-frontend.js 719 B
build/cart-blocks/cart-items-frontend.js 301 B
build/cart-blocks/cart-line-items-frontend.js 1.06 kB
build/cart-blocks/cart-order-summary-frontend.js 1.27 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 431 B
build/cart-blocks/proceed-to-checkout-frontend.js 1.32 kB
build/catalog-sorting.js 1.7 kB
build/checkout-blocks/fields-frontend.js 332 B
build/checkout-blocks/order-note-frontend.js 1.14 kB
build/checkout-blocks/order-summary-discount-frontend.js 2.29 kB
build/checkout-blocks/order-summary-subtotal-frontend.js 273 B
build/checkout-blocks/order-summary-taxes-frontend.js 431 B
build/checkout-blocks/pickup-options-frontend.js 4.14 kB
build/checkout-blocks/terms-frontend.js 1.56 kB
build/checkout-blocks/totals-frontend.js 310 B
build/customer-account.js 3.17 kB
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/items-frontend.js 237 B
build/mini-cart-contents-block/shopping-button-frontend.js 705 B
build/mini-cart-frontend.js 2.02 kB
build/price-filter-wrapper-frontend.js 7.04 kB
build/price-format.js 1.19 kB
build/product-add-to-cart--product-button--product-image--product-price--product-rating--product-sale-bad--49d3ecb2.js 253 B
build/product-add-to-cart--product-button--product-image--product-rating--product-title.js 151 B
build/product-add-to-cart.js 8.84 kB
build/product-button--product-image--product-price--product-rating--product-sale-badge--product-sku--prod--5bce0384.js 464 B
build/product-button--product-image--product-price--product-rating--product-sale-badge--product-sku--product-title.js 262 B
build/product-rating.js 921 B
build/product-results-count.js 1.66 kB
build/product-sale-badge-frontend.js 975 B
build/product-sale-badge.js 800 B
build/product-stock-indicator.js 646 B
build/rating-filter-wrapper-frontend.js 5.58 kB
build/stock-filter.js 7.7 kB
build/vendors--attribute-filter-wrapper--cart-blocks/order-summary-coupon-form--cart-blocks/order-summary--48e1e4bb-frontend.js 6.82 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/vendors--checkout-blocks/shipping-method-frontend.js 12 kB
build/vendors--product-add-to-cart-frontend.js 7.25 kB
build/wc-blocks-google-analytics.js 1.56 kB
build/wc-blocks-middleware.js 933 B
build/wc-blocks-registry.js 3.15 kB
build/wc-blocks-shared-context.js 1.52 kB
build/wc-blocks-shared-hocs.js 1.73 kB
build/wc-blocks-vendors-style-rtl.css 1.96 kB
build/wc-blocks-vendors-style.css 1.96 kB
build/wc-blocks.js 2.63 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

@tarunvijwani tarunvijwani marked this pull request as ready for review April 3, 2023 20:33
@woocommercebot woocommercebot requested review from a team and nielslange and removed request for a team April 3, 2023 20:33
@tarunvijwani tarunvijwani requested review from a team, Aljullu, nielslange and mikejolley and removed request for nielslange and a team April 3, 2023 20:33
nielslange

This comment was marked as outdated.

@nielslange nielslange assigned nielslange and unassigned tarunvijwani Apr 5, 2023
Copy link
Member

@mikejolley mikejolley left a comment

Choose a reason for hiding this comment

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

Works but we should revise how the components are used rather than insert a span using another components classname.

name={ name }
permalink={ permalink }
/>
<span className="wc-block-components-product-title">
Copy link
Member

Choose a reason for hiding this comment

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

I believe wrapping this with a classname is the wrong approach. It looks as though wc-block-components-product-title is used within the product title block and is not exposed as a component. Why don't we expose a component instead? if the styles and component are to be shared, that makes the most sense.

  • Create a base component called product title
  • Move the code from the product title block into the component. Note that it accepts tag so you can define the h* tag or pass a span.
  • Make both the product title block and the cart item list use the new component.

Copy link
Member

Choose a reason for hiding this comment

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

I believe wrapping this with a classname is the wrong approach. It looks as though wc-block-components-product-title is used within the product title block and is not exposed as a component. Why don't we expose a component instead? if the styles and component are to be shared, that makes the most sense.

  • Create a base component called product title
  • Move the code from the product title block into the component. Note that it accepts tag so you can define the h* tag or pass a span.
  • Make both the product title block and the cart item list use the new component.

Thanks for your review, @mikejolley. Creating the base component sounds like a good approach. I'll do that now.

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 tested and it works well, but I have to say I'm a bit unsure if we should go ahead with this. Let me explain:

The Product Title global styles should be applied to all Product Title blocks, but nothing else IMO. In the case of the Cart block, those product titles are not the Product Title block. Instead, they are a component displaying the product title. I'm wary of applying the styles from a block to a different component, as that might cause future issues and be confusing for users. For example, it doesn't allow overriding the global styles: ie, imagine I want product titles to be bold except when displayed in the Cart block, I wouldn't be able to do that with this approach.

Something similar happened with the Sale Badge. We have the Sale Badge block and the sale badge component rendered inside the Product Image block. Currently, styles applied to the Sale Badge block are applied to the sale badge component. But IMO that's confusing and prone to break in the future.

I posted a question regarding this in #8151.

@nielslange
Copy link
Member

Thanks for your review, @Aljullu. In #8939 (review), @mikejolley suggested creating a base component called product title and using that instead of applying styles from a different block. I'll keep working on this approach now.

Comment on lines +33 to +41
export const CHECKOUT_PAGE_ID = STORE_PAGES.checkout?.id;
export const CHECKOUT_URL = STORE_PAGES.checkout?.permalink;
export const PRIVACY_URL = STORE_PAGES.privacy?.permalink;
export const PRIVACY_PAGE_NAME = STORE_PAGES.privacy?.title;
export const TERMS_URL = STORE_PAGES.terms?.permalink;
export const TERMS_PAGE_NAME = STORE_PAGES.terms?.title;
export const CART_PAGE_ID = STORE_PAGES.cart?.id;
export const CART_URL = STORE_PAGES.cart?.permalink;
export const LOGIN_URL = STORE_PAGES.myaccount?.permalink
Copy link
Member

Choose a reason for hiding this comment

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

These changes ensure that the preview does not break in Storybook.

@tarunvijwani
Copy link
Author

We're discussing the final approach on slack: p1681203933835379-slack-C02UBB1EPEF

@tarunvijwani
Copy link
Author

Closing the PR as per the discussion on Slack: p1681728763577949/1681203933.835379-slack-C02UBB1EPEF

The Product Title block and Product Title component in the Cart Line Items block are different; hence they should have different global style options. The Product Title component should inherit the parent's Global styles, i.e., Cart Line Items inner block instead of the Product Title block.

@nielslange nielslange deleted the fix/8829-cart-line-items-product-title-global-styles branch April 19, 2023 23:48
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. 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.

Ensure Cart block supports the WCBlock-level global styles for Blocks » Product Title » Typography
4 participants