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

Option to disable duotone #31764

Closed
ajlende opened this issue May 12, 2021 · 7 comments · Fixed by #32002
Closed

Option to disable duotone #31764

ajlende opened this issue May 12, 2021 · 7 comments · Fixed by #32002
Assignees
Labels
[Block] Cover Affects the Cover Block - used to display content laid over a background image [Block] Image Affects the Image Block [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi [Feature] Media Anything that impacts the experience of managing media [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Status] In Progress Tracking issues with work in progress

Comments

@ajlende
Copy link
Contributor

ajlende commented May 12, 2021

What problem does this address?

There should be a way to disable the duotone UI from theme.json

What is your proposed solution?

I think for colors, if you set an empty palette [] and set custom to false in theme.json the control disappears entirely, so maybe something similar could work here too

@ajlende ajlende added [Feature] Media Anything that impacts the experience of managing media [Block] Cover Affects the Cover Block - used to display content laid over a background image [Block] Image Affects the Image Block [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. labels May 12, 2021
@ajlende
Copy link
Contributor Author

ajlende commented May 14, 2021

I think for colors, if you set an empty palette [] and set custom to false in theme.json the control disappears entirely, so maybe something similar could work here too

@mtias and @youknowriad I confirmed that this doesn't actually work for colors. Setting the values in the theme.json as specified still just shows the default palette.

These are the relevant parts of the theme.json config that I have:

{
	"version": 1,
	"settings": {
		"color": {
			"custom": false,
			"customGradient": false,
			"duotone": [],
			"gradients": [],
			"link": false,
			"palette": []
		}
	}
}

And this is what I see:

color palettes showing on the user interface when the theme.json config should have them disabled

Setting gradients or palette to false causes errors just like duotone.

Since there isn't already a system for disabling block supports via theme.json, I think having a separate setting to enable and disable them makes more sense. Palettes are used outside of block supports, so it may make sense that you want the supports disabled, but you still want the color/gradient/duotone palettes in other places like for border color for examaple.

I propose adding a block-supports option directly under settings to enable or disable the supports.

{
	"version": 1,
	"settings": {
		"block-supports": {
            "alignWide": false,
			"color": {
              "__experimentalDuotone": false,
              "background": false,
              "gradients": false,
              "text": false
           }
		}
	}
}

We default to having all block supports enabled. Setting to a value of false disables the block support. The support won't be added unless both the theme and the block have it enabled.

What do you think?

@mtias mtias added the [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi label May 14, 2021
@youknowriad
Copy link
Contributor

I think you can disable colors by doing two things, setting the palette to [] and custom to false. Confirm @jorgefilipecosta ?

@erikjoling
Copy link

erikjoling commented May 19, 2021

I found out I can disable colors and gradients by setting:

"color": {
	"custom": false,
	"customGradient": false,
	"gradients": null,
	"palette": null
}

I believe this mimics the behavior of add_theme_support where you had to add:

add_theme_support( 'disable-custom-colors' );
add_theme_support( 'disable-custom-gradients' );
add_theme_support( 'editor-color-palette' );
add_theme_support( 'editor-gradient-presets' );

But it's quite confusing and I haven't found a solution for duotone yet.

@erikjoling
Copy link

#31986

@ajlende
Copy link
Contributor Author

ajlende commented May 19, 2021

So it sounds like for this, in order to be consistent with existing settings, there are a few things that need to happen:

  1. The DuotoneControl needs to be disabled when color.duotone === null to hide the toolbar item.
  2. The ColorListPicker in the DuotonePicker dropdown needs to be disabled when color.palette === null.
  3. The CustomDuotoneBar in the DuotonePicker dropdown needs to be disabled (but probably still shown?) when color.custom === false.

Does that sound accurate?

@youknowriad
Copy link
Contributor

That makes sense yes.

@oandregal
Copy link
Member

After some conversation at #33280 I've prepared #33295 to update the logic that handles the visibility of the duotone control.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Cover Affects the Cover Block - used to display content laid over a background image [Block] Image Affects the Image Block [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi [Feature] Media Anything that impacts the experience of managing media [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Status] In Progress Tracking issues with work in progress
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants