PitPik/tinyColorPicker

Using color names for an input value results in #NANNANNAN

onet4 opened this issue · 1 comments

onet4 commented

The input value becomes #NANNANNAN even when the name is defined in the colorNames option under the following conditions,

  • the user directly types a color name such as cyan, red, transparent in the input.
  • a color name is set to the value attribute of the input element and the user clicks on the input to change the color.
<input class="color" value="cyan" />

Hi @onet4,
well, tinyColorPicker can only work with HEX, rgb(a) and hsl(a). There is no way around this.
What you can do is, use renderCallback to calculate the color name (from an array...) and display this value wherever you need to do so (also as value in a hidden input field).
See demos for how to be able to use renderCallback.

In the demo you saw, where colorNames is defined as option, colorNames is actually only an optional option, not really used by colorPicker but used in renderCallback. You could use colorNames in this example also as an "external" variable...

Good luck and cheers