-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
theme.json schema: Allow object type on style properties #45897
Conversation
Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
Thanks for doing this.
I think refs are valid for all properties. |
@@ -145,10 +145,10 @@ Border styles. | |||
|
|||
| Property | Type | Props | | |||
| --- | --- |--- | | |||
| color | string | | | |||
| color | undefined | | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ajlende, that's super helpful context!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created a PR for this here: #46375
Thanks, I thought so! I've added the new type to all of the style properties. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM, pending merging #46375
# 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
object
to 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