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

Change Text Color on "Aqua" background #8088

Closed
mmfreitas opened this issue Dec 16, 2021 · 5 comments
Closed

Change Text Color on "Aqua" background #8088

mmfreitas opened this issue Dec 16, 2021 · 5 comments
Assignees
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@mmfreitas
Copy link

NetBox version

v3.1.0

Feature type

Change to existing functionality

Proposed functionality

Change text color on aqua background.

From this:
imageimage

To this:
imageimage

Use case

To see the text on an "aqua" background more clearly.

Database changes

No response

External dependencies

No response

@mmfreitas mmfreitas added the type: feature Introduction of new functionality to the application label Dec 16, 2021
@jeremystretch
Copy link
Member

So here's an interesting bit of trivia: There's a utility function in NetBox called foreground_color() which is used to determine the color of text over a colored background automatically. We use the RBG code 00ffff for aqua, which resolves to white for its corresponding foreground color.

>>> from utilities.utils import foreground_color
>>> foreground_color('00ffff')
'ffffff'

I do agree that black text is more legible, but I don't recall where the formula it uses came from originally and I'm hesitant to tweak it. Might need to do a bit more research.

@jeremystretch jeremystretch added status: under review Further discussion is needed to determine this issue's scope and/or implementation type: bug A confirmed report of unexpected behavior in the application and removed type: feature Introduction of new functionality to the application labels Dec 16, 2021
@hSaria
Copy link
Contributor

hSaria commented Dec 16, 2021

The source of the function appears to be a stackoverflow answer. The RGB multipliers, I believe, come from NTSC's RGB to YIQ conversion formula, where Y, the luma, is for black/white. Not quite sure where the threshold of >186 for black originates from.

@hSaria
Copy link
Contributor

hSaria commented Dec 16, 2021

W3 has a page that uses a threshold of 150. On the same page is a slider you can play around with to see how well it works, it works significantly better with 150.

You can check out the source of the W3 page and look for isDark. The class w3color can be found here. It uses the same multipliers as RGB-to-YIQ, but with a 150 threshold on the W3 page.

@jeremystretch
Copy link
Member

Reducing the dark threshold to 150 tweaks the text color for several colors, namely fuchsia, agua, light green, orange, and grey. They do seem more readable with this configuration.

Screenshot_2021-12-16 Home NetBox(1)

@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation and removed status: under review Further discussion is needed to determine this issue's scope and/or implementation labels Dec 16, 2021
@jeremystretch jeremystretch self-assigned this Dec 16, 2021
@jeremystretch
Copy link
Member

Thanks for the pointers, @hSaria!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

3 participants