-
Notifications
You must be signed in to change notification settings - Fork 219
Product Elements: Margin need to be reviewed #7954
Comments
@danieldudzic do you think we can close this issue now? Or is there something left? |
I'm still waiting on feedback from @vivialice regarding p1674213756256509-slack-C02FL3X7KR6 |
I conducted an evaluation of the Global style support for the following blocks, with a particular focus on margin and padding support.
My findingsDuring my evaluation, I discovered that some blocks lack support for global margin or padding, or both. Specifically, the following blocks do not support either:
I will create a new PR that adds support for padding and margin for all the product elements used in the Products block. |
As we have removed margins from CSS, we have to pass margin in attributes, as you can see here: woocommerce-blocks/assets/js/blocks/product-query/constants.ts Lines 87 to 92 in 0c69a83
This causes one problem. As you can see in demo video, our margin bottom will be set to 0.75rem by default in sidebar settings. i.e.
Screen.Recording.2023-04-06.at.3.20.57.PM.movBecause of this, even if user changes block margins from Global settings, it won't have any effect. In other words, these blocks bottom margin can't be set using Global styles. Solution 1: Defining margins in
|
Thanks for this research, @imanish003. My feeling is that none of the approaches is perfect because we want those elements to have margin by default without the user having set any margin in advance, so there is always going to be some confusion: "why does this block have margin if I hadn't defined it?". Having said that, I consider that passing the margins as an attribute is the best approach we have right now. I understand that means that margin global styles are not applied by default, but I think that's expected in cases where the user adds a block that contains inner blocks: some styling of those inner blocks might come with a pre-defined state to make it look good in the context it was added. Then, if I as a user add more instances of that inner block (let's imagine, Product Price), yes, I would expect it not to have margin by default and inherit the global styles. But the Product Price which is added with the default pattern, I would expect it to have opinionated margins to make it look good in the default pattern. IMO that also applies to So the tl;dr is that I don't think we should fix anything here and I would keep it as-is. However, if that's not an option, from the ones you proposed I lean more towards solution 2, as that won't impact those blocks when added in other contexts (as the Single Product template).
Related to the specificity problem you mention below in Working in Editor but not frontend. Why?. I wonder if using
|
Thanks, @Aljullu, for your feedback. It's very helpful. I'd like to share some thoughts in response to your comments 🙌🏻
I simply want themes to be able to customize the Products block using a theme.json file. Since the Products block will be used in various scenarios, I don't think we should restrict any styles. The approaches I shared enable theme developers to style product elements, and the Gutenberg style hierarchy will also function as expected. I believe this would be ideal for the Products block 🙂 To be honest, I'll consider passing styles as an attribute only as a last resort, as it disrupts the styling hierarchy. However, it might just be me who thinks this way. 🤷🏻♂️
Wow, that sounds like a great idea! I'm going to try :where() selector. Thank you so much! 🙌🏻 |
Similar issue for the
All Products
block: #2565We should review Product Elements margins. Ideally, we should transition from using
margins
in CSS to utilizingglobal styles
(to allow for better customizability). We also need to make sure not to break any of the existing (other) blocks relying on some of these margins.Example of current CSS margin for the
Product Price
:The text was updated successfully, but these errors were encountered: