theme.json schema: Allow object type on style properties#45897
Conversation
|
|
|
Thanks for doing this.
I think refs are valid for all properties. |
| | Property | Type | Props | | ||
| | --- | --- |--- | | ||
| | color | string | | | ||
| | color | undefined | | |
There was a problem hiding this comment.
These undefined types are the result of running npm run docs:build. It looks like these changes need to match the result of this script when run on GitHub, so I've pushed these changes for now. However, this should probably be improved, as undefined isn't that helpful.
I'll spin up a follow-up PR if I figure this out!
There was a problem hiding this comment.
There isn't anything special going on with the docgen—just reading in the json file and formatting a few things as markdown. So it shouldn't be too hard to update the docgen to aggregate the types in the oneOf list which would also fix the radius property.
Eventually it would be nice to generate the schema from a higher-level source that is more suited for docgen. There's a discussion open about that, but I'd like to see the quick fix before tackling the larger problem.
There was a problem hiding this comment.
Thanks @ajlende, that's super helpful context!
Thanks, I thought so! I've added the new type to all of the style properties. |
# Conflicts: # docs/reference-guides/theme-json-reference/theme-json-living.md
|
Size Change: 0 B Total Size: 1.32 MB ℹ️ View Unchanged
|
What?
This PR adds support for objects, in addition to strings, for style properties in theme.json.
Do we need to add support for objects on other properties, in addition to color?I've now added support for all style properties.Why?
In #41696, we added the ability to reference values from other locations in the tree. However, currently, this isn't valid markup because the reference is an object rather than a string.
Fixes #45889.
How?
Add
objectto the supported types for style properties, and add a definition forref, calledrefComplete.Testing Instructions
Add the following markup to a theme.json file:
Without this PR, you should see a warning in your text editor that the ref is an incorrect type (
Incorrect type. Expected "string".). With this PR, this warning shouldn't show, at least for style values.cc. @WordPress/block-themers