You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Also ran some common sense checks against a known source of truth (the DOM) to double check the accuracy; Didn't run many of these but just a few just to make sure it wasn't unnecessarily lossy.
// Native DOM
const ele = document.createElement("div")
ele.style.color = "hsl(158, 83%, 46%)"
console.log(ele.style.color) // rgb(20,215,143) (converted by DOM automatically)
// New HSL -> RGB javascript algorithm
hslToRgb(158, 0.83, 0.46)/
// [20, 215, 143]
Uh oh!
There was an error while loading. Please reload this page.
🐛 Bug Report
The function that converts hslToRgb in this library looks like it originates from this stackoverflow answer:
https://stackoverflow.com/questions/2353211/hsl-to-rgb-color-conversion
However, This answer is wrong this method of converting hsl to rgb is fundamentally flawed the correct way is documented here
https://www.rapidtables.com/convert/color/hsl-to-rgb.html
in which a code-translation version of the math turns into the refined more accurate version:
To Reproduce
No steps needed to reproduce other than check the inputs/outputs of that function against any reputable online color converter.
Expected behavior
Expected behavior is that it swaps between hsl / rgb in an extremely "non-lossy" way
Link to repro
Source of problem is here.
https://github.com/react-spring/react-spring/blob/e73385837e7a75ef64e82d17a28e7c86fb5c0e49/src/shared/normalizeColors.ts
Environment
react-spring any version.
EDIT: Quick edit to say if this could be fixed on react-spring 8 aswell as 9 that would be amazing
The text was updated successfully, but these errors were encountered: