xiaokaike/vue-color

Set color "programmatically"?

chesterlaykin opened this issue · 1 comments

Hello,

How can I load a color programmatically, for instance "#a8efa8" ?

My vue component looks like:
<sketch-picker v-on-clickaway="away" v-if="colorEditor" :value="bgColor.value" @input="$emit('input',$event)" />

It loads any existing saved value, which is an object of many color codes (hsl, hsv, hex etc).
But if there is no existing value, I would like to set a value just by loading a hex value ("#a8efa8") , but how can I do it?

It works if I create an object with all the values (hsl, hsv etc), and set it to my form property. But that's a lot of code for one color, so it would be more convenient if I can input a hex value and get the object in return somehow?

workaround: add a v-if="status === 'idle'" on the color picker. Then:
status = 'loading'
color = '#asdasd'
status = 'idle'

Color picler gets re-initialized and has the color set