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

Ability to insert custom color settings into Color panel #47323

Closed
justintadlock opened this issue Jan 20, 2023 · 3 comments
Closed

Ability to insert custom color settings into Color panel #47323

justintadlock opened this issue Jan 20, 2023 · 3 comments
Assignees
Labels
[Feature] Colors Color management [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi

Comments

@justintadlock
Copy link
Contributor

When developing custom blocks, there is sometimes a need to custom color options outside of the standard text, background, and link colors. Currently, developers must add these to a custom panel instead of adding them to the core Color panel that already exists.

RNhLH39 - Imgur

This request recently appeared in the support forums, but I've seen other plugins create their own panels just to house custom color options (I've done this in one of my own plugins too).

We need the ability to insert custom color options into the existing panel instead of creating entirely new panels, which take up additional screen real estate and can often make the user experience less than ideal.

@justintadlock justintadlock added [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi [Feature] Colors Color management labels Jan 20, 2023
@skorasaurus
Copy link
Member

heavily related: #41877

@aaronrobertshaw aaronrobertshaw self-assigned this May 5, 2023
@aaronrobertshaw
Copy link
Contributor

Thanks for creating this issue @justintadlock 👍

When developing custom blocks, there is sometimes a need to custom color options outside of the standard text, background, and link colors. Currently, developers must add these to a custom panel instead of adding them to the core Color panel that already exists.

Blocks can actually already inject their own custom color controls into the Color panel. In fact, a number of core blocks already do this including:

For each of the blocks above I've linked to the code where they add their controls to the Color panel's inspector controls slot. They should provide some direction on how you can achieve adding custom color controls.

You can also find a lot of background context and history in the following PRs.

Some further details were shared in https://make.wordpress.org/core/2023/03/07/introduction-of-block-inspector-tabs/

In case an overly simplified snippet helps:

import {
	InspectorControls,
	__experimentalColorGradientSettingsDropdown as ColorGradientSettingsDropdown,
} from '@wordpress/block-editor';

const CustomColorControls = ( { props } ) => (
	<InspectorControls group="color">
		<ColorGradientSettingsDropdown .../>
	</InspectorControls>
)

I hope that addresses this issue. Do you think we can close this one now?

@justintadlock
Copy link
Contributor Author

Yes, I think that feedback should close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Colors Color management [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi
Projects
Archived in project
Development

No branches or pull requests

3 participants