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

Editor: When picking a custom color dynamically set a text color with good contrast #37051

Closed
apeatling opened this issue Oct 24, 2019 · 3 comments · Fixed by WordPress/gutenberg#19181
Assignees
Labels
[Feature] Post/Page Editor The editor for editing posts and pages. [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it

Comments

@apeatling
Copy link
Member

apeatling commented Oct 24, 2019

If I set the background color of a group block to predefined colors, the text color inside of the group block is set to a color with an appropriate contrast (as chosen by the theme css classes has-secondary-background)

However, if I set the background color of a group block to a custom color, the text color always switches to dark grey. This means I cannot set a custom dark background color as the text is unreadable with no way to change the color.

Let's see if Gutenberg core would be interested in an enhancement where when picking a custom background color we also dynamically set a text color with good contrast.

2019-10-24 15 42 34

@apeatling apeatling added [Type] Bug When a feature is broken and / or not performing as intended [Feature] Post/Page Editor The editor for editing posts and pages. labels Oct 24, 2019
@gwwar gwwar removed their assignment Oct 31, 2019
@gwwar
Copy link
Contributor

gwwar commented Dec 12, 2019

@apeatling I think this might be an enhancement rather than a bug. When a theme preset is picked it applies the more generic class has-x-background-color, which provides a color background and text value. The editor is not setting dynamic values, so when a custom color is picked for background, it doesn't attempt to update the text colors.

Screen Shot 2019-12-11 at 5 03 20 PM

@gwwar
Copy link
Contributor

gwwar commented Dec 12, 2019

I think it'd still be a nice improvement, but we might want to see if a try PR is possible in Gutenberg since this is a core block.

@gwwar gwwar added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it and removed [Type] Bug When a feature is broken and / or not performing as intended labels Dec 14, 2019
@gwwar gwwar changed the title Editor: Custom group block background color messes with the text color Editor: When picking a custom color dynamically set a text color with good contrast Dec 14, 2019
@glendaviesnz glendaviesnz self-assigned this Dec 16, 2019
@glendaviesnz
Copy link
Contributor

glendaviesnz commented Dec 16, 2019

I have this working on a branch, with changes to the custom background dynamically setting text color to black or white depending on which provides the best contrast, and also adds a custom text color picker so this can be modified by the user:

text-color

I haven't quite got the setting of the custom text color working correctly, should be able to get it sorted and a PR up tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Post/Page Editor The editor for editing posts and pages. [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants