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

fix: enable floating point value display #209

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

C17AN
Copy link

@C17AN C17AN commented Jul 30, 2024

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 of dynamic-contrast.js, I modified the rgbExp to accept decimal values. Additionally, I changed the calculation to use parseFloat instead of parseInt to handle these values correctly.

Screenshot

AS-IS

image

TO-BE

image

Note

AS-IS (tested with included test/fixture/test.css)
image

TO-BE (tested with included test/fixture/test.css)
image

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant