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

Bug fix in contrastRatio function #3013

Merged
merged 4 commits into from
Mar 12, 2020
Merged

Conversation

mridulgogia
Copy link
Contributor

@mridulgogia mridulgogia commented Mar 9, 2020

Closes #2916
Fix of ContrastRatio function.

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

@kibanamachine
Copy link

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

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.

tldr; The SASS contrast calculations do seem to be working correctly now in dark mode. 👍 But someone better at math than me should review the actual code.

Testing this locally by using the makeHighContrastColor() for creating dark color contrast values, this PR does seem to fix the issues we were having before.

Examples:

Screen Shot 2020-03-09 at 12 15 52 PM

Also, testing a color combination that fails minimum contrast without a calculation:

When debugging the SASS contrast values:
Before

// SASS Original contrast
contrastRatio($euiColorDanger, $euiColorLightShade): 3.45674
// SASS Calculated contrast
contrastRatio($euiColorDangerText, $euiColorLightShade): 4.50783
// JS Calculated contrast
5.4 !== 4.5

After

// SASS Original contrast
contrastRatio($euiColorDanger, $euiColorLightShade): 4.15215
// SASS Calculated contrast
contrastRatio($euiColorDangerText, $euiColorLightShade): 4.55297
// JS Calculated contrast
4.6 ~= 4.55

CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

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

SASS code looks like it was ported correctly from the MDN JavaScript example, but I have one question on the first conditional

src/global_styling/functions/_math.scss Show resolved Hide resolved
Co-Authored-By: Caroline Horn <[email protected]>
Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

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

Code changes LGTM

@snide
Copy link
Contributor

snide commented Mar 12, 2020

I double checked this one as well. Merging! Thanks for the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Figure out what is wrong with our SASS contrastRatio() function in dark mode
5 participants