fix: color picker now updates fields

Signed-off-by: Corentin Thomasset <corentin.thomasset74@gmail.com>
This commit is contained in:
Corentin Thomasset 2020-06-08 11:58:09 +02:00
parent 48376c17b2
commit efe62bb3cf
2 changed files with 10 additions and 1 deletions

View file

@ -11,6 +11,7 @@
hide-inputs
mode="rgba"
v-model="rgbPicker"
@input="(v) => updateColors(v, 'picker')"
/>
</v-col>
<v-col cols="12" sm="6" align="center">
@ -116,7 +117,7 @@
this.keyword = convert.rgb.keyword(r, g, b);
},
updateColors(value, fromType) {
if (this.$refs[fromType].validate()) {
if (fromType === 'picker' || this.$refs[fromType].validate()) {
if (fromType === 'rgb') {
const [r, g, b] = value.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/).slice(1).map(v => parseInt(v));
this.rgbPicker = {r, g, b}
@ -150,6 +151,13 @@
} catch (ignored) {
// ignored
}
} else if (fromType === 'picker') {
const {r, g, b} = value;
this.setRGB(r, g, b);
this.setHEX(r, g, b);
this.setHSL(r, g, b);
this.setKeyword(r, g, b);
}
}
}