Closed dgattoni closed 3 years ago
@dgattoni This is working as intended, albeit with slightly confusing parameter names. lightReturnColor
is the color you want to be returned for light backgrounds and vice versa for dark. We can update to be more explicit (lightComparisonReturnColor
possibly). The way to reason about it is we can't guarantee you are actually passing a light color so we are naming it after the comparison color vs the color you are passing. You are seeing white correctly because of strict mode kicking it when you place pink on a light background in your example.
Docs and signature updated in v4.0.5.
Awesome! Thank you @bhough for the update! 🙌
polished
version: 4.0.4JSS-in_CSS
library and version: styled-components 5.2.1Mixin/Helper/Shorthand Usage
What You Are Seeing
The Problem
on
readableColor
unit tests, theit
block on line 13"should return custom light background when passed dark color"
is being tested passing a dark colour as the 2nd argument and light color as the 3rd argument, however, the function input signature expects a light colour as the 2nd param and dark colour as the 3rd parameter.What You Expected To See
As specified on the documentation:
So, following the current function input signature, if I pass the following values:
I expect the returning value to be my optional light color "pink", as it has no contrast issues with "purple", (the "given color") but instead, I got "white" as the
defaultLightReturnColor
.Reproduction
I have created a CodeSandbox example to reproduce the issue