atlas-engineer / nyxt

Nyxt - the hacker's browser.
https://nyxt-browser.com/
9.78k stars 409 forks source link

Rethinking the theme libray #2289

Closed aadcg closed 2 years ago

aadcg commented 2 years ago

I was playing around with themes today and I noticed that our default theme doesn't follow all of the recommendations related to contrast mentioned in libraries/theme/theme.lisp.

I put some thought to it and played a bit with a nice tool that computes the contrasts.

Today we're here: 2022-05-23_18:11:22

A suggestion: 2022-05-23_18:10:05

EDIT: Of course it'd look awful if we were to apply these colors right now, as it can be seen below. The point was to tweak the colors to meet the criteria of having overall better contrasts.

2022-05-23_20:52:08

2022-05-23_20:44:18

Reference: Colors with a minimum of 4.5:1 contrast ratio on both black and white.

Ambrevar commented 2 years ago

True your suggestion has better contrast, but I find the original theme more pleasing to the eye. Just a personal preference.

aartaka commented 2 years ago

Current color themes are both parts of Nyxt identity. While we certainly can change some tertiary or quaternary colors, the accend and primary colors are too important to shift them much. We've discussed it with @jmercouris when doing a theme library — Carribean Blue is a good an recogniseable accent color.

However, having proper color contrast is important, I acknowledge that. How about this: you design accessible theme(s) (you have good ideas on those, based on our nx-modus-themes chat) and we merge those in Nyxt, and list those together with the two default themes.

This way, we preserve Nyxt identity color scheme in a default theme, while still having an easy toggle for a more accessible variant.

aadcg commented 2 years ago

I agree, and I don't think we should change our color palette. Rather, I'm studying its properties.

primary-color: Should preferably contrast both with background-color and text-color. secondary-color: Should contrast with background-color. tertiary-color: Should contrast with text-color. quaternary-color: Should strongly contrast with text-color. accent-color: Should contrast with every other color in the theme.

The WCAG guidelines help us to quantify contrast. They define the following ratios as desirable:

Is it necessary to have one color, primary-color, that contrasts with both background-color and text-color? Let's see where it's being used (marginal use cases omitted):

  1. html elements (h1..6, anchors, table headers)
  2. the controls part of the status buffer (back, forward, reload, "hamburger")
  3. hint's background (with opacity)

Case 3 is the only one that might require good contrast between 3 colors.

Conclusions:

aadcg commented 2 years ago

I took some time to think about this. My idea was to port the modus themes, whose palette is in the public domain, and write an external extension. In the process, I reviewed the foundations of how we think about themes so that it's general enough for any use case.

Please see the final 3 conclusion above and tell me your opinions. @jmercouris @aartaka @Ambrevar @pdelfino

Ambrevar commented 2 years ago

For the box style, we have a binding to toggle the box opacity, so as long as we can toggle between high contrast and low opacity, we are good.

aartaka commented 2 years ago

The WCAG guidelines help us to quantify contrast. They define the following ratios as desirable:

  • 7:1 (better); easy to find colors that contrast with either background-color or text-color.
  • 4.5:1 (good); still possible to find colors that contrast with both background-color and text-color.

Is it necessary to have one color, primary-color, that contrasts with both background-color and text-color? Let's see where it's being used (marginal use cases omitted):

  1. html elements (h1..6, anchors, table headers)
  2. the controls part of the status buffer (back, forward, reload, "hamburger")
  3. hint's background (with opacity)

Case 3 is the only one that might require good contrast between 3 colors.

primary-color is the main color of interface elements. Given this purpose, it's preferable for it to have contrast with both text-color and background-color, because intrface elements tend to mix with both. Even if we don't have much cases where it happens, we should aim to preserve maximum possible contrast there.

  • [ ] accent-color can't have a 4.5:1 contrast ratio with every theme color. Edit its definition.

Yes! It is indeed confusing :D We should rather say that is should stand out, without specifying in which way!

  • [ ] primary-color should have good contrast with text-color or, optionally, with both text-color and background-color.

I'd say the other way around! Currently, we have a lot of interface elements (buttons, table headers, prompt selection) that have

:background-color theme:primary 
:color theme:background

