-
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
Update: Keep existing preset shape on theme.json #25407
Update: Keep existing preset shape on theme.json #25407
Conversation
Size Change: +23 B (0%) Total Size: 1.2 MB
ℹ️ View Unchanged
|
b700aeb
to
1e5c527
Compare
🤔 Why are we worried about backwards-compatibility? |
Hi @aristath, We need to be backward compatible at the components level e.g: PanelColorGradientSettings, PanelColor, ColorPalette, and all the other components that use the current shape. Most of these components were shipped since WordPress 5.0 and use a different shape. If we change the shape we need to make the components accept both shapes or translate the new shape to the old one before passing it to the components. |
This PR is the basis of some work #25419, which is important for other tasks to continue. I'm going to merge the PR for now so other work with this branch as the base can be merged. I'm totally open to discussions on this change and in case there is feedback we can iterate on follow up PR's. |
Before the colors, gradients and and font sizes had the shape ( {slug, name, color } ), ( {slug, name, gradient } ), and ( {slug, name, fontSize } ). On theme.json, we were following the idea of all presets having the same shape ( {slug, name, value } ). This change was made when all presets were in a preset array, and we would not have any preset mapping, so if all followed the same shape, we could have a straightforward loop. Meanwhile, presets are not a single array anymore. We have a mapping, and we can also easily map the value key.
This shape change is not bringing the simplification we hoped and is doing the opposite as we need to translate between the different shapes. Just applying this simple change, we are removing lines of code.
If we don't merge this PR and we follow the idea of shape change, we will need to make sure all components that receive font-sizes, colors, and gradients support both shapes, so they are back-compatible. Or that our useEditorFeature hook converts the new shape to the old one so when it is passed to components, they can interpret it. Either way, we are increasing our maintainability effort as we will have two shapes around the codebase.
It seems the shape change did not simplified things and had the opposite effect.
How has this been tested?
I verified the preset vars are still correctly generated on the server and client.