-
Notifications
You must be signed in to change notification settings - Fork 219
Ensure Cart block supports the WCBlock level global styles for Blocks » Product Title
#8939
Conversation
- Add a span with product title class to fix the global style of product title. - Inherit font-weight for product title.
Blocks » Product Title
Blocks » Product Title
The release ZIP for this PR is accessible via:
Script Dependencies ReportThere is no changed script dependency between this branch and trunk. This comment was automatically generated by the TypeScript Errors Report
🎉 🎉 This PR does not introduce new TS errors. |
Size Change: +4.76 kB (0%) Total Size: 1.1 MB
ℹ️ View Unchanged
|
…line-items-product-title-global-styles
…line-items-product-title-global-styles
…line-items-product-title-global-styles
…line-items-product-title-global-styles
…line-items-product-title-global-styles
…line-items-product-title-global-styles
…line-items-product-title-global-styles
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.
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"> |
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 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.
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 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.
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 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.
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. |
…line-items-product-title-global-styles
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 |
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.
These changes ensure that the preview does not break in Storybook.
We're discussing the final approach on slack: p1681203933835379-slack-C02UBB1EPEF |
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. |
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
Blocks » Product Title » Typography
Blocks » Product Title » Color
Blocks » Product Title » Layout
Testing
Automated Tests
User Facing Testing
WP Admin » Settings » Reading
.WP Admin » Apperance » Editor
.Styles
sidebar.Blocks
section.Product Title
block.Blocks » Product Title » Typography
settings.FONT
,SIZE
,FONT WEIGHT
,LINE HEIGHT
andLETTER SPACE
.Blocks » Product Title » Colors
settings.Background
andText
colors. (Note thatHeadings
color is not used in this block.)Blocks » Product Title » Layout
settings.MARGIN
.Note: Cart product title styles should match the product titles in the products block so that product titles look consistent throughout the site.
WooCommerce Visibility
Changelog