-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move Duotone "presets" blocks support data to dedicated duotone
attribute.
#48371
Comments
Could you summarize why duotone should go in filters? Feels to me like color is the most logical place. And if not, shouldn't filters at least be part of color? So |
@tomdevisser To quote @ajlende here
|
I'm actually not suggesting adding duotone under filters. Here are some examples of image block attributes for what I'm talking about. Custom DuotoneCustom duotone filters continue to be stored in {
"id": 67,
"sizeSlug": "large",
"linkDestination": "none",
"style": {
"border": { "radius": "12px", "color": "#111111", "width": "8px" },
"color": { "duotone": ["#000097", "#ff4747"] }
}
} Preset DuotoneThe preset support added by #48318 would move to {
"id": 67,
"sizeSlug": "large",
"linkDestination": "none",
"style": {
"border": { "radius": "12px", "width": "8px" }
},
"borderColor": "primary",
"duotone": "blue-red" // This is how duotone needs to be updated for presets.
} |
duotone
attribute.
Sorry for any confusion here. I raised this Issue late in my day and got all my terminology mixed up. Thanks to @ajlende for correcting things. I've updated the Issue title and description. |
Can you explain the reasoning for this change? Actually as part of the proposal here #37064 and the iterations we're doing to UI components like here, we want to move in the opposite direction for "colors", "typography"... We want to ideally unify the "style" attribute between global styles and block attribute meaning all "styles" of a given block would be stored in a unified format in the "style" attribute. |
In other words, what I suggest here is not to create a separate attribute but instead store the value of |
So #48318 introduced the concept of storing the raw string for the preset in the So when you select a preset you get the following stored If you select a custom color Duotone then an array of colors gets stored as it was previously before we supported storing presets. The change being proposed isn't introduced presets but just where we store those. This is as per #48381. If that's going to take us off track then we can easily stop and pivot towards something else.
We could do this but then the block is tightly coupled to the format of the preset. My thought was that it was better to store the preset string only and hide the implementation details from the block. If there's prior art doing it the other way then I can easily update that, but I would like to understand why it's preferable. Much appreciated. |
|
Now you say you already store |
Here's an attempt to address this: #48426 |
Still curious about this, anyone knows what we currently support in theme.json for duotone? |
You use the CSS variable:
|
Interesting, @oandregal @jorgefilipecosta might know better here but are we normalizing everything with the "var" format or am I wrong? I mean if the decision is to actually use the CSS variables in theme.json, it could make sense to use them in block "style" attribute too. I think we do support both formats for other properties (colors...) but we should probably have a "norm" or recommendation for everyone? |
The problem with the However, when writing a theme.json file by hand it seems better to not obfuscate the fact that you're using a CSS custom property, so we've always recommended using the CSS custom property instead of the weird internal syntax. |
I think it would be nice if the style attribute only stored valid CSS (or the I think everything except for duotone is already doing that? Gradients, for example are saved as a CSS gradient string which is then parsed for editing. One possible way we could make it work for duotone is by encoding the list of colors in the URL. Something like |
I don't understand the reasoning behind this? Can you explain further? |
As per discussion below let's store any duotone presets (not custom colors which will remain "as is" in the
styles.colors.duotone
) into a new, dedicatedduotone
attribute on the block.Why do you think it would need deprecations or additional backwards compatibility code?
The way I see it, old blocks with the custom colors saved continue to work like they did before. Nothing here gets touched.
New blocks that select a preset have a new attribute that unsets the
style.color.duotone
attribute and sets the newduotone
attribute.I think that it should be this PR so that we don't have to deal with backwards compatibility when switching over to storing custom filters in
style
and presets induotone
.Originally posted by @ajlende in #48318 (comment)
The text was updated successfully, but these errors were encountered: