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

feat(ConditionalFormatting): allow inverse color scaling and add color picker #20353

Closed

Conversation

stevetracvc
Copy link
Contributor

@stevetracvc stevetracvc commented Jun 11, 2022

SUMMARY

Currently, for the conditional color scaling, alpha is directly proportional to the value. This PR adds a checkbox to the Conditional Formatting modal that allows the designer to invert this scale, ie, as the value increases, the alpha decreases

Additionally, this fixes an issue I noticed with #20016 that broke the conditional formatting feature (need to convert hex string to 'rgb(R,G,B)' string).

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Broken color formatting:
broken

Regular conditional formatting:
regular

Inverted for Rank
inverted

TESTING INSTRUCTIONS

  • Create a table with numeric values
  • Add a conditional formatting under the Customize tab
  • Toggle the checkbox to see the effect

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@stevetracvc
Copy link
Contributor Author

The hexToRGBString function might be useful elsewhere, so please let me know if there's a good place to move it.

@codecov
Copy link

codecov bot commented Jun 11, 2022

Codecov Report

Merging #20353 (ca1296a) into master (ab9f72f) will increase coverage by 0.00%.
The diff coverage is 77.27%.

@@           Coverage Diff           @@
##           master   #20353   +/-   ##
=======================================
  Coverage   66.71%   66.71%           
=======================================
  Files        1739     1739           
  Lines       65149    65190   +41     
  Branches     6899     6919   +20     
=======================================
+ Hits        43462    43493   +31     
- Misses      19934    19939    +5     
- Partials     1753     1758    +5     
Flag Coverage Δ
javascript 51.79% <77.27%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...d/packages/superset-ui-chart-controls/src/types.ts 100.00% <ø> (ø)
...explore/components/controls/ColorPickerControl.jsx 88.23% <ø> (ø)
...onalFormattingControl/FormattingPopoverContent.tsx 46.34% <0.00%> (-5.01%) ⬇️
...nts/controls/ConditionalFormattingControl/types.ts 100.00% <ø> (ø)
superset-frontend/src/utils/colorUtils.ts 40.90% <66.66%> (+4.06%) ⬆️
...-ui-chart-controls/src/utils/getColorFormatters.ts 98.78% <85.71%> (-1.22%) ⬇️
...ntend/packages/superset-ui-core/src/color/utils.ts 94.02% <86.66%> (-5.98%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ab9f72f...ca1296a. Read the comment docs.

Copy link
Member

@michael-s-molina michael-s-molina left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @stevetracvc and for adding tests! I left some comments.

@kgabryje
Copy link
Member

Love the change with color picker!
A few comments:

  1. Maybe it would look better if we left the checkbox without any validation errors? If we changed copy in the tooltip to sth like "Ignored when '=' operator is selected", maybe that would be sufficient and we could simply ignore the state of the checkbox?
  2. Is it possible to make the color picker popover a bit wider, so that the input fields for rgb values are wide enough to hold 3 digits? See video
Screen.Recording.2022-06-14.at.15.44.03.mov

@stevetracvc
Copy link
Contributor Author

Love the change with color picker! A few comments:

  1. Maybe it would look better if we left the checkbox without any validation errors? If we changed copy in the tooltip to sth like "Ignored when '=' operator is selected", maybe that would be sufficient and we could simply ignore the state of the checkbox?

I'll defer to you.

  1. Is it possible to make the color picker popover a bit wider, so that the input fields for rgb values are wide enough to hold 3 digits? See video

I added an extra prop to make it easier to set the color picker width. Here's 300 and 250 (default is 200), I think 250 is probably good.
color-picker-300
color-picker-250

@@ -26,10 +26,12 @@ import ControlHeader from '../ControlHeader';
const propTypes = {
onChange: PropTypes.func,
value: PropTypes.object,
sketchPickerWidth: PropTypes.number,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure if you'd rather just hard code in a bigger width, rather than having it as a prop

there are a lot of issues associated with moving away from color strings
like `rgb(255, 255, 255)` in favor of `#FFFFFF` (and similar with alpha values).
This fixes a lot of the issues presented, and also provides some extra functions
to help with the transition. Unfortunately there are still too many other components
that are using these rgb strings to convert the color picker right now.
@stevetracvc
Copy link
Contributor Author

switching from colors stored as 'rgb(r, g, b)' to hex strings is going to affect a lot of different parts of the code

@stevetracvc stevetracvc changed the title feat(ConditionalFormatting): allow inverse color scaling feat(ConditionalFormatting): allow inverse color scaling and add color picker Aug 10, 2022
@rusackas
Copy link
Member

rusackas commented Feb 2, 2024

Hey @stevetracvc @kgabryje @michael-s-molina - it looks like this effort fell by the wayside somehow. Is there any interest in rekindling/rebasing this effort to get it across the finish line?

@stevetracvc
Copy link
Contributor Author

@rusackas I'd love to, not sure how much work it'll be. I'm still running v2.0.x something, and I haven't had a chance to play with any of the newer updates. I don't think I'll be able to look at it till March though. I'll have to see what you all did with the colors themselves, since I know there was a weird transition period between rgb objects and hex strings.

@rusackas
Copy link
Member

rusackas commented Feb 7, 2024

Cool... I'll just set this to Draft mode for now then, and hit us up here or on Slack if you want to catch up on things when the time comes.

@rusackas rusackas marked this pull request as draft February 7, 2024 16:04
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 77.27273% with 10 lines in your changes are missing coverage. Please review.

Project coverage is 66.71%. Comparing base (ab9f72f) to head (ca1296a).
Report is 3248 commits behind head on master.

Files Patch % Lines
...ntend/packages/superset-ui-core/src/color/utils.ts 86.66% 1 Missing and 3 partials ⚠️
...onalFormattingControl/FormattingPopoverContent.tsx 0.00% 4 Missing ⚠️
...-ui-chart-controls/src/utils/getColorFormatters.ts 85.71% 0 Missing and 1 partial ⚠️
superset-frontend/src/utils/colorUtils.ts 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master   #20353   +/-   ##
=======================================
  Coverage   66.71%   66.71%           
=======================================
  Files        1739     1739           
  Lines       65149    65190   +41     
  Branches     6899     6919   +20     
=======================================
+ Hits        43462    43493   +31     
- Misses      19934    19939    +5     
- Partials     1753     1758    +5     
Flag Coverage Δ
javascript 51.79% <77.27%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rusackas
Copy link
Member

rusackas commented Jun 6, 2024

@stevetracvc Since this still seems to be accumulating conflicts and whatnot, I'll go ahead and close it. Please feel free to reopen it if you ever want to rekindle this effort. Thanks!

@rusackas rusackas closed this Jun 6, 2024
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.

None yet

6 participants