Theme: Simplify ramp object by flattening warnings to optional top-level property #72942
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What?
Closes #72931
Updates the object shape generated by the theme package to simplify how colors and warnings are referenced from a generated color ramp.
Follow-up to #72847
Why?
How?
Rather than assigning each ramp value as an object of
{ color: string, warning: boolean }, optimistically assumes that colors will be generated without warnings and instead assigns the value asstring, with warnings only assigned as a top-level object key if any exist.Optionally, as mentioned by @jsnajdr in #72847 (comment), we could remove
warningbehavior altogether, as its primary purpose is for debugging. Personally I feel it might be valuable to keep for the short-term to protect against possible regressions in contrast matching, but this should serve as an incremental step in that direction, since it makes it easier to removewarningaltogether in assuming that it's optional and likely excluded in most cases.Testing Instructions
Validate no regressions in behavior of behavior of theme provider:
npm run storybook:startVerify that building theme package succeeds and produces no local changes:
npm run --workspace @wordpress/theme buildgit status