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

Provide ways to extend/customize the Global Styles sidebar #48068

Open
mmtr opened this issue Feb 14, 2023 · 7 comments · May be fixed by #49136
Open

Provide ways to extend/customize the Global Styles sidebar #48068

mmtr opened this issue Feb 14, 2023 · 7 comments · May be fixed by #49136
Labels
[Feature] Extensibility The ability to extend blocks or the editing experience Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Enhancement A suggestion for improvement.

Comments

@mmtr
Copy link
Contributor

mmtr commented Feb 14, 2023

What problem does this address?

Gutenberg does not provide any way to extend/customize the Global Styles sidebar for things like:

  • To display extra help content - text or video. For example maybe an organization has branding guidelines about which colors (styles) are suitable and when they ought to be used.
  • Getting other style variations from some source, i.e. ones that are 'generic' and not linked to a theme.
  • Some kind of revision log.

Plugins developers interested in such extensions are forced to manipulate the DOM (e.g. injecting custom React components inside an element located with a CSS selector). But this is very fragile, since Gutenberg can change the DOM without further notice, breaking these extensions.

What is your proposed solution?

Add standard extension points to the Global Styles sidebar such as SlotFills, hooks, or a programmatic API, so plugin developers can customize it with a more robust mechanism.

Seems that the editor sidebar is currently extensible via SlotFills (#13357), so I guess the Global Styles sidebar can follow the same approach.

@mmtr mmtr added [Feature] Extensibility The ability to extend blocks or the editing experience Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Feb 14, 2023
@Copons
Copy link
Contributor

Copons commented Feb 14, 2023

cc @mtias

@erikyo
Copy link

erikyo commented Mar 7, 2023

Same thing here, I would like to be able to extend the global styles panel (e.g. by adding the font-family) but I have not found any way to do this.

@mtias
Copy link
Member

mtias commented Mar 7, 2023

There are multiple points of extensibility to consider here. New "navigator" items should probably use a registration based API, while pieces outside the navigator could use some UI slots if we make them semantic enough. cc @gziolo @oandregal

Extending individual design features seems more granular.

@oandregal
Copy link
Member

Thanks for providing specific examples of things to be extended/customized. That helps a lot in providing feedback.

To display extra help content - text or video. For example maybe an organization has branding guidelines about which colors (styles) are suitable and when they ought to be used.

Would the existing filters help with this? They can be used to provide specific color palette per block type. There's a new one landing in 6.2 to be able to filter per block instance https://make.wordpress.org/core/2023/02/28/custom-settings-wordpress-6-2/

The case for showing some tooltips is an interesting one. I don't know that we allow that in the post editor. cc @jorgefilipecosta as he has worked quite a bit on extending UIs.

Getting other style variations from some source, i.e. ones that are 'generic' and not linked to a theme.

Can we do this with the existing filters provided by the REST API? Perhaps rest_post_dispatch? If this does not work for some reason, we could look into providing a specific filter for this.

Some kind of revision log.

There's work to add this feature. I'm not sure how active it is or whether other people could pick it up #46667


In general, my understanding so far is that the UI reflects APIs registered elsewhere (block supports from the block API, theme.json API, etc.). The UI is still a moving target (see #49014 where it's being moved to the black shell sidebar, to the left), so I don't know how stable can we make those UI slots, if any is required.

@jorgefilipecosta
Copy link
Member

The case for showing some tooltips is an interesting one. I don't know that we allow that in the post editor. cc @jorgefilipecosta as he has worked quite a bit on extending UIs.

As far as I know we don't have any API to provide additional tooltips.

@mmtr
Copy link
Contributor Author

mmtr commented Mar 30, 2023

Would the existing filters help with this? They can be used to provide specific color palette per block type.

They can definitely help with the specific example of ensuring that some style guidelines are respected. But the purpose of the example was to provide additional context about why some developers might want to modify the sidebar UI to inject additional content that could be helpful for users editing global styles, and that cannot be done with existing filters.

I understand though how making the UI extensible makes harder to iterate on it because it needs to maintain backwards compatibility.

@youknowriad
Copy link
Contributor

Ok, since there's still uncertainties about the use cases and semantics and I think for the sake of moving forward here, we can start by adding a slot in the Gutenberg plugin, protect it using the isGutenbergPlugin check, request feedback from plugins developers. Once we reach the "core merge" window, we can make a more informed call about whether we're confident enough to include these slots on core or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Extensibility The ability to extend blocks or the editing experience Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Enhancement A suggestion for improvement.
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

9 participants