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

TablePanel/StatPanel: Fix values not being visible when background transparent #55092

Merged
merged 3 commits into from Sep 19, 2022

Conversation

mdvictor
Copy link
Contributor

@mdvictor mdvictor commented Sep 13, 2022

What this PR does / why we need it:
Fixes issue where alpha value of a color was not taken into consideration and caused Table cells and Stat panels to show text colored as the background rendereding it invisible. This happened when the background color was set to transparent and the text color was dark, which triggered the text color to be white. If the Grafana theme was also set to light then both the background and the text would be white and thus invisible.

Which issue(s) this PR fixes:

Fixes #39781

@mdvictor mdvictor requested a review from a team September 13, 2022 13:05
@mdvictor mdvictor requested review from a team as code owners September 13, 2022 13:05
@mdvictor mdvictor requested review from codeincarnate, supilee, joshhunt, ashharrison90, academo and oscarkilhed and removed request for a team September 13, 2022 13:05
@mdvictor mdvictor added this to the 9.1.6 milestone Sep 13, 2022
@mdvictor mdvictor self-assigned this Sep 13, 2022
@mdvictor mdvictor added add to changelog backport v9.1.x Bot will automatically open backport PR labels Sep 13, 2022
const a = tcolor.getAlpha();

if (a < 0.3) {
return themeIsDark ? 'rgb(247, 248, 250)' : 'rgb(32, 34, 38)';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the b > 180 basically the same thing as themeIsDark? I'm asking because this is a breaking change of the getTextColorForBackground function since the themeIsDark is required.

Copy link
Contributor Author

@mdvictor mdvictor Sep 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understand, the b component is strictly related to the background color hex code and does not take into account what the theme settings are. I understand that this is a breaking change. In this case I guess the cleanest solution is to create a new function that takes the transparency component into account and use that internally.

@grafanabot
Copy link
Contributor

@mdvictor mdvictor requested a review from mckn September 15, 2022 05:15
Copy link
Contributor

@mckn mckn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@grafanabot
Copy link
Contributor

@mdvictor mdvictor merged commit 32c4245 into main Sep 19, 2022
@mdvictor mdvictor deleted the table-color-text-not-visible branch September 19, 2022 08:47
grafanabot pushed a commit that referenced this pull request Sep 19, 2022
…ansparent (#55092)

* TablePanel/StatPanel: Fix values not being visible when background transparent

* Maintain backwards compatibility

(cherry picked from commit 32c4245)
mdvictor added a commit that referenced this pull request Sep 19, 2022
…ansparent (#55092) (#55362)

* TablePanel/StatPanel: Fix values not being visible when background transparent

* Maintain backwards compatibility

(cherry picked from commit 32c4245)

Co-authored-by: Victor Marin <36818606+mdvictor@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Light Theme - Issue with text color with Cell Display Mode set to Color Background
3 participants