This repository has been archived on 2024-02-08. You can view files and clone it, but cannot push or open issues or pull requests.
frontend/src/components/global/colorPicker.vue
konrad e266c69acd
All checks were successful
continuous-integration/drone/push Build is passing
Add option to remove color from label, task, namespace or list (#157)
Add reset to color picker

Move all usages of verte to seperate component

Co-authored-by: kolaente <k@knt.li>
Reviewed-on: #157
2020-06-15 09:46:52 +00:00

60 lines
1012 B
Vue

<template>
<div class="color-picker-container">
<verte
v-model="color"
menuPosition="top"
picker="square"
model="hex"
:enableAlpha="false"
:rgbSliders="true"/>
<a @click="reset" class="reset">
Reset Color
</a>
</div>
</template>
<script>
import verte from 'verte'
import 'verte/dist/verte.css'
export default {
name: 'colorPicker',
data() {
return {
color: '',
}
},
components: {
verte,
},
props: {
value: {
required: true,
},
},
watch: {
value(newVal) {
this.color = newVal
},
color() {
this.update()
}
},
mounted() {
this.color = this.value
},
methods: {
update() {
this.$emit('input', this.color)
this.$emit('change')
},
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>