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

rgbaRegex fails 3 digit decimals #610

Closed
levymetal opened this issue Apr 5, 2022 · 3 comments · Fixed by #611
Closed

rgbaRegex fails 3 digit decimals #610

levymetal opened this issue Apr 5, 2022 · 3 comments · Fixed by #611
Labels

Comments

@levymetal
Copy link
Contributor

levymetal commented Apr 5, 2022

Summary

polished version: 4.2.1

After #609, rgbaRegex no longer allows more than two decimal places for the alpha component. While this is an edge case, it's not totally unreasonable - in theory the minimum step should be 1/256. Also, because it now accepts a percentage, the maximum precision differs depending on the unit. Eg, we can pass 2.8% but not 0.028.

I'm happy to whip up a PR if this is considered a regression - just let me know.

Mixin/Helper/Shorthand Usage

readableColor('rgba(243,112,33,0.028)');

What You Are Seeing

Couldn't parse the color string. Please provide the color as a string in hex, rgb, rgba, hsl or hsla notation.

What You Expected To See

#000

Reproduction

n/a

@bhough
Copy link
Contributor

bhough commented Apr 5, 2022

@levymetal We would definitely accept a PR for this. Generally, we try to clean up long floats as it causes weird behaviors and inconsistent calculations in some browsers. However, I still consider this a regression and would want to accept broader inputs even though we clean it up on behalf of the user.

@jrmyio
Copy link

jrmyio commented Apr 6, 2022

@bhough this is definitely a pretty nasty bug:

Since version: 4.2.1:

// Throws no error
console.log(shade(0.05, 'rgba(247,213,175,0.56)'));

// Throws error since 4.2.1
console.log(mix(0.7, shade(0.05, 'rgba(247,213,175,0.56)'), '#3768fa'));

Codesandbox:
https://codesandbox.io/s/upbeat-bush-9ylp0k?file=/src/index.js:0-166

@bhough bhough added bug and removed unconfirmed bug labels Apr 6, 2022
bhough added a commit that referenced this issue Apr 6, 2022
Addresses an issue introduced in 4.2.1 that broke colors with values of various float lengths.

fix #610
@bhough bhough mentioned this issue Apr 6, 2022
@bhough bhough closed this as completed in 8d5ccfa Apr 6, 2022
@bhough
Copy link
Contributor

bhough commented Apr 6, 2022

This should be fully addressed in 4.2.2 Thank @levymetal!

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

Successfully merging a pull request may close this issue.

3 participants