2021-10-28 21:41:42 +02:00
|
|
|
<template>
|
2022-03-13 23:10:48 +01:00
|
|
|
<label class="flex justify-start items-center" :class="!disabled ? 'cursor-pointer' : ''">
|
|
|
|
<div class="border-2 rounded flex flex-shrink-0 justify-center items-center" :class="wrapperClass">
|
|
|
|
<input v-model="selected" :disabled="disabled" type="checkbox" class="opacity-0 absolute" :class="!disabled ? 'cursor-pointer' : ''" />
|
2024-07-08 18:36:37 +02:00
|
|
|
<span v-if="partial" class="material-symbols text-base leading-none text-gray-400">remove</span>
|
2023-12-21 20:52:42 +01:00
|
|
|
<svg v-else-if="selected" class="fill-current pointer-events-none" :class="svgClass" viewBox="0 0 20 20"><path d="M0 11l2-2 5 5L18 3l2 2L7 18z" /></svg>
|
2021-10-28 21:41:42 +02:00
|
|
|
</div>
|
2023-03-23 00:05:43 +01:00
|
|
|
<div v-if="label" class="select-none" :class="[labelClassname, disabled ? 'text-gray-400' : 'text-gray-100']">{{ label }}</div>
|
2021-10-28 21:41:42 +02:00
|
|
|
</label>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
value: Boolean,
|
2022-01-25 01:03:54 +01:00
|
|
|
label: String,
|
|
|
|
small: Boolean,
|
2022-08-20 21:21:58 +02:00
|
|
|
medium: Boolean,
|
2022-01-25 01:03:54 +01:00
|
|
|
checkboxBg: {
|
|
|
|
type: String,
|
|
|
|
default: 'white'
|
|
|
|
},
|
2022-03-13 23:10:48 +01:00
|
|
|
borderColor: {
|
|
|
|
type: String,
|
|
|
|
default: 'gray-400'
|
|
|
|
},
|
2022-01-25 01:03:54 +01:00
|
|
|
checkColor: {
|
|
|
|
type: String,
|
|
|
|
default: 'green-500'
|
2022-03-13 23:10:48 +01:00
|
|
|
},
|
|
|
|
labelClass: {
|
|
|
|
type: String,
|
|
|
|
default: ''
|
|
|
|
},
|
2023-12-21 20:52:42 +01:00
|
|
|
disabled: Boolean,
|
|
|
|
partial: Boolean
|
2021-10-28 21:41:42 +02:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
selected: {
|
|
|
|
get() {
|
|
|
|
return this.value
|
|
|
|
},
|
|
|
|
set(val) {
|
|
|
|
this.$emit('input', !!val)
|
|
|
|
}
|
2021-10-31 01:50:49 +02:00
|
|
|
},
|
|
|
|
wrapperClass() {
|
2022-03-13 23:10:48 +01:00
|
|
|
var classes = [`bg-${this.checkboxBg} border-${this.borderColor}`]
|
2022-01-25 01:03:54 +01:00
|
|
|
if (this.small) classes.push('w-4 h-4')
|
2022-08-20 21:21:58 +02:00
|
|
|
else if (this.medium) classes.push('w-5 h-5')
|
2022-01-25 01:03:54 +01:00
|
|
|
else classes.push('w-6 h-6')
|
|
|
|
|
|
|
|
return classes.join(' ')
|
|
|
|
},
|
2022-03-13 23:10:48 +01:00
|
|
|
labelClassname() {
|
|
|
|
if (this.labelClass) return this.labelClass
|
2022-08-28 21:21:28 +02:00
|
|
|
var classes = []
|
|
|
|
if (this.small) classes.push('text-xs md:text-sm pl-1')
|
|
|
|
else if (this.medium) classes.push('text-base md:text-lg pl-2')
|
|
|
|
else classes.push('pl-2')
|
2022-03-13 23:10:48 +01:00
|
|
|
return classes.join(' ')
|
2021-10-31 01:50:49 +02:00
|
|
|
},
|
|
|
|
svgClass() {
|
2022-01-25 01:03:54 +01:00
|
|
|
var classes = [`text-${this.checkColor}`]
|
|
|
|
if (this.small) classes.push('w-3 h-3')
|
2022-08-20 21:21:58 +02:00
|
|
|
else if (this.medium) classes.push('w-3.5 h-3.5')
|
2022-01-25 01:03:54 +01:00
|
|
|
else classes.push('w-4 h-4')
|
|
|
|
|
|
|
|
return classes.join(' ')
|
2021-10-28 21:41:42 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {},
|
|
|
|
mounted() {}
|
|
|
|
}
|
|
|
|
</script>
|