Cleanup code & make sure it has a common code style
This commit is contained in:
parent
4a8b15e7be
commit
a8a7f70a3c
132 changed files with 6821 additions and 6595 deletions
|
|
@ -1,12 +1,12 @@
|
|||
<template>
|
||||
<div class="color-picker-container">
|
||||
<verte
|
||||
v-model="color"
|
||||
:menuPosition="menuPosition"
|
||||
picker="square"
|
||||
model="hex"
|
||||
:enableAlpha="false"
|
||||
:rgbSliders="true"/>
|
||||
:enableAlpha="false"
|
||||
:menuPosition="menuPosition"
|
||||
:rgbSliders="true"
|
||||
model="hex"
|
||||
picker="square"
|
||||
v-model="color"/>
|
||||
<a @click="reset" class="reset">
|
||||
Reset Color
|
||||
</a>
|
||||
|
|
@ -14,58 +14,58 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import verte from 'verte'
|
||||
import 'verte/dist/verte.css'
|
||||
import verte from 'verte'
|
||||
import 'verte/dist/verte.css'
|
||||
|
||||
export default {
|
||||
name: 'colorPicker',
|
||||
data() {
|
||||
return {
|
||||
color: '',
|
||||
lastChangeTimeout: null,
|
||||
export default {
|
||||
name: 'colorPicker',
|
||||
data() {
|
||||
return {
|
||||
color: '',
|
||||
lastChangeTimeout: null,
|
||||
}
|
||||
},
|
||||
components: {
|
||||
verte,
|
||||
},
|
||||
props: {
|
||||
value: {
|
||||
required: true,
|
||||
},
|
||||
menuPosition: {
|
||||
type: String,
|
||||
default: 'top',
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
value(newVal) {
|
||||
this.color = newVal
|
||||
},
|
||||
color() {
|
||||
this.update()
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.color = this.value
|
||||
},
|
||||
methods: {
|
||||
update() {
|
||||
|
||||
if (this.lastChangeTimeout !== null) {
|
||||
clearTimeout(this.lastChangeTimeout)
|
||||
}
|
||||
},
|
||||
components: {
|
||||
verte,
|
||||
},
|
||||
props: {
|
||||
value: {
|
||||
required: true,
|
||||
},
|
||||
menuPosition: {
|
||||
type: String,
|
||||
default: 'top',
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
value(newVal) {
|
||||
this.color = newVal
|
||||
},
|
||||
color() {
|
||||
this.update()
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.color = this.value
|
||||
},
|
||||
methods: {
|
||||
update() {
|
||||
|
||||
if(this.lastChangeTimeout !== null) {
|
||||
clearTimeout(this.lastChangeTimeout)
|
||||
}
|
||||
|
||||
this.lastChangeTimeout = setTimeout(() => {
|
||||
this.$emit('input', this.color)
|
||||
this.$emit('change')
|
||||
}, 500)
|
||||
},
|
||||
reset() {
|
||||
// FIXME: I havn't found a way to make it clear to the user the color war reset.
|
||||
// Not sure if verte is capable of this - it does not show the change when setting this.color = ''
|
||||
this.color = ''
|
||||
this.update()
|
||||
},
|
||||
this.lastChangeTimeout = setTimeout(() => {
|
||||
this.$emit('input', this.color)
|
||||
this.$emit('change')
|
||||
}, 500)
|
||||
},
|
||||
}
|
||||
reset() {
|
||||
// FIXME: I havn't found a way to make it clear to the user the color war reset.
|
||||
// Not sure if verte is capable of this - it does not show the change when setting this.color = ''
|
||||
this.color = ''
|
||||
this.update()
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
Reference in a new issue