to look integrated with both the backgroudn and the text. Because of that, contrast of primary-color with background-color is more important than with the text-color—it simply is a more widespread and sensible interface element palette!

  • [ ] I really think that the box-style of the hints should have full opacity, otherwise we have an awful contrast and it's not the best default.

I concur with what @Ambrevar said—it's just a matter of finding a good set of colors for hints!

aadcg commented 2 years ago

I'm going to reply but it's important to understand that I've now read the material design guidelines that @aartaka got inspiration from.

Regarding the box-style of the hints, are you saying that we should keep the opacity and choose another color?

primary-color is the main color of interface elements. Given this purpose, it's preferable for it to have contrast with both text-color and background-color, because intrface elements tend to mix with both. Even if we don't have much cases where it happens, we should aim to preserve maximum possible contrast there.

Not quite. primary-color is certainly not a neutral color, i.e. it must stand out, and it should communicate our branding (in our case it's the Caribbean blue). Regarding contrast, a foreground color must be choose when primary-color is in the background (the so-called on-primary concept in the material themes). In our case, that would be black. We're violating that principle today.

Yes! It is indeed confusing :D We should rather say that is should stand out, without specifying in which way!

We agree. Both primary and secondary colors should stand out.

I'd say the other way around! Currently, we have a lot of interface elements (buttons, table headers, prompt selection) that have

:background-color theme:primary :color theme:background

to look integrated with both the backgroudn and the text. Because of that, contrast of primary-color with background-color is more important than with the text-color—it simply is a more widespread and sensible interface element palette!

Again, I'm afraid we're doing it wrong. primary and secondary colors are meant to be used on big surfaces so we don't need to care much about the contrast between background and primary/secondary. If you put a light grey square inside a white square, you can discern it well. We need to take into account contrast ratios such as on-primary:primary or on-secondary:secondary, i.e. text or small elements that will be on the foreground.

aadcg commented 2 years ago

I don't think this is the right moment to make big decisions. My goal, in the long run, is to provide a better default theme without changing the grey/blue palette. It might not make much sense to work on #2188, while we don't have a good foundation on the theme library.

I think I have a clear idea of how it could be done, but it requires time and experimentation. There are more pressing things to work on now.

What we should address right now, if we reach consensus, is to be more precise on the concepts and properties of our theme library.

The proposal below might sound radical, but please think it through.

background and on-background must have a high contrast ratio.

primary is the one that stands out and conveys the "branding" . on-primary must have a high contrast ratio with its counterpart.

surface follows the same rationale as primary, and one can define as many as needed.

primary and all surfaces are used on surfaces, so there are no contrast requirements relative to background and on-background.

How does it map?

| now                | proposal        |
|--------------------+-----------------|
| `background-color` | `background`    |
| `text-color`       | `on-background` |
| `accent-color`     | `primary`       |
| none               | `on-primary`    |
| `primary-color`    | `surface1`      |
| none               | `on-surface1`   |
| `secondary-color`  | `surface2`      |
| none               | `on-surface2`   |
| `tertiary-color`   | `surface3`      |
| none               | `on-surface3`   |
| `quaternary-color` | `surface4`      |
| none               | `on-surface4`   |
aartaka commented 2 years ago

I've re-read the Material Design Guidelines (MDG), and I have to highlight one thing about them: they are about designing applications (single-purpose, one company, an identity that stands out), not platforms (OSes/DEs/shells/computing environemtns, general-purpose, provide a neutral basis for applications to stand out from).

Nyxt is a platform for both

Thus, Material Design guidelines are not to be taken literally there—platforms have a different set of design requirements than applications do. Notably, platforms need to be more neutral about the brand colors:

Given this set of requirements, I believe that my adjustments to Material Design are sensible enough:

Again, I've taken inspiration from MDG, yes. But MDG are still to be taken with a grain of salt, given the specificity of our use-cases. And deviating from the ~Bible~ MDG is okay here, if our case requires it. And it does.

aadcg commented 2 years ago

White smoke emerged from the Sistene chapel during the conversation I had with @aartaka.

We agreed on the following:

jmercouris commented 2 years ago

I must say your metaphor is hilarious André! Let's wait then. I think tweaking the theme will be a "lifelong" process anyways.

aadcg commented 2 years ago

Significant progress in this front was achieved. Thanks everyone, especially @aartaka.