-
Notifications
You must be signed in to change notification settings - Fork 219
Product Elements: Sales badge should expose styling to theme.json
#8151
Comments
After looking into this, I have determined, that currently, the Sale badge is stylable via
We should determine if the above is the desired behavior.
|
Thank you for your exploration @danieldudzic !
That's great, but I think the spirit of @nerrad's comment on the kick-off thread (pdnLyh-30z-p2#comment-1957) was to add an Element directive so that such related elements could be styled globally and generically without styling the specific block. @nerrad, is that a correct interpretation of your words? If that's so, what kind of custom element directive should be explore? Should we have a
I think we do not need to worry about this for now: likely, we are going to remove the “Product Image” block altogether, in favor of an even more atomic approach of combining the “Cover” block with the “Sale badge”. |
It looks like there are a number of different directions that we could go with this (despite my earlier suggestions - your assessment was correct Lucio):
I'm now actually leaning toward the third option here. The only difficulty of course is determining what the default styles for the block would be that would work reasonably well for a sales badge on most themes. I'm also wondering if we should create and register a default "palette" for Woo Elements that we use for things like the sales badge and then we can automatically register that palette for every Woo installation. Block themes that want to customize the starting point for Stores could potentially set the palette colors (cc @vivialice). |
Yes, and besides just the semantics of it, wrong styles (such as hover effects indicating interactability) could be applied this way.
Agreed, that's what I was trying to articulate. I think elements do not need to be exactly low-level HTML element (for example, Core exposes a
I agree 100% with this and find the idea of providing a starting palette would benefit people immensely. I know this is probably a stupid question, but I couldn't find specific information on the Editor Styles > Global Styles > Child Theme > Parent Theme > Core right? |
Correct. I participated in an early exploration where plugins just provided a |
Hey @vivialice! Do you have any suggestions regarding default styles we could add for the Sale badge (that would work reasonably well on most themes)? @nerrad has also suggested exploring creating a default "palette" for Woo Elements that we use for things like the sales badge and then we can automatically register that palette for every Woo installation. Block themes that want to customize the starting point for Stores could potentially set the palette colors. I'd be keen to hear your thoughts regarding this. Thanks in advance! |
Let's hold off on that for now (based on further direction elsewhere). |
Further directionLet's use theme.json filters to add colors and set default styles for Sale Badges (both in Product Image and a standalone block). We should use Example (for Define
|
Hi @kmanijak, Please correct me if I am wrong. This is what I understood so far. Now as you mentioned, we can use theme.json filters instead of
In my opinion, we can go ahead & preserve the current styles. That way, we can complete the implementation & create a draft PR. Meanwhile, we can ask for feedback from Jarek & based on feedback; we can make the changes if required. Because AFAIU, we will be able to make the changes pretty quickly. @kmanijak @tjcafferkey What do you think? |
I don't think that's possible at the moment, but that would be a desirable state in a long term.
My understanding was that we want to style On Sale Badge block with some default colors (can be currents) and expose such styles through the Does it make sense? But I must admit, your comment gave me second thoughts and I'm not 100% sure 🤔
Totally agree! |
This:
(which would be added via usage of
|
Hi @nerrad, Thanks for listing the number of things that we will need to consider. That's very helpful 🙌🏻 I just wanted to confirm one thing.
As already mentioned by you & @kmanijak, that may be confusing to users as badge is not interactive element. |
Howdy! I wanted to re-open this conversation as we are facing a similar issue in #8939. The thing is:
Then, the question is: do we want product titles in the Cart block to inherit the global styles applied to the Product title block? I'm bringing this here because that issue reminded me of this one: 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, prone to break and has other issues (ie: the user can't override global styles in the component). tl;dr IMO product title and sale badge components shouldn't inherit the styles of the Product Title and Sale Badge blocks. If we want their styles to be customizable, we should convert the components into inner blocks, but the current situation in the sale badge component is confusing and we should avoid doing the same with product titles. What do you think? |
I think you've raised a good point here Albert about the nuance that context has here. While from the perspective of the shopper to a store the fact something is rendered as a part of a block or a component is irrelevant, the context of that element does matter with regards to certain styles. There are some design attributes that might be still consistent such as those around typography (or color) whereas the variations are more likely to surface with size, or gaps (padding/margin). So to add to the questions you've already asked, what is inherited from styles in the context (i.e. sizing and gaps defined by the block container components are in) vs what is specific to that element (individual blocks/components)? On the surface, I agree though, generally, I don't think components should automatically inherit the styles of the individual blocks and my initial leaning is that components should be styled via the context they are in. |
Hi @Aljullu, Please bear with me as I clarify a few points.
Are you referring to this import when mentioning product titles in the Cart block? Additionally, in the Products block, we utilize a variation of core/post-title, as evidenced here. To my knowledge, we use product titles in three ways:
Is your question whether all three instances should inherit global styles? 🤔
Regarding the Sale Badge block and sale badge component, are you referring to the following?
Please let me know if I've understood your points correctly. 🙂 |
Yes, exactly. I think at least option 2 shouldn't inherit styles from the blocks.
Yup. Sorry for not being more precise! To clarify my point: I think what we are doing here is problematic:
We are importing the component of a block to be used in a completely different block. So it inherits the styles of Product Badge, but in the editor UI that's not rendered as the Product Badge block because it can't be selected and styles can be customized. I'm not sure what's the best solution here, but I lean towards this being a proper inner block that can be selected and modified using the editor UI. |
Thanks, @Aljullu, for helping me understand your points! 🙌🏻
I also agree with you. I don't believe any of those should share global styles because all three are distinct from one another.
I agree with this as well. As far as I know, we plan to implement this in the future, where the Image block will be a combination of the Cover block and the Sale Badge block. I agree that we should be able to customize each of these individually. 🙂 |
Based on the discussion on pull request #9068, I am going to close this issue. If it's needed, we can always reopen it. |
In some way, the Sales badge should be exposed for styling to inherits from
theme.json
. A suggestion would be to use a custom element directive. In this case, we should make sure to fall back to a default.The text was updated successfully, but these errors were encountered: