|
|
@ -17,21 +17,23 @@ const props = withDefaults(defineProps<Props>(), { |
|
|
|
pickButton: false, |
|
|
|
pickButton: false, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits(['update:modelValue', 'input']) |
|
|
|
const emit = defineEmits(['input', 'closeModal']) |
|
|
|
|
|
|
|
|
|
|
|
const vModel = computed({ |
|
|
|
const vModel = computed({ |
|
|
|
get: () => props.modelValue, |
|
|
|
get: () => props.modelValue, |
|
|
|
set: (val) => { |
|
|
|
set: (val) => { |
|
|
|
emit('update:modelValue', val || null) |
|
|
|
|
|
|
|
emit('input', val || null) |
|
|
|
emit('input', val || null) |
|
|
|
}, |
|
|
|
}, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const picked = ref<string>(props.modelValue || enumColor.light[0]) |
|
|
|
const picked = ref<string>(props.modelValue || enumColor.light[0]) |
|
|
|
|
|
|
|
|
|
|
|
const selectColor = (color: string) => { |
|
|
|
const selectColor = (color: string, closeModal = false) => { |
|
|
|
picked.value = color |
|
|
|
picked.value = color |
|
|
|
if (props.pickButton) vModel.value = color |
|
|
|
if (props.pickButton) vModel.value = color |
|
|
|
|
|
|
|
if (closeModal) { |
|
|
|
|
|
|
|
emit('closeModal') |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const isPickerOn = ref(false) |
|
|
|
const isPickerOn = ref(false) |
|
|
@ -39,9 +41,7 @@ const isPickerOn = ref(false) |
|
|
|
const compare = (colorA: string, colorB: string) => colorA.toLowerCase() === colorB.toLowerCase() |
|
|
|
const compare = (colorA: string, colorB: string) => colorA.toLowerCase() === colorB.toLowerCase() |
|
|
|
|
|
|
|
|
|
|
|
watch(picked, (n, _o) => { |
|
|
|
watch(picked, (n, _o) => { |
|
|
|
if (!props.pickButton) { |
|
|
|
vModel.value = n |
|
|
|
vModel.value = n |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
@ -54,7 +54,7 @@ watch(picked, (n, _o) => { |
|
|
|
class="color-selector" |
|
|
|
class="color-selector" |
|
|
|
:class="compare(picked, color) ? 'selected' : ''" |
|
|
|
:class="compare(picked, color) ? 'selected' : ''" |
|
|
|
:style="{ 'background-color': `${color}` }" |
|
|
|
:style="{ 'background-color': `${color}` }" |
|
|
|
@click="selectColor(color)" |
|
|
|
@click="selectColor(color, true)" |
|
|
|
> |
|
|
|
> |
|
|
|
{{ compare(picked, color) ? '✓' : '' }} |
|
|
|
{{ compare(picked, color) ? '✓' : '' }} |
|
|
|
</button> |
|
|
|
</button> |
|
|
|