In 3.0.0 How to convert hex to hsl ? #113
arsonik posted onGitHub
Hi there we used to do that
ColorConvert.hex.hsl('#FF0000');
what's the new correct way since 3.0.0 ?
is it the only option ?
const rgb = ColorConvert.hex.rgb(color.value);
const hsl = ColorConvert.rgb.hsl(...rgb);
Shouldn't have changed? Are you getting an error?
> cc.hex.hsl('#FF0000')
[ 0, 100, 50 ]
Maybe the types are giving issue? Noticed that the @types/color-convert
package has not been bumped to reflect the v3 changes.
Having the same issue with 3.0.0
Ah, types are included in color-convert
V3 now. Try removing the @types/color-convert
dependency.
If that doesn't work then the types might need to be updated to reflect the automatic conversions. @LitoMore did you build the types from the conversions.js file or the output of the BFS builder?
EDIT: ah yeah the types only have the direct conversions, not the wrappers.
I'll probably need to make a build step to generate both the composite converters and the resulting types. I'll do this soon, sorry for breaking y'all.
As long as ESM isn't a breaker for you, the API shouldn't change in v3. The next version will probably be a patch bump, so you can pin to v2 for now and then 3.0.1 or 3.1.0 (not sure what kind of bump will be warranted) will fix this.
Upside is that bootup times will be a little faster.
Thanks for the update! We pinned @ 2.0.1 for now 👍
Ah, types are included in
color-convert
V3 now. Try removing the@types/color-convert
dependency.If that doesn't work then the types might need to be updated to reflect the automatic conversions. @LitoMore did you build the types from the conversions.js file or the output of the BFS builder?
EDIT: ah yeah the types only have the direct conversions, not the wrappers.
I'll probably need to make a build step to generate both the composite converters and the resulting types. I'll do this soon, sorry for breaking y'all.
As long as ESM isn't a breaker for you, the API shouldn't change in v3. The next version will probably be a patch bump, so you can pin to v2 for now and then 3.0.1 or 3.1.0 (not sure what kind of bump will be warranted) will fix this.
Upside is that bootup times will be a little faster.
yes definitely a typing issue, cause I saw the typings were provided now so I removed the @types package
I'll probably need to make a build step to generate both the composite converters and the resulting types. I'll do this soon
@Qix- Should I copy the existing @types/color-convert
definitions to our project for a quick fix? Or wait for your changes?
If they cover all of the calculated conversions then sure, that should be fine as a quick fix.
Thanks for the quick turnaround! 🙌 Could get an updated package published with this?
Released as 3.0.1
. Thanks again for bringing this up! Let me know if that doesn't solve the issue.