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

Add editor.PanelBody.children filter #24513

Closed

Conversation

aristath
Copy link
Member

This is a simple change, adding a new editor.PanelBody.children filter.
This will allow plugin & theme developers to modify controls that were already added from somewhere else (core or 3rd parties), add their own, and generally be allowed to tweak things properly without resorting to hacky, hardcoded solutions.

An example scenario: Recently in a theme I was building I wanted to add a simple switch in the colors panel to allow auto-calculating the text-color for maximum readability depending on the selected background-color. It was impossible to do because a filter was not present.

There are many scenarios I can think of that would benefit from something like this, both in plugins and themes 👍

@youknowriad
Copy link
Contributor

Thanks for opening the PR.

That said, I'm not sure this is great filter to add for several reasons. We faced a lot of issues with Component filters in terms of backward compatibility and we decided basically to stop adding these. The reasoning is that the props of the components often need to change, new props, props removed... and maintaining backward compatibility there quickly becomes a nightmare.

Also, instead of adding hooks because they're potentially useful (which is true but it's also true for all components), we tend to try to generalize APIs instead, we prefer APIs that are related to data and not UI in general.

I hope this makes sense.

@aristath
Copy link
Member Author

aristath commented Aug 14, 2020

@youknowriad It makes sense, yes.
But how can one add something to an existing panel? Is there any way that can be accomplished with what we have now? 🤔
Developers may need to add some things that don't necessarily have an impact on props... So I could for example add a notice inside the colors panel that says something along the lines of The link color you have selected achieves WCAG AA compliance. If you need AAA, please select a color with greater constrast with its surrounding text. Suggested value: #f00.

@youknowriad
Copy link
Contributor

But how can one add something to an existing panel? Is there any way that can be accomplished with what we have now?

This has came up a few times already and I really understand that developers want to tweak these panels easily but any UI related filters/logic is subject to changes and breakage in the future and is something we ideally avoid. Of course we can still discuss filter by filter by in general.

The link color you have selected achieves WCAG AA compliance. If you need AAA, please select a color with greater constrast with its surrounding text. Suggested value: #f00.

This is an interesting example and something we'd want to support directly in Core IMO, in fact, there's already support for it for regular colors/backgrounds so I think we can probably bring it to link colors too.

When it comes to configuring panels, we'd like to propose an API related to theme.json to enable/disable things which can also mean the possibility to replace panels.

@aristath
Copy link
Member Author

aristath commented Sep 2, 2020

A separate issue to add contrast-checking was opened in #24595 so I'll go ahead and close this one since it's not how we want to do handle things. A proper, generalized API would be preferable 👍

@aristath aristath closed this Sep 2, 2020
@aristath aristath deleted the aristath/add-panel-children-filter branch September 2, 2020 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants