Open obi-sammy opened 2 days ago
I would like to be assigned to this issue after it has been reviewed, Thank you.
Thanks for finding this @obi-sammy Before we get into developing it, how would you suggest this to be solved?
Good day @utk09-NCL,
After researching the issue, I would suggest setting the button’s text color to either black or white based on the brightness of the button’s background color. To achieve this, we can calculate the brightness of the button's background color, and I found the package tinycolor2, which offers a simple method isLight()
to determine whether a color is light or dark. This can help us adjust the text color dynamically.
If you need any further clarifications on this approach, I’d be happy to explain in more detail or explore any other ideas. I’m excited to collaborate further on this!
Thanks for considering my suggestion!
We are already using chroma-js
, so probably just use that. Maybe you can check the luminance of the button background colour and then decide the text colour based on that?
@utk09-NCL. Since we're already using chroma.js
, we can leverage the luminance()
method, which calculates the brightness of a color. I suggest we use this to determine the brightness of the button's background color, and based on the result, set the text color to either black or white to ensure readability.
I'd be happy to be assigned to this issue and start implementing the solution. If you need any further clarifications, feel free to reach out, and I'd be glad to explain or discuss the approach further.
Assigning this to you @obi-sammy
Describe the Bug
When a user selects a lighter color, particularly white (#FFF), the background of the 'Generate Color' button becomes white while the text becomes invisible because it is set to white by default. This affects visibility and usability for any lighter color selections.
Steps to Reproduce
Steps to reproduce the behavior:
Expected Behavior
When the button background color is a light color (e.g., white or any other light hex color), the text color should automatically change to a darker color (e.g., black) to maintain contrast and readability. This ensures users can always see the text, regardless of the background color.
Screenshots
Environment
Additional Context
This issue also applies to any lighter background colors that cause poor contrast with the white text. The text color should dynamically adjust based on the brightness of the selected background color to ensure visibility.