Replies: 12 comments
-
CC @JayPanoz (ReadiumCSS wizard / maintainer) and @llemeurfr (EDRLab, Thorium "product owner", ultimately the arbiter of all design decisions / developement priorities) and @HadrienGardeur (also involved in the annotations / colours debate) Thank you for your suggestion. I think we all absolutely agree on principle that ideally the contrast levels should be consistently high regardless of colour themes (publisher styles and reading app / user overrides), but we made pragmatic implementation choices. For example the current colour palette was created from a limited set of named colours. Actual hues can vary slightly across RS / Reading Systems, but the symbolic names are to be standardized for interoperability purposes. This is to be proposed as a basis for a revision/update of the W3C annotations specification. Plus, the availability of colour themes vary from one RS to another. For example Thorium doesn't support Windows-native system-level high-contrast themes yet, but this could be a new variable to adjust for when offering colours for highlights. Note that highlights are used for annotations, search results, TTS (and to some extent EPUB3 Media Overlays synchronised text-audio too). So, this is to be discussed further. I am moving this to a GitHub discussion. |
Beta Was this translation helpful? Give feedback.
-
Also see: #2817 |
Beta Was this translation helpful? Give feedback.
-
@lindheli do you have a screenshot of a colour palette that would work for you? (maybe from other reading systems) |
Beta Was this translation helpful? Give feedback.
-
There are two levels of discussion here.
I like this solution because it does not add any complexity to the user interface, and the UX adapts itself to the context of use of the app. |
Beta Was this translation helpful? Give feedback.
-
I noticed that this issue was "locked" by GitHub earlier on, when I attempted to convert this to a "discussion" (GitHub crashed several times in a row, so I gave up in the end ;) |
Beta Was this translation helpful? Give feedback.
-
Thank you Linda for sending this in: "Here is a list of the colors to choose between in EasyReader, which is one of the current readers we recommend for our users, just for reference. This is not necessarily the best list of colors, just what our users are used to." |
Beta Was this translation helpful? Give feedback.
-
As a side note, and I guess we will discuss that during the next engineering call, I‘ve started to give this a look in Playground + ts-toolkit, specifically the high-contrast issue, and there are some interesting problems to solve, or at least multiple strategies to implement with caveats. Note CSS now has a |
Beta Was this translation helpful? Give feedback.
-
On this topic: In Thorium's highlighting engine I attempted to use fancy CSS, but Chromium broke things in very interesting ways (Electron updates, as well as mainstream evergreen Chrome), so I opted for a much simpler contrast ratio calculation: @supports (color: oklch(from red l c h)) {
background-color: rgb(R, G, B);
color: oklch(from rgb(R, G, B)) clamp(0, (0.7 / l - 1) * infinity, 1) c h);
} @supports (color: oklch(from color-mix(in oklch, red, tan) l c h)) {
background-color: rgb(R, G, B);
color: color(from rgb(R, G, B) xyz-d65 clamp(0, (0.36 / y - 1) * infinity, 1) clamp(0, (0.36 / y - 1) * infinity, 1) clamp(0, (0.36 / y - 1) * infinity, 1));
}
} @supports (color: contrast-color(red)) {
background-color: rgb(R, G, B);
color: contrast-color(rgb(R, G, B));
}
} ===> const calcRGB = (rgb: number) => {
return (rgb <= 0.03928) ? rgb / 12.92 : ((rgb + 0.055) / 1.055) ** 2.4;
};
const computeHighContrastForegroundColourForBackground = (r: number, g: number, b: number) => {
let foregroundColour = "#ffffff";
const red = calcRGB(r);
const green = calcRGB(g);
const blue = calcRGB(b);
// sRGB Luma (ITU Rec. 709) https://en.wikipedia.org/wiki/Rec._709
const luminance = 0.2126 * red + 0.7152 * green + 0.0722 * blue;
const pickBlack = (luminance + 0.05) / 0.05;
const pickWhite = 1.05 / (luminance + 0.05);
if (pickBlack > pickWhite) {
foregroundColour = "#000000";
}
return foregroundColour;
}; |
Beta Was this translation helpful? Give feedback.
-
Regarding the Chromium breakage, see screenshots: ...see issue tracker: https://issues.chromium.org/issues/371224775 ...initially reported at Lea Verou's website: |
Beta Was this translation helpful? Give feedback.
-
I'm always a little wary of meeting user needs strictly through system level settings. They're good for defaults and "auto" values, but it's best to allow the user to set things up in the app as well. FYI, this is consistent with both Thorium's approach for language and app theme. IMO highlight colors should be theme-specific and at least for high-contrast themes, we should target a higher contrast ratio. With our recommended approach for standardizing annotation colors, we're not using these strings ( We've also been discussing with @JayPanoz how we could automatically calculate high contrast colors to allow developers and users who set their own themes to always get good contrast on both text and highlights. |
Beta Was this translation helpful? Give feedback.
-
Issue in Playground with some references. I'd be happy this is moved to another place if it makes sense so that it can be easier to find for all maintainers and contributors across projects – in that case please feel free to edit the original post to better introduce the issue we are trying to solve. |
Beta Was this translation helpful? Give feedback.
-
GitHub had a known bug (now fixed) when I tried to convert this to a discussion. I am trying again... |
Beta Was this translation helpful? Give feedback.
-
Under Annotation, the colors to choose between are all very soft. Would it be possible to add bright/strong colors for higher contrast as well? We also suggest adding black.
Beta Was this translation helpful? Give feedback.
All reactions