You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When setting navigationBackgroundColor to #4e9a06, the text displays with low contrast. The contrast ratio falls below the AA rating, triggering a warning in Chrome DevTools.
The isLuminant function should use this L_middle as a threshold instead of 0.5.
In this case, the luminance of the background color (#4e9a06) is 0.44864313725490196, which is ≥ L_middle. This causes isLuminant to return true, resulting in the use of the darker foreground color and, consequently, higher contrast.
Please note that I'm not an expert in color theory or accessibility standards, so my understanding and calculations might be incorrect. I welcome any corrections or additional insights from those more knowledgeable in this area.
The text was updated successfully, but these errors were encountered:
Thank you for your insightful feedback on our color contrast logic, @KojiAndoJC san!
I agree that improvements are needed. I plan to align our implementation with the CSS Color Module Level 6 specification, specifically the contrast-color() function.
However, as browser support is currently limited, we'll implement a similar logic within our repository. This approach will allow us to enhance our color contrast immediately while preparing for future adoption of the official CSS specification. Your contribution is greatly appreciated!
Thank you for your response, @xhiroga. I agree that the contrast-color() solution is smart!
While you're considering implementing similar logic, I realized there's one more point I'd like to add. Even though the logic I suggested would result in higher contrast, some users might prefer the current foreground color. To accommodate these users, it might be helpful to implement a foregroundColor configuration option. This way, users could choose between the automatic high-contrast selection and their preferred color, offering more flexibility.
As I'm not fully familiar with the entire codebase or all use cases, I think it's best to wait for your implementation. However, I'm happy to provide any additional feedback or clarification if needed.
What is the problem?
When setting
navigationBackgroundColor
to#4e9a06
, the text displays with low contrast. The contrast ratio falls below the AA rating, triggering a warning in Chrome DevTools.Reproduction Steps
Set the configuration JSON as follows:
Sign in Method
Browser Name
Chrome
Browser Version
129.0.6668.59 (Official Build) (64-bit)
Other information
The current logic for determining foreground color is as follows:
Causes of the low contrast issue:
The lighter color (
#d5dbdb
) is darker than the default white (#ffffff
), resulting in lower contrast.The threshold for determining darker foreground color usage is not optimized.
Contrast calculation:
The contrast ratio is calculated using the following equation (source: https://web.dev/learn/accessibility/color-contrast):
To find the optimal threshold, we can calculate the middle point (L_middle) by solving:
Using the current
getLuminance
function:The
isLuminant
function should use this L_middle as a threshold instead of 0.5.In this case, the luminance of the background color (#4e9a06) is 0.44864313725490196, which is ≥ L_middle. This causes
isLuminant
to return true, resulting in the use of the darker foreground color and, consequently, higher contrast.For more precise contrast calculations, the luminance should be calculated using a different formula, as described in this article: https://css-tricks.com/understanding-web-accessibility-color-contrast-guidelines-and-ratios/
Please note that I'm not an expert in color theory or accessibility standards, so my understanding and calculations might be incorrect. I welcome any corrections or additional insights from those more knowledgeable in this area.
The text was updated successfully, but these errors were encountered: