fix: enable floating point value display #209
Open
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.
Description
Fixes an issue where the
getColorContrast()
function did not work correctly when the rgba values included decimal points.Problem
Including decimal points in rgba values is not correct syntax, but I have experienced situations where both the text and background turn completely black, making it difficult to verify the input values.
For example, if you incorrectly input something like
rgba(0,0,0.1)
, both the text and background turn black, rendering the values unreadable. (Attached at screenshot)Solution
In the
getColorContrast()
function ofdynamic-contrast.js
, I modified thergbExp
to accept decimal values. Additionally, I changed the calculation to useparseFloat
instead ofparseInt
to handle these values correctly.Screenshot
AS-IS
TO-BE
Note
AS-IS (tested with included
test/fixture/test.css
)TO-BE (tested with included
test/fixture/test.css
)I have tested this change with your
test/fixture/test.css
, but If you believe this PR might cause a breaking change, it's perfectly fine not to merge it and to fix the issue in your own way.Thank you for creating such a great extension.