-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Experiment with allowing Theme JSON to control Navigation block within the Navigation Editor screen #34784
Closed
+64
−20
Closed
Experiment with allowing Theme JSON to control Navigation block within the Navigation Editor screen #34784
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
83e6ded
Allow filtering of Theme JSON final config
getdave 53100bc
Allow block-level settings to be added to valid settings config
getdave 5b0a576
Allow for filtering of Theme-level theme JSON settings.
getdave 4a96cdb
Get setting from modified Theme JSON rather than block level prop
getdave 5a24c37
Default to previous prop value default only if setting is nullish
getdave 06db44a
Allow Theme JSON to manage justification controls
getdave 9ae1bf2
Add Theme JSON filter to main navigation file
getdave 31a2dac
Allow color settings to be controlled via Theme JSON
getdave 4aff550
Conditionalise filtering of Theme JSON to Navigation editor screen
getdave File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Allow Theme JSON to manage justification controls
- Loading branch information
commit 06db44a857091f6dffad965eea0e001b8a9c0d9f
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
I worry that if all blocks can add things here:
Can't the block register its own settings?
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 for taking a look.
Anything that isn't "valid" isn't allowed in the Theme JSON config. Therefore if we don't allow blocks to add to this we can't control them via Theme JSON at this level of granularity.
If the consensus is that Theme JSON should only allow for configuration that applies to all blocks, then the feature has
limitedsomewhat reduced utility for the configuration of (more specialised) blocks as it's a fact that many (almost all) block features won't apply generally across the board.The objectives that this exploration seeks to explore are:
As a result, I think we should at least consider opening up Theme JSON schema for extension by developers (Core or otherwise).
By doing so we will afford great flexibility and power to block builders to allow Themers (or even users!) to configure their blocks without needing to understanding complex hook/filters.
Key point: if we don't agree that Theme JSON should be extensible, then it would seem that we will need to declare it as not suitable for configuring blocks at a granular level. It will be purely for configuring common things such as spacing, colors...etc, but not for individual features.
The knock on effect for this on the Nav Editor project will be that we must move Theme JSON alongside Block Supports API as defunct for the purposes of configuring the Nav block inside the Nav Editor. This will leave us back where we are today - a plethora of brittle hooks and filters and overrides.
I've had little/limited involvement in the Theme JSON project and so I'd like to ask the opinion of @oandregal (and others) what they think. If this experiment is going against core principles of Theme JSON and Global Styles then please do let us know.
This is also a concern of mine.
Good question. They can't at the moment. However, we could (in theory) expose APIs to allow blocks to register their own Theme JSON settings.
It can't right now because this is a PoC 😄 But in the future we could enable this.
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.
Could we use the block definition (
block.json
) to register block-specific settings? Perhaps a newsupports.custom
settings section? Or perhaps we allow providing data for any registered attribute of the block?My overall thinking is that if we want to do this, the first step is to figure out a way that works for any block, whether it's a core block or a 3rd party block. As a general approach, I'd explore a path that doesn't involve letting others filter the theme.json tree directly, otherwise if/when we want to change the theme.json shape we won't be able to do it without breaking the users of those filters. If we use a declarative approach (like pulling data from
block.json
to the proper places) we are in a better spot to modify the theme.json tree in the future.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.
I'm largely unfamiliar with the inner workings of the navigation block, so I may have misunderstood things or lack the proper context. But just wanted to re-share that both block-supports and theme.json are editor-agnostic so far: they aren't meant to configure things per editor.
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 for reiterating this. We're aware the approach would be...unusual.
What we're trying to do is explore all avenues so as to be sure we've ruled out all options before we decide on a preferred direction.
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.
The topic of allowing settings per-block is something that we've discussed in a few PRs and issues. I figured it'd be good to have a single place to share our thoughts on it, so I created #35114