Updates to experimental-theme.json #28163
Labels
[Feature] Themes
Questions or issues with incorporating or styling blocks in a theme.
Global Styles
Anything related to the broader Global Styles efforts, including Styles Engine and theme.json
[Type] Overview
Comprehensive, high level view of an area of focus often with multiple tracking issues
Part of #20331
There's been good feedback and experimentation in the past months regarding the experimental-theme.json approach with some themes being built on top of it. This issue is to consolidate conversations that are scattered through many issues and pull requests. @jorgefilipecosta @youknowriad @ItsJonQ provided thoughts to put this together.
The need for theme metadata
theme.json has gained appeal as a place to centralize the theme metadata. Eventually, we'd want to do things like:
Example:
Related: WordPress/theme-experiments#81
Tasks:
settings
&styles
top-level keys Update theme.json shape: make settings & style top-level keys #28110customTemplates
Add support for custom templates in FSE themes #27778 Load page templates via theme.json abstractions #28700 Rename pageTemplates config to customTemplates in theme.json #28830 Add mechanism to translate custom page templates #28783templateParts
Add an 'area' term for Template Parts. #28410Controlling the visibility of UI controls.
Themes had expressed interest in having more control over what a user can do. At the moment, we have settings to opt-in/opt-out into a feature. There are two use cases to support here:
How to offer more granularity and gain the ability to define where a UI control for a property should be shown: in the block sidebar, in the global sidebar, none, or everywhere. See Controlling design tools visibility #27295 (comment)
Allow themes to decide which UI controls are shown/hidden per panel for a given block type. See Sidebar Controls & Component System #27331 Some notes:
Task:
The difference between “root/site block” VS defaults that are inherited.
Status: this is done, the global key was split into defaults and root.
At the moment, we coalesce these two things into one key,
global
, that behaves differently for settings & styles. The semantics are clearer if we separate the two concepts.The idea would be to remove the
global
key from the block list and add two new keys:root
to represent the root/site block. It maps to the UI in the global styles sidebar at the site editor (the global tab) and can control both settings & styles of that block.defaults
to represent "all the blocks" and is only allowed in settings. It serves as defaults for the blocks that they can overwrite.Tasks:
global
intodefaults
androot
Update theme.json: split global block selector into root and defaults #28533How to express hierarchy: flat vs nested
Status: a flat structure is preferred.
Task:
Comparison of a flat vs nested structure
Eventually, we're going to need to express hierarchy. This can be exemplified by the following use case: paragraphs that are top-level VS paragraphs that live within a sidebar (template part). This is necessary for both settings & styles, as the UI controls need to behave differently in each case and represent faithfully the styles.
During the past months, we discussed two ways to achieve hierarchy and this is still an open discussion:
In the theme.json it'd be:
Everything together
The full representation of a theme.json file.
The following example presumes that settings & styles are top-level keys and the block selectors are subtrees of them. An alternative to this would be to maintain today's structure (settings & styles are subtrees of a particular block selector), and/or grouping them under a top-level key called
blocks
.The following example presumes that the nested blocks live at the same level as the settings & styles keys. An alternative to this would be to create an explicit
children
key to hold nested blocks so each block would have the keyssettings
,styles
, andchildren
.The text was updated successfully, but these errors were encountered: