Sphinxxxx/vanilla-picker

Disabling alpha in options does not remove it from the color string

Closed this issue · 1 comments

I need to remove alpha as an option for end users but would then expect the returned hex value to not include an alpha. My specific use case requires me to then send this data to a 3rd party API, which only validates 6 digit hex. This means I will now need to edit the hex value before I send it off.

It would make more sense to me that when alpha is set to false in the color picker it would return non-alpha colors (rgb instead of rgba, 6-digit hex instead of 8, etc.)

In your onDone/onChange callback, you can use the printHex() method on the color object, which takes an "include alpha" parameter:

picker.onChange = function(color) {
    var hex6 = color.printHex(false);
    ...
};