Skip to content
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: Add missing block names and unify block properties #51293

Merged
merged 1 commit into from
Jul 11, 2023

Conversation

t-hamano
Copy link
Contributor

@t-hamano t-hamano commented Jun 7, 2023

What?

This PR makes the following three changes in the theme.json schema:

  • Add missing block names: Because every block has some block support.
  • Simplify core/button and core/archives block schema
  • Fix a typo (core/post-comments to core/post-comment)

Why?

To allow developers to design theme.json with reference to the correct schema.

Testing Instructions

Create the following JSON file, specifying the JSON schema changed by this PR.

{
	"$schema": "https://github.com/WordPress/gutenberg/schema/add-missing-block-and-polish/schemas/json/theme.json",
	"version": 2
}

Screenshots or screencast

Add missing block names

Before After
before after

Simplify core/button and core/archives block schema

Before After
button_before button_after
archives_before archives_after

Fix a typo (core/post-comments to core/post-comment)

Before After
typo_before typo_after

@t-hamano t-hamano self-assigned this Jun 7, 2023
@t-hamano t-hamano added [Type] Developer Documentation Documentation for developers [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. labels Jun 7, 2023
Comment on lines 687 to 694
"core/archives": {
"type": "object",
"description": "Archive block. Display a monthly archive of your posts. This block has no block-level settings",
"additionalProperties": false
"$ref": "#/definitions/settingsPropertiesComplete"
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Archive block now has some support.

Comment on lines -1866 to 1935
"core/post-comments": {
"core/post-author-biography": {
"$ref": "#/definitions/stylesPropertiesAndElementsComplete"
},
"core/post-author-name": {
"$ref": "#/definitions/stylesPropertiesAndElementsComplete"
},
"core/post-comment": {
"$ref": "#/definitions/stylesPropertiesAndElementsComplete"
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes block name (core/post-comments to core/post-comment)

Comment on lines -840 to +851
"core/post-comments": {
"core/post-author-biography": {
"$ref": "#/definitions/settingsPropertiesComplete"
},
"core/post-author-name": {
"$ref": "#/definitions/settingsPropertiesComplete"
},
"core/post-comment": {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes block name (core/post-comments to core/post-comment)

Comment on lines 699 to 706
"core/button": {
"type": "object",
"allOf": [
{
"$ref": "#/definitions/settingsPropertiesAppearanceTools"
},
{
"type": "object",
"properties": {
"border": {
"description": "Settings related to borders.",
"type": "object",
"properties": {
"radius": {
"description": "Allow users to set custom border radius.",
"type": "boolean",
"default": false
}
}
}
}
},
{ "$ref": "#/definitions/settingsPropertiesColor" },
{ "$ref": "#/definitions/settingsPropertiesLayout" },
{ "$ref": "#/definitions/settingsPropertiesSpacing" },
{
"$ref": "#/definitions/settingsPropertiesTypography"
},
{ "$ref": "#/definitions/settingsPropertiesCustom" }
]
"$ref": "#/definitions/settingsPropertiesComplete"
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it should be necessary to define only button blocks specially.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intention when this was added was to update all blocks to only show the features that they support. But seeing as that was a year and a half ago and nothing else has been updated, I think it's fine.

We really need a system to automatically generate the schema so we can be more specific about blocks without the huge maintenance burden.

@github-actions
Copy link

github-actions bot commented Jun 7, 2023

Flaky tests detected in 52028ea.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5521145155
📝 Reported issues:

@t-hamano t-hamano marked this pull request as ready for review June 7, 2023 13:03
@t-hamano t-hamano requested a review from ajlende as a code owner June 7, 2023 13:03
@ajlende ajlende force-pushed the schema/add-missing-block-and-polish branch from 0bc8246 to 52028ea Compare July 11, 2023 14:19
@ajlende ajlende enabled auto-merge (squash) July 11, 2023 14:20
@ajlende ajlende merged commit 98c01fd into trunk Jul 11, 2023
48 checks passed
@ajlende ajlende deleted the schema/add-missing-block-and-polish branch July 11, 2023 14:51
@github-actions github-actions bot added this to the Gutenberg 16.3 milestone Jul 11, 2023
@t-hamano
Copy link
Contributor Author

Thanks for the review, @ajlende 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Type] Developer Documentation Documentation for developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants