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

Increase contrast for EuiCodeBlock colors #3309

Merged
merged 15 commits into from
May 28, 2020

Conversation

ryankeairns
Copy link
Contributor

@ryankeairns ryankeairns commented Apr 13, 2020

Fixes #3243

Summary

The color variables used by EuiCodeBlock produce insufficient color contrast largely due to the slightly darker background color ($euiColorLightestShade vs $euiPageColorBackground).

This PR:

  • increases color contrast by adjusting the color variables using the makeHighContrastColor mixin as prescribed in the underlying issue.
  • substitutes EUI text colors directly, where possible
  • removes a few colors that were not used by any components
  • changes the addition/deletion styles from a background color to a left-border. This border approach saves a lot of hassle by not having to adjust the text color again given another bg color variation.

Screenshot 2020-04-13 16 59 07

Testing

It's a little cumbersome to test all the color variables. You can do a couple of things to render the less used colors:

  1. Use the Chrome inspector to override classes on the existing docs examples (adding/chaning to hljs-meta, hljs-title, hljs-section, hljs-addition, hljs-deletion, etc.) See the _code_block.scss file for the full set; many of these render in the existing examples already.
  2. Change the docs examples. For example, I sued this c++ example from the hljs docs to render several of the aforementioned classes:

Screenshot 2020-04-14 10 36 16

Renders as... (and all passed 4.5):

Screenshot 2020-04-14 09 43 14

Checklist

  • Check against all themes for compatibility in both light and dark modes
  • Checked in mobile
  • Checked in IE11 and Firefox
  • Props have proper autodocs
  • Added documentation examples
  • Added or updated jest tests
  • Checked for breaking changes and labeled appropriately
  • Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

@ryankeairns ryankeairns added accessibility accessibility - WCAG AA Level AA WCAG Accessibility Criteria labels Apr 13, 2020
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3309/

@ryankeairns ryankeairns marked this pull request as ready for review April 14, 2020 16:00
@ryankeairns
Copy link
Contributor Author

Need to merge master...

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3309/

@cchaos cchaos self-requested a review April 15, 2020 19:04
Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

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

Thanks for taking this one on. 🎨 Color!!! 👨‍🎨

Just had a few comments on ways to improve the code and possibly dark theme.

Eventually we'll want to follow up with some actual thinking of the different selectors. For instance here is our (pretty simple) color scheme for CSS vs Github's.

Screen Shot 2020-04-15 at 15 39 02 PM

src/global_styling/variables/_colors.scss Show resolved Hide resolved
src/global_styling/variables/_colors.scss Outdated Show resolved Hide resolved
src/themes/eui/eui_colors_dark.scss Outdated Show resolved Hide resolved
src/components/code/_code_block.scss Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@elizabetdev elizabetdev self-assigned this May 8, 2020
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3309/

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3309/

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3309/

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3309/

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3309/

@elizabetdev
Copy link
Contributor

elizabetdev commented May 27, 2020

@cchaos and @ryankeairns,

Here are a few design decisions that I took to complete this PR:

  • I tried to maintain the same hue as suggested by @cchaos. Both dark and light themes now have similar colors.
  • I'm using the makeHighContrastColor() function for all colors.
  • I removed the bold of the .hljs-keyword. I researched other similar code highlighters and none of them had the keywords with bold. This class was using the same color as the normal text and I changed it to purple. I think it looks better to have a different color.
  • The .hljs-addition and .hljs-deletion are now using a box-shadow instead of a border. But I'm not sure consumers are able to use it. Just passing one of these classes to the EuiCodeBlock component doesn't do anything because the class is added to the wrapper div instead of the <code> tag. We can address this issue in a different PR.
  • Added an orange to highlight the symbols. In the past, the symbols had the same colors as the text. I think it looks better if they are highlighted in a different color.
  • Added a SQL example in the docs.

codeBlock@2x

@elizabetdev elizabetdev requested a review from cchaos May 27, 2020 15:41
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3309/

Copy link
Contributor

@snide snide left a comment

Choose a reason for hiding this comment

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

I love it! This looks soooooo much better. Small comment about a couple of your additional variable names. Also for the addition / deletion stuff there's no rendering in the actual docs, but I'm guessing that's what you meant by making a separate issue for it?

Comment on lines 123 to 124
$euiCodeBlockPurple: #6F42C1;
$euiCodeBlockOrange: #E36209;
Copy link
Contributor

Choose a reason for hiding this comment

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

I would name these not by their color but by their purpose.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ugh. Github ate my full comment. This one is tricky. On one hand these are being used how we'd normally use a core value like $euiPrimary, or they are just one offs for use in the code blocks alone. It's hard to make a name for these things without writing the descriptive name like euiCodeBlockKeywordColor over again. Whichever direction we go, I think it's safe to say it should be the name of the color. Even something like $euiColorCodeBlock01 and $euiColorCodeBlock02 feels more flexible.

I'm sure @cchaos has opinions.

Copy link
Contributor

@cchaos cchaos May 27, 2020

Choose a reason for hiding this comment

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

Related yet tangental thought to this. Maybe we should be using the color blind palette instead of our primary, secondary, etc... colors which are more specific to our brand whereas the code block coloring is more specific to visually distinguishing between elements of code. We even have purple and orange colors in there where we then won't have to redefine new hexes for those.

Screen Shot 2020-05-27 at 14 52 28 PM

Copy link
Contributor

@elizabetdev elizabetdev May 28, 2020

Choose a reason for hiding this comment

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

@cchaos and @snide,

Here are the new updates:

  • As suggested, I replaced the colors with the color blind palette.
  • The colors $euiTextSubduedColor and $euiTextColor were not replaced because the color blind palette doesn't have colors for texts.
  • I didn't replace the $euiColorDanger because we don't have a red in the color blind palette.
  • I checked the contrast levels and all of them passed 4.5.

Let me know what you think of this new version:

codeBlock@2x

@ryankeairns
Copy link
Contributor Author

Thanks @miukimiu , the color contrast levels check out and it looks much better!

@elizabetdev elizabetdev requested a review from snide May 28, 2020 16:30
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3309/

Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

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

It is too bad that we do loose some saturation in the colors, but I think it's really only noticeable when doing a directly comparison. In the long run, it's a much better correlation to use the vis colors instead of the brand colors.

👍 LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility - WCAG AA Level AA WCAG Accessibility Criteria accessibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Insufficient color contrast in EuiCodeBlock
5 participants