koel/resources/assets/js/components/ui/CheckBox.vue

38 lines
785 B
Vue
Raw Normal View History

2022-07-15 07:23:55 +00:00
<template>
<span>
<input :checked="checked" type="checkbox" v-bind="$attrs" @input="onInput">
2022-12-02 16:17:37 +00:00
<icon v-if="checked" :icon="faCheck" />
2022-07-15 07:23:55 +00:00
</span>
</template>
<script lang="ts" setup>
import { faCheck } from '@fortawesome/free-solid-svg-icons'
import { ref } from 'vue'
const props = withDefaults(defineProps<{ modelValue?: any }>(), {
modelValue: false
})
const checked = ref(props.modelValue)
const emit = defineEmits<{ (e: 'update:modelValue', value: boolean): void }>()
2022-07-15 07:23:55 +00:00
2022-12-02 16:17:37 +00:00
const onInput = (event: Event) => {
2022-07-15 07:23:55 +00:00
checked.value = (event.target as HTMLInputElement).checked
emit('update:modelValue', checked.value)
}
</script>
<style scoped>
span {
position: relative;
}
svg {
color: var(--color-highlight);
position: absolute;
top: 1px;
2023-08-20 22:35:58 +00:00
left: 1px;
2022-07-15 07:23:55 +00:00
}
</style>