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

Try alternate highlight color #3425

Merged
merged 1 commit into from
Nov 10, 2017
Merged

Try alternate highlight color #3425

merged 1 commit into from
Nov 10, 2017

Conversation

jasmussen
Copy link
Contributor

@jasmussen jasmussen commented Nov 10, 2017

Since we have both mouse and keyboard interactions for selecting starting in text and expanding into selecting blocks at the block level, we tried using the CSS 2.1 Highlight variable so the operating system highlight color would be used. Sadly, this variable isn't uniformly implemented across platforms. It seems that on Firefox, you have to add your own translucency to the mix — the color is still probably right, but the light blue color we'e used to is actually that blue color shown at .3 opacity.

Now we can look at hacks to make that work, but it's probably a futile game. This PR takes a different approach. There's a new color, $blue-medium-highlight, which has almost the exact same saturation and lightness that the operating system light blue color has, but with a hue that's the same as the other WordPress medium blue colors. This is combined with using the ::selection and ::-moz-selection CSS properties to change the selection color, and the two match in that way. For browsers that don't support those properties, text selection will just be the same color of the operating system.

This issue was discovered here: #3068 (comment)

GIFs, Chrome:

chrome

Firefox:

firefox

Since we have both mouse and keyboard interactions for selecting starting in text and expanding into selecting blocks at the block level, we tried using the CSS 2.1 `Highlight` variable so the operating system highlight color would be used. Sadly, this variable isn't uniformly implemented across platforms. It seems that on Firefox, you have to add your own translucency to the mix — the color is still probably right, but the light blue color we'e used to is actually that blue color shown at .3 opacity.

Now we can look at hacks to make that work, but it's probably a futile game. This PR takes a different approach. There's a new color, $blue-medium-highlight, which has almost the exact same saturation and lightness that the operating system light blue color has, but with a hue that's the same as the other WordPress medium blue colors. This is combined with using the `::selection` and `::-moz-selection` CSS properties to change the selection color, and the two match in that way. For browsers that don't support those properties, text selection will just be the same color of the operating system.
@jasmussen jasmussen added the [Type] Enhancement A suggestion for improvement. label Nov 10, 2017
@jasmussen jasmussen self-assigned this Nov 10, 2017
Copy link
Contributor

@afercia afercia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on Windows, the new highlighting is consistent across all major browsers.

The contrast ratio seems good to me: https://jdlsn.com/color/?type=hex&color=444444&color2=b3e7fe

Minor concerns about the contrast ratio between the highlighting and the surrounding white background but I think this is OK and can be revisited in the future, if necessary. Worth noting on Windows the native selection uses a darker blue and inverts the text color.

@afercia
Copy link
Contributor

afercia commented Nov 10, 2017

For reference: on Windows, the native selection uses a darker blue and inverts the text color in order to have a higher contrast:

screenshot 120

screenshot 119

Copy link
Member

@karmatosed karmatosed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Thanks for working through this and let's get it in.

@karmatosed karmatosed merged commit 0ddd17f into master Nov 10, 2017
@karmatosed karmatosed deleted the try/alternate-highlight branch November 10, 2017 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants