2121 -->
2222
2323<docs >
24+ As this component is based on the [NcPopover](NcPopover) component,
25+ it also inherits all props and events from it.
2426
2527### General description
2628
@@ -82,13 +84,13 @@ export default {
8284</style>
8385```
8486
85- * Using v-bind for both color and open state and emitting an event that updates the color
87+ * Using v-model for both color and open state and emitting an event that updates the color
8688
8789```vue
8890<template>
8991 <div class="container1">
9092 <NcButton @click="open = !open"> Click Me </NcButton>
91- <NcColorPicker :value ="color" @input="updateColor" :shown.sync ="open">
93+ <NcColorPicker v-model ="color" v-model :shown="open">
9294 <div :style="{'background-color': color}" class="color1" />
9395 </NcColorPicker>
9496 </div>
@@ -100,11 +102,6 @@ export default {
100102 color: '#0082c9',
101103 open: false
102104 }
103- },
104- methods: {
105- updateColor(e) {
106- this.color = e
107- }
108105 }
109106}
110107</script>
@@ -223,13 +220,14 @@ import Check from 'vue-material-design-icons/Check.vue'
223220import DotsHorizontal from ' vue-material-design-icons/DotsHorizontal.vue'
224221
225222import { Chrome } from ' @ckpack/vue-color'
223+ import { defineComponent } from ' vue'
226224
227225const rgbToHex = function (color ) {
228226 const hex = color .toString (16 )
229227 return hex .length === 1 ? ' 0' + hex : hex
230228}
231229
232- export default {
230+ export default defineComponent ( {
233231 name: ' NcColorPicker' ,
234232
235233 components: {
@@ -247,7 +245,7 @@ export default {
247245 /**
248246 * A HEX color that represents the initial value of the picker
249247 */
250- value : {
248+ modelValue : {
251249 type: String ,
252250 required: true ,
253251 },
@@ -278,19 +276,19 @@ export default {
278276 ' submit' ,
279277 ' close' ,
280278 ' update:open' ,
281- ' update:value ' ,
279+ ' update:modelValue ' ,
282280 ' input' ,
283281 ],
284282
285283 data () {
286284 return {
287- currentColor: this .value ,
285+ currentColor: this .modelValue ,
288286 advanced: false ,
289287 }
290288 },
291289
292290 watch: {
293- value (color ) {
291+ modelValue (color ) {
294292 this .currentColor = color
295293 },
296294 },
@@ -340,7 +338,7 @@ export default {
340338 /**
341339 * Emits a hexadecimal string e.g. '#ffffff'
342340 */
343- this .$emit (' update:value ' , color)
341+ this .$emit (' update:modelValue ' , color)
344342
345343 /**
346344 * Emits a hexadecimal string e.g. '#ffffff'
@@ -349,7 +347,7 @@ export default {
349347
350348 },
351349 },
352- }
350+ })
353351
354352 </script >
355353
0 commit comments