-
Notifications
You must be signed in to change notification settings - Fork 122
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
refactor: simplify color manipulation code #1372
Merged
markov00
merged 60 commits into
elastic:master
from
markov00:2021_09_10-simplify_text_contrast
Sep 21, 2021
Merged
Changes from all commits
Commits
Show all changes
60 commits
Select commit
Hold shift + click to select a range
50cd467
use optional chaining
markov00 37022ad
remove unnecessary multiply by 1 operation
markov00 6da2bd5
simplify fillTextColor
markov00 b8007c9
move lightness check within fn
markov00 d8917a3
refactor getTextColorIfTextInvertible and fix bg color isOpaque check
markov00 ee4220c
use only numeric contrastRatio to improve readibility
markov00 484166a
dry code removing getOnPaperColorSet
markov00 f11dad1
replace isColorValid with a safer alternative
markov00 09e8d66
refactor fillTextColor
markov00 823534b
reduce complexity of fillTextColor
markov00 67dab73
reduce color functions: remove stringToRGB part 1
markov00 f73d912
remove stringToRGB part 2
markov00 bbbd4fb
removed unused fillColor on brush
markov00 ac30089
cleanup remaining RGBtoString
markov00 a25b276
replace addOpacity with a more robust implementation
markov00 8f61878
remove unused RGBtoString
markov00 cf640f8
remove unused hexto tohex
markov00 81b7432
remove argsTo toArgs and validateColor
markov00 8c3b038
remove d3-color dep
markov00 1a7d6ed
removed unused RgbObject
markov00 b4b0960
prepare fillTextColor to use RGBATuple in makeHighContrastColor
markov00 0cfe70a
dry hueInterpolator
markov00 758a303
combineColors with RgbaTuple only
markov00 a286c81
convert makeHighContrastColor to use RgbaTuple
markov00 9762e00
fillTextColor correctly use rgbatuples
markov00 d656c39
fix color calc test
markov00 5a2c81c
move chromajs related code into color_library_wrappers
markov00 710ca8d
move colorToRgba into wrappers
markov00 e728b51
fix wrongly applied opacity on points renderer
markov00 30c7af2
textInvertible on by default
markov00 b803d19
remove unused `seriesOpacity` argument from `OpacityFn`
markov00 55b4c2f
add LRU cache for colors
markov00 44dd420
remove `textOpacity` prop from configurations
markov00 8df655b
remove `textInvertible` prop. Maximize contrast by default
markov00 6504922
remove `textContrast` prop. Always use the default hardcoded value
markov00 da5b058
refactor fillTextColor to always maximise contrast
markov00 fe9ceeb
fix opacity for textures
markov00 9220821
replace makeHighContrastColor code with only black/white text output
markov00 5d52689
Merge branch 'master' into 2021_09_10-simplify_text_contrast
markov00 97d5c67
remove unused foreground color in `fillTextColor`
markov00 84b4884
`fillTextColor` accept only a background and containerBackground
markov00 950d4c0
fix tests
markov00 6be4bea
update API report with changes
markov00 3e7d6cc
update VRT baselines with color contrast changes
markov00 6311bcd
clear canvas with background color instead of clearRect
markov00 7d8cecd
update VRTs with latest changes on the background color
markov00 6764cf4
Merge branch 'master' into 2021_09_10-simplify_text_contrast
markov00 edcd469
fix color test with APCA contrast results
markov00 8c484a3
fix lint on apca code
markov00 2261239
cleanup mocks wrong/unused types
markov00 53c3ebd
fix ci to ignore canvas package
markov00 7927211
fix ci and types
markov00 6e25032
fix vrts without jsdom
markov00 70f1774
fix missing clearRect on clearCanvas
markov00 d932a01
Merge branch 'master' into 2021_09_10-simplify_text_contrast
markov00 878f650
revert to wcag2 color contrast
markov00 7ca2a0f
revert: use wcag2 color contrast
markov00 06917ee
add comment on clearCanvas
markov00 02711a0
fix unit color contrast unit test
markov00 229c8e8
fix color contrast test with wcag2 result
markov00 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
### | ||
source .ci/global_setup.sh | ||
|
||
|
||
VRTS_FILES=$1 | ||
### | ||
### visual testing | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+46 Bytes
(100%)
...l-stories-flame-alpha-cpu-profile-flame-chart-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-58 Bytes
(100%)
...tests-for-all-stories-flame-alpha-flame-chart-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-126 Bytes
(100%)
...ests-for-all-stories-flame-alpha-icicle-chart-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-64 Bytes
(100%)
...ll-stories-interactions-sunburst-slice-clicks-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+123 Bytes
(100%)
...r-all-stories-legend-piechart-repeated-labels-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-240 Bytes
(100%)
...-visual-tests-for-all-stories-legend-piechart-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+52 Bytes
(100%)
...sts-for-all-stories-mosaic-alpha-other-slices-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+119 Bytes
(100%)
...r-all-stories-small-multiples-alpha-sunbursts-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-104 Bytes
(100%)
...for-all-stories-stylings-partial-custom-theme-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-293 Bytes
(100%)
...for-all-stories-stylings-partition-background-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-196 Bytes
(100%)
...sts-for-all-stories-stylings-partition-labels-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-503 Bytes
(99%)
...ests-for-all-stories-sunburst-bold-link-value-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-313 Bytes
(99%)
...for-all-stories-sunburst-clockwise-no-special-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-185 Bytes
(100%)
...ll-stories-sunburst-counter-clockwise-special-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+153 Bytes
(100%)
...-tests-for-all-stories-sunburst-custom-stroke-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-385 Bytes
(100%)
...tests-for-all-stories-sunburst-custom-tooltip-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-211 Bytes
(100%)
...stories-sunburst-donut-chart-with-fill-labels-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-163 Bytes
(100%)
...-tests-for-all-stories-sunburst-heterogeneous-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-513 Bytes
(99%)
...ual-tests-for-all-stories-sunburst-most-basic-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-216 Bytes
(100%)
...isual-tests-for-all-stories-sunburst-negative-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-216 Bytes
(100%)
...l-tests-for-all-stories-sunburst-not-a-number-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-233 Bytes
(100%)
...ual-tests-for-all-stories-sunburst-percentage-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+148 Bytes
(100%)
...ests-for-all-stories-sunburst-single-sunburst-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-145 Bytes
(100%)
...l-stories-sunburst-sunburst-with-three-layers-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-385 Bytes
(100%)
...all-stories-sunburst-sunburst-with-two-layers-visually-looks-correct-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-180 Bytes
(100%)
...ests-for-all-stories-sunburst-value-formatted-visually-looks-correct-1-snap.png
Oops, something went wrong.
Binary file modified
BIN
-559 Bytes
(99%)
...sts-for-all-stories-sunburst-with-fill-labels-visually-looks-correct-1-snap.png
Oops, something went wrong.
Binary file modified
BIN
+1.33 KB
(100%)
...al-tests-for-all-stories-treemap-custom-style-visually-looks-correct-1-snap.png
Oops, something went wrong.
Binary file modified
BIN
+66 Bytes
(100%)
...ual-tests-for-all-stories-treemap-groove-text-visually-looks-correct-1-snap.png
Oops, something went wrong.
Binary file modified
BIN
+525 Bytes
(100%)
...-tests-for-all-stories-treemap-mid-two-layers-visually-looks-correct-1-snap.png
Oops, something went wrong.
Binary file modified
BIN
+1.9 KB
(100%)
...ual-tests-for-all-stories-treemap-multi-color-visually-looks-correct-1-snap.png
Oops, something went wrong.
Binary file modified
BIN
+1.17 KB
(100%)
...isual-tests-for-all-stories-treemap-one-layer-visually-looks-correct-1-snap.png
Oops, something went wrong.
Binary file modified
BIN
+501 Bytes
(100%)
...sual-tests-for-all-stories-treemap-percentage-visually-looks-correct-1-snap.png
Oops, something went wrong.
Binary file modified
BIN
+330 Bytes
(100%)
...ual-tests-for-all-stories-treemap-three-layer-visually-looks-correct-1-snap.png
Oops, something went wrong.
Binary file modified
BIN
-460 Bytes
(100%)
...or-all-stories-treemap-two-layers-stress-test-visually-looks-correct-1-snap.png
Oops, something went wrong.
Binary file modified
BIN
+2.06 KB
(100%)
...ual-tests-for-all-stories-treemap-zero-values-visually-looks-correct-1-snap.png
Oops, something went wrong.
Binary file modified
BIN
-6 Bytes
(100%)
...gative-log-areas-shows-only-positive-values-when-hiding-negative-one-1-snap.png
Oops, something went wrong.
Binary file modified
BIN
+54 Bytes
(100%)
...s__/dark-mode-test-ts-small-multiples-dark-mode-renders-panel-titles-1-snap.png
Oops, something went wrong.
Binary file modified
BIN
-23 Bytes
(100%)
...ies-test-ts-goal-stories-should-render-actual-tooltip-color-on-hover-1-snap.png
Oops, something went wrong.
Binary file modified
BIN
-48 Bytes
(100%)
...ts-goal-stories-theme-eui-dark-should-render-gauge-with-target-story-1-snap.png
Oops, something went wrong.
Binary file modified
BIN
+35 Bytes
(100%)
...s-goal-stories-theme-eui-light-should-render-gauge-with-target-story-1-snap.png
Oops, something went wrong.
Binary file modified
BIN
+23 Bytes
(100%)
...items-should-not-move-when-color-picker-series-is-hidden-or-unhidden-1-snap.png
Oops, something went wrong.
Binary file modified
BIN
-95 Bytes
(100%)
...ctions-test-ts-interactions-tooltips-should-show-tooltip-on-sunburst-1-snap.png
Oops, something went wrong.
Binary file modified
BIN
-250 Bytes
(100%)
...ies-extra-values-should-display-flat-legend-extra-values-on-sunburst-1-snap.png
Oops, something went wrong.
Binary file modified
BIN
+539 Bytes
(100%)
...ries-extra-values-should-display-flat-legend-extra-values-on-treemap-1-snap.png
Oops, something went wrong.
Binary file modified
BIN
-159 Bytes
(100%)
...s-extra-values-should-display-nested-legend-extra-values-on-sunburst-1-snap.png
Oops, something went wrong.
Binary file modified
BIN
+507 Bytes
(100%)
...es-extra-values-should-display-nested-legend-extra-values-on-treemap-1-snap.png
Oops, something went wrong.
Binary file modified
BIN
-133 Bytes
(100%)
...egend-stories-should-correctly-render-multiline-nested-legend-labels-1-snap.png
Oops, something went wrong.
Binary file modified
BIN
+142 Bytes
(100%)
...ame-order-as-nested-with-no-indent-even-if-there-are-repeated-labels-1-snap.png
Oops, something went wrong.
Binary file modified
BIN
-1 Byte
(100%)
...es-test-ts-legend-stories-should-render-legend-action-on-mouse-hover-1-snap.png
Oops, something went wrong.
Binary file modified
BIN
+55 Bytes
(100%)
...styles-test-ts-styles-should-hide-the-value-label-with-0-text-border-1-snap.png
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm actually created this as a very specific one just to move chromajs function into a single file. I can create have a more complex/functional fn when actually required