chore: Refactor visual accent colors to use tokens - #4745
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4745 +/- ##
=======================================
Coverage 97.62% 97.62%
=======================================
Files 956 956
Lines 31004 31004
Branches 11410 11409 -1
=======================================
Hits 30269 30269
- Misses 688 728 +40
+ Partials 47 7 -40 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| colorBackgroundBadgeBlue: { light: '{colorInfo100}', dark: 'rgba(92, 127, 255, 0.2)' }, | ||
| colorBackgroundBadgeRed: { light: '{colorError100}', dark: 'rgba(255, 61, 61, 0.2)' }, | ||
| colorBackgroundBadgeYellow: { light: '{colorWarning100}', dark: 'rgba(251, 211, 50, 0.2)' }, | ||
| colorBackgroundBadgeGreen: { light: '{colorSuccess100}', dark: hexToRgba(paletteTokens.colorGreen500!, 0.2) }, |
There was a problem hiding this comment.
Why do we need to convert hex to rgba? We already have some tokens defined in hex, so why should these be different?
There was a problem hiding this comment.
In the visual-accent feature, we are introducing a quite a bit of semi-transparent colors that are all associated with primitive color palette like colorGreen500 with different opacity values. If we keep maintaining these only with the rgba it's error prone and hard to maintain. In think in the long term, other rgba values can also use the hexToRgba function for better maintainability.
There was a problem hiding this comment.
it's error prone and hard to maintain
why?
There was a problem hiding this comment.
We design those styles using primitive color palette like colorGreen* while applying opacities. As soon as we convert them to rgba values, it becomes hard to understand which primitive color is associated with.
Here is an example:
- In design, we define styles like
colorIndigo500with 20% opacity - If we convert it to
rgbait'srgba(35, 42, 68, 0.2)- It's almost impossible to remember that is Indigo500
Maintaining such rgba values for many styles in the code base is not good idea in general.
There was a problem hiding this comment.
It's almost impossible to remember that is Indigo500
I didn't get it
Maintaining such rgba values for many styles in the code base is not good idea in general.
But that’s exactly what you’ve done in this function - you’ve converted hex values to rgba.
There was a problem hiding this comment.
In other words, rgba is a hard coded value which we should not have, in the same reason why we should not style using hex code. The function is a layer that that converts primitive values to raw values.
b3214e8 to
ac49215
Compare
Description
This PR refactors the visual accent styling for the Box and Badge components.
Changes
Related links, issue #, if available: n/a
How has this been tested?
Review checklist
The following items are to be evaluated by the author(s) and the reviewer(s).
Correctness
CONTRIBUTING.md.CONTRIBUTING.md.Security
checkSafeUrlfunction.Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.