WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.51k stars 4.2k forks source link

Cover block without forced color/image #38144

Open strarsis opened 2 years ago

strarsis commented 2 years ago

What problem does this address?

Sometimes a core/cover block is heavily styled by a theme, e.g. by adding complex decorative elements and background effects to it.

The cover/block currently forces a color or image selection at insertion. The theme then has to forcefully hide any color or image before applying its own complex styles. Alternatively the theme needs to rely on the end user cooperation that 0 opacity is applied.

What is your proposed solution?

Make the color/image selection optional and not mandatory as it is the case right now.

carolinan commented 2 years ago

I do run into this. Part of the problem is that the cover block is the only option we have for layering blocks over other blocks, and sometimes the block options are not suitable for what we are trying to create.

skorasaurus commented 1 year ago

I haven't tested it, but it sounds like from https://github.com/WordPress/gutenberg/issues/46148 you may be able to disable the color for the cover block using theme.json ?

jordesign commented 1 year ago

https://github.com/WordPress/gutenberg/pull/50115 suggests to me that it's possible to disable colors for the block - does this sufficiently resolve this issue for you @strarsis (and @carolinan for a gut check)?

strarsis commented 1 year ago

https://github.com/WordPress/gutenberg/pull/50115 suggests to me that it's possible to disable colors for the block - does this sufficiently resolve this issue for you @strarsis (and @carolinan for a gut check)?

Disable color for all blocks of this block type or only for specific blocks? One may still want to use a solid background color in some blocks.

jordesign commented 1 year ago

Disable color for all blocks of this block type or only for specific blocks? One may still want to use a solid background color in some blocks.

Ah yes - so the theme.json approach wouldn't work for that then.

t-hamano commented 1 year ago

I think it is also possible to disable only the color control of the cover block:

theme.json ```json { "$schema": "https://schemas.wp.org/trunk/theme.json", "version": 2, "settings": { "appearanceTools": true, "layout": { "contentSize": "840px", "wideSize": "1100px" }, "blocks": { "core/cover": { "color": { "custom": false, "customDuotone": false, "customGradient": false, "duotone": [], "gradients": [], "link": false, "palette": [], "text": false, "background": false, "defaultGradients": false, "defaultPalette": false } } } } } ```

However, when inserting a cover block, the color palette simply disappears and you are forced to insert an image.

cover-without-color

Personally, I think that the cover block, as the name suggests, is intended to have some kind of background. If you don't need a background, can you use a group block instead? I think the group block covers many of the things that can be done with the cover block.