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

Cover block: Text color #33723

Closed
webmandesign opened this issue Jul 28, 2021 · 3 comments
Closed

Cover block: Text color #33723

webmandesign opened this issue Jul 28, 2021 · 3 comments
Labels
[Block] Cover Affects the Cover Block - used to display content laid over a background image [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Type] Enhancement A suggestion for improvement.

Comments

@webmandesign
Copy link
Contributor

What problem does this address?

It is currently difficult to set a text color for Cover block inner elements easily in one place. Currently if Cover block content contains of Heading, Paragraph and List, for example, I have to set text color for each one of these.
Instead, the preferable solution would be to set text color on the Cover block itself, so the inner elements can inherit the color.

What is your proposed solution?

In my theme, I've tried to enable the text color control for Cover block using a JavaScript code in a file enqueued via enqueue_block_editor_assets action with PHP.

Here is the actual JavaScript code portion dealing with the issue:

wp.hooks.addFilter(
	'blocks.registerBlockType',
	'my-custom-block-mods',
	function( settings, name ) {
		if ( 'core/cover' === name ) {
			settings = lodash.merge( {}, settings, {
				supports: {
					color: { text: true }
				},
			} );
		}

		return settings;
	}
);

This indeed produces a working text color control, which resolves my issue, actually.

Unfortunately, the code above breaks the custom overlay color functionality. When I use the code above, I can only choose the overlay color from predefined palette (which works well as the palette color class is applied on the Cover container) but I can no longer set a custom overlay color (which does not produce background-color:... inline style on the Cover container anymore).

I understand that overlay color is actually set as a background color on Cover container. But I fail to understand why enabling text color breaks (part of) this functionality.

Could anyone enlighten me please? Is there any way of implementing this currently via WordPress theme?
Could text color control be added to Cover block?

Thanks for any help!

@annezazu annezazu added [Block] Cover Affects the Cover Block - used to display content laid over a background image [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Type] Enhancement A suggestion for improvement. labels Jul 28, 2021
@bgoewert
Copy link

bgoewert commented Dec 1, 2021

I was trying to do this with theme.json. But it is being overwritten by the default .wp-block-cover__inner-container color.

"core/cover": {
	"color": {
		"text": "var(--wp--preset--color--black) !important"
	}
}

image

I'm currently just overriding the default .wp-block-cover__inner-container class. But it would be nice to do this with theme.json as well as the block editor.

@akasunil
Copy link
Member

I believe this is resolved in latest pull. We can close this issue. @Mamaduka

CleanShot 2024-03-14 at 14 07 45@2x

@Mamaduka
Copy link
Member

Thanks for the ping, @sunil25393. It was probably #41572.

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 [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

5 participants