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

Hide Panels for certain block styles #27205

Closed
davy440 opened this issue Nov 23, 2020 · 4 comments
Closed

Hide Panels for certain block styles #27205

davy440 opened this issue Nov 23, 2020 · 4 comments
Labels
[Feature] Theme Style Variations Related to style variations provided by block themes Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Help Request Help with setup, implementation, or "How do I?" questions.

Comments

@davy440
Copy link

davy440 commented Nov 23, 2020

Hello all,
I am creating a new style for gallery block. It is working as expected but it does not require any default gallery controls present in the Gallery Settings Panel. I want to hide these controls whenever the style is selected.

I figured that its gonna use the editor.BlockEdit filter. I referred to the example in the handbook but I cannot figure out how to make the Panel hide using the filter. This is my code as of now-

const { Fragment }	= wp.element;
const { addFilter } = wp.hooks;
const { InspectorControls } = wp.editor;
const { createHigherOrderComponent } = wp.compose;

const hideGalleryControls = createHigherOrderComponent( ( BlockEdit ) => {
	return ( props ) => {
		
		const { attributes } = props;
		
		return (
				<Fragment>
					<BlockEdit {...props} />
						<InspectorControls>
						{
							"is-style-custom" === attributes.className &&
							//Don't know what to do here
						}
						</InspectorControls>
				</Fragment>
		);
		
		
	}
}, 'hideGalleryControls' );

addFilter(
	'editor.BlockEdit',
	'custom/hideGallery',
	hideGalleryControls
);

Any help would be appreciated!

@davy440
Copy link
Author

davy440 commented Nov 24, 2020

Did a little bit of research and found an article by Florian Brinkmann - . Got to know about the removeEditorPanel in core/edit-post store.
I researched through the core and found a removeBlock method. Is there something similar like removeBlockPanel or hideBlockPanel in the core? If not, would be really nifty to have this feature.

@annezazu annezazu added [Feature] Theme Style Variations Related to style variations provided by block themes [Type] Help Request Help with setup, implementation, or "How do I?" questions. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Nov 25, 2020
@annezazu
Copy link
Contributor

Hey @davy440 ! Thanks for submitting this. @jorgefilipecosta perhaps you have some insight here?

@tellthemachines
Copy link
Contributor

Hi @davy440 ! I'm afraid there's no method to remove block panels in Core, and (to my knowledge) no plans to implement such a feature.

There is a way to disable block styling controls individually, on a per-block type basis, through theme.json. For example, if you wanted to disable padding for all Group blocks, you could add the following inside the settings object of your theme.json:

"blocks": {
			"core/group": {
				"spacing": {
					"padding": false
				}
			}
		},

You won't be able to make it work conditionally on a certain block style though.

@tellthemachines
Copy link
Contributor

I'm going to close this one in favour of #33891 which has more info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Theme Style Variations Related to style variations provided by block themes Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Help Request Help with setup, implementation, or "How do I?" questions.
Projects
None yet
Development

No branches or pull requests

3 participants