hxf31891 / react-gradient-color-picker

An easy to use color/gradient picker for React.js
MIT License
126 stars 39 forks source link

Gradient with a missing last percent failing to parse #87

Open Ondoher opened 4 months ago

Ondoher commented 4 months ago

Fails to render with an error: "Missing )"

using version: "react-best-gradient-color-picker": "^3.0.5", color value: "linear-gradient(to right, rgba(128, 0, 128, 0) 5%, rgba(128, 0, 128, 0.2) 20%, rgba(128, 0, 128, 0.4) 73%, rgb(128, 0, 128, 0.2))"

in the getColor function, this string has been turned to: "linear-gradient(90deg, RGBA(128,0,128,0) 5%, rgba(128,0,128,0.2) 20%, rgba(128,0,128,0.4) 73%, rgba(128, 0, 128, 1) NaN%)"

From https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/linear-gradient

"By default, if there is no color with a 0% stop, the first color declared will be at that point. Similarly, the last color will continue to the 100% mark, or be at the 100% mark if no length has been declared on that last stop."

Also, could you let the thing render if the color value fails to parse. properly.