Skip to content

Export functions to convert to different color value #100

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

Open
MelanieW97 opened this issue Jan 8, 2024 · 2 comments
Open

Export functions to convert to different color value #100

MelanieW97 opened this issue Jan 8, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@MelanieW97
Copy link

Hello,

would it be possible to expose the functions you use for converting the color values to a different type, e.g. rgba to hex.
I need to let the user choose a color value he wants but save a specific value. Therefore, it'd be great if I could handle it the same way as you so in order to prevent bugs on two sides.

Thanks in advance. :)

@MelanieW97
Copy link
Author

Hey there,

I found the class "ConverterService". That's exaclty what I need. However, it is not part of the public API. Unfortunately, I cannot use it.

Error: Module not found: Error: Package path ./lib/services/converter.service is not exported from package /xyz/node_modules/ngx-colors (see exports field in /xyz/node_modules/ngx-colors/package.json)

It'd be so great to use this ConverterService.

@KroneCorylus KroneCorylus added the enhancement New feature or request label Jan 31, 2024
@MelanieW97
Copy link
Author

MelanieW97 commented Feb 17, 2025

Hello again,

I've just noticed that the CMYK option does not seem to be working in the converter service.
As I said, I use the same function as you do since I don't want a different behavior but it's not working for CMYK values.

stringToFormat always returns an empty string for cmyk values.

Image

Image

Therefore, my input field is empty since I transform the value to HEX with stringToFormat.

Edit: Never mind! It's all good. However, you seem to have added CMYK after an update and I have not noticed. Therefore, my local converter service did not include the logic for that. Consider this little problem as a push for exporting the functions. :)
In that case, I could simply use them instead of having to duplicate them in my own code.

Exporting the ColorFormats enum would be nice, too.
In that case, I can even go like this and be safe that the enum does not change:

this.converterService.stringToFormat(color, ColorFormats.HEX);

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

No branches or pull requests

2 participants