Qix-/color-convert

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);
posted by arsonik 2 months ago

Shouldn't have changed? Are you getting an error?

> cc.hex.hsl('#FF0000')
[ 0, 100, 50 ]
posted by Qix- 2 months ago

Maybe the types are giving issue? Noticed that the @types/color-convert package has not been bumped to reflect the v3 changes.

posted by tvthatsme 2 months ago

Having the same issue with 3.0.0 Image

posted by PS1TD 2 months ago

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.

posted by Qix- about 2 months ago

Thanks for the update! We pinned @ 2.0.1 for now 👍

posted by tvthatsme about 2 months ago

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

posted by arsonik about 2 months ago

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?

posted by LitoMore about 2 months ago

If they cover all of the calculated conversions then sure, that should be fine as a quick fix.

posted by Qix- about 2 months ago

Thanks for the quick turnaround! 🙌 Could get an updated package published with this?

posted by tvthatsme about 2 months ago

Released as 3.0.1. Thanks again for bringing this up! Let me know if that doesn't solve the issue.

posted by Qix- about 2 months ago

Fund this Issue

$0.00
Funded

Pull requests