2024-04-04 22:20:42 +00:00
|
|
|
<template>
|
|
|
|
<span
|
2024-04-24 19:16:12 +00:00
|
|
|
class="relative align-bottom inline-block w-[32px] h-[20px] bg-gray-500 rounded-full shadow-inner cursor-pointer transition-all duration-200 ease-in-out mr-2
|
2024-04-04 22:20:42 +00:00
|
|
|
after:h-[16px] after:aspect-square after:absolute after:bg-white after:top-[2px] after:left-[2px] after:rounded-full after:transition-left after:duration-200 after:ease-in-out
|
|
|
|
has-[:checked]:bg-k-highlight has-[:checked]:after:left-[14px]"
|
2024-04-24 19:16:12 +00:00
|
|
|
tabindex="0"
|
|
|
|
role="checkbox"
|
|
|
|
@keydown.space="value = !value"
|
2024-04-04 22:20:42 +00:00
|
|
|
>
|
2024-04-23 21:01:27 +00:00
|
|
|
<input v-model="value" :checked="value" class="hidden" type="checkbox" v-bind="$attrs">
|
2024-04-04 22:20:42 +00:00
|
|
|
</span>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
import { computed } from 'vue'
|
|
|
|
|
|
|
|
const props = withDefaults(defineProps<{ modelValue?: any }>(), { modelValue: false })
|
|
|
|
|
|
|
|
const emit = defineEmits<{ (e: 'update:modelValue', value: boolean): void }>()
|
|
|
|
|
|
|
|
const value = computed({
|
|
|
|
get: () => props.modelValue,
|
|
|
|
set: value => emit('update:modelValue', value)
|
|
|
|
})
|
|
|
|
</script>
|