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(dark-palette): improve base colors #29239

Merged
merged 2 commits into from
Apr 15, 2024
Merged

fix(dark-palette): improve base colors #29239

merged 2 commits into from
Apr 15, 2024

Conversation

liamdebeasi
Copy link
Contributor

@liamdebeasi liamdebeasi commented Mar 29, 2024

Issue number: resolves #29219


What is the current behavior?

We got feedback that the current dark theme is a bit jarring when compared with native. In particular, devs are expecting the contrast to be white for many of these colors to match native iOS. Currently, text inside of a primary button is black on dark mode, but devs expect it to be white. Additionally, the dark mode colors appear to be too washed out when compared with their light mode counterparts.

The team discussed this and we think we can find a way to make the colors more in line with what devs expect while still allowing for AA color contrast levels.

What is the new behavior?

  • Adjusted the secondary and danger colors to be slightly more vibrant/inline with what developers expect in mobile apps while still meeting AA color contrast.

Does this introduce a breaking change?

  • Yes
  • No

Other information

I intentionally did not change the contrast color, and I intentionally did not significantly change the vibrancy of each color token. I did some research into how the native platforms handle colors. I'll place this information here, because there are some subtle differences between web and native that make a difference.

Material Design

Source

Material Design 2 calls for desaturated color tokens as well as flipping contrast colors. For example, a vibrant purple background with light text on light mode is a washed purple with dark text on dark mode. The colors in Ionic <=7 did not follow these patterns. The tokens in Ionic 8 now follows these patterns, so what we have in main means we are aligning closer with native MD than have in the past.

image

iOS

Source

iOS is a bit tricky. On the docs, Apple references the WCAG color contrast formula (what Ionic follows). However, the table they present below is slightly different:

Text Size Text Weight Minimum Contrast Ratio
Up to 17 points All 4.5:1
18 points and larger All 3:1
All Bold 3:1

The last row is the main difference. WCAG states that text that is bold AND >=14pts (~18.66px) needs to meet a minimum contrast ratio of 3:1. Apple's guidelines state that any text that is bold (regardless of size) needs to meet a minimum contrast ratio of 3:1. In other words, Apple is using different guidelines to choose colors which is why colored dark mode buttons on iOS typically use white text.

However, Apple is inconsistent in implementing its own guidelines. Consider the following red buttons in the Apple Music app.

Screenshot Meets Web guidelines Meets Apple guidelines Notes
Text is not bold which makes it not meet either guidelines.
Text is bold which makes it pass the Apple guidelines, but it's still too small to also pass the Web guidelines.

Ionic

One of the things I tried is adjusting the base color to work well with white and black backgrounds. It's common to have a blue background with white text (such as a button) AND to have a blue link on a black background (such as an a element). This approach does not work well for the shade/tint colors used for hover/focus states. These colors also need to meet Web guidelines.

Consider the following example:

Screenshot Notes Text/Link passes AA guidelines Tint passes AA guidelines
Screenshot 2024-04-15 at 3 28 47 PM This uses the same primary color found in the light palette
Screenshot 2024-04-15 at 3 29 21 PM This changes the base color such that the Text/Link passes with a 4.5:1 ratio
Screenshot 2024-04-15 at 3 34 14 PM This changes the base color such that the Tint passes with a 4:5:1 ratio

We also considered adjusting the a and ion-text colors to use the tint color. We decided against that because it a) felt a little odd given that tint is typically used for states (hover, focus, etc) and b) we were concerned that making this change would impose future restrictions on how this color palette can evolve.

Conclusion

While Ionic's colors don't exactly match the iOS colors, the reality is that we are a web-based tool, so we are going to be evaluated using web-based tools/standards. As a result, it's recommended that we align closer with the Web guidelines than Apple's guidelines.

Testing

Testing:

Developers can look at the colors by opening http://localhost:3333/src/themes/test/colors

In the video below, the first state is the dark theme in main. The second state is the proposed changes.

Visual Comparison
comparison.mov

@github-actions github-actions bot added the package: core @ionic/core package label Mar 29, 2024
@liamdebeasi liamdebeasi changed the title refactor(palettes): improve dark theme feat(palettes): improve dark theme Mar 29, 2024
Copy link

vercel bot commented Apr 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ionic-framework ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 15, 2024 8:18pm

@liamdebeasi liamdebeasi changed the title feat(palettes): improve dark theme fix(dark-palette): improve base colors Apr 15, 2024
@liamdebeasi liamdebeasi marked this pull request as ready for review April 15, 2024 20:35
@liamdebeasi liamdebeasi requested a review from a team as a code owner April 15, 2024 20:35
@liamdebeasi liamdebeasi requested review from mapsandapps and brandyscarney and removed request for mapsandapps April 15, 2024 20:35
@liamdebeasi liamdebeasi merged commit 4698d22 into feature-8.0 Apr 15, 2024
65 of 66 checks passed
@liamdebeasi liamdebeasi deleted the FW-6081 branch April 15, 2024 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: core @ionic/core package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants