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

Fix (Next Theme): Prefer light text on filled primary buttons #972

Conversation

joshuarrrr
Copy link
Member

@joshuarrrr joshuarrrr commented Aug 16, 2023

Description

  • Update the chooseLightOrDarkText() fn (only in next theme) to prefer light text as long as the contrast ratio is >3.5
  • Update the Button OUI docs page to provide all the color variants (except ghost) in the initial example

Note that, because primary is the same color for next dark and light, it now always has the light text.
The current contrast ratio between primary and ghost in the next theme is 3.33.

Screenshot 2023-08-16 at 15-15-27 OpenSearch UI
Screenshot 2023-08-16 at 15-15-19 OpenSearch UI
Screenshot 2023-08-16 at 15-15-08 OpenSearch UI
Screenshot 2023-08-16 at 15-14-59 OpenSearch UI

Issues Resolved

Fixes #935

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • All tests pass
    • yarn lint
    • yarn test-unit
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

For more information on following Developer Certificate of Origin and signing off your commits, please check here.

- Update the `chooseLightOrDarkText()` fn to prefer light text as long as the contrast ratio is >3.5
- Update the `Button` OUI docs page to provide all the color variants (except ghost) in the initial example

Signed-off-by: Josh Romero <[email protected]>
@KrooshalUX
Copy link
Contributor

"Note that, because primary is the same color for next dark and light, it now always has the light text.
The current contrast ratio between primary and ghost in the next theme is 3.33."

  • What is Ghost set to at this point? Is it# FCFEFF?
  • Based on color alone, I get 3.33. But, based on font weight & color, I get a passing contrast ratio (would need to also test the final version in browser once this is merged). Does the rating not take font weight and size into consideration?
  • I dont love that dark mode now also has the same light text on the button. This doesnt seem to make much sense to me, and causes visual noise (higher contrast buttons than others).

@joshuarrrr
Copy link
Member Author

What is Ghost set to at this point?

Next light and dark: #FCFEFF

Based on color alone, I get 3.33.

Yeah, it's just the pure color contrast ratio. It's not a rating, it just gets factored in along with other factors to various a11y ratings.

I dont love that dark mode now also has the same light text on the button. This doesnt seem to make much sense to me, and causes visual noise (higher contrast buttons than others).

All the other dark mode colors are noticeably lighter than the light mode equivalents, except for primary in the next theme. Do you want a variation of primary between next light and next dark, or would you like us to make the text calculation button use the underlying theme to preferentially choose dark or light text?

@KrooshalUX
Copy link
Contributor

KrooshalUX commented Aug 17, 2023

I am a little confused - In #935 (comment) - you mentioned primary wasn't being transformed for the buttons in "current" dark mode - but I am seeing what you are seeing in "Current" theme, that they are lighter in dark mode ("All the other dark mode colors are noticeably lighter than the light mode equivalents").

I had initially provided that primary color because it was stable across light and dark modes while providing sufficient contrast for buttons with light text at the cont weight/size specified.

@joshuarrrr
Copy link
Member Author

I believe this PR should be closed in favor of #981

@joshuarrrr joshuarrrr closed this Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Button text does not adjust between light and dark mode
3 participants