elk/components/common/CommonCheckbox.vue

40 wiersze
915 B
Vue
Czysty Zwykły widok Historia

<script setup lang="ts">
defineProps<{
2023-05-20 19:23:41 +00:00
label?: string
hover?: boolean
2023-05-20 19:23:41 +00:00
iconChecked?: string
iconUnchecked?: string
}>()
2023-04-12 12:35:35 +00:00
const { modelValue } = defineModels<{
2023-05-20 19:23:41 +00:00
modelValue?: boolean | null
}>()
</script>
<template>
<label
class="common-checkbox flex items-center cursor-pointer py-1 text-md w-full gap-y-1"
:class="hover ? 'hover:bg-active ms--2 px-4 py-2' : null"
2023-05-20 19:23:41 +00:00
v-bind="$attrs"
@click.prevent="modelValue = !modelValue"
>
2023-05-20 19:23:41 +00:00
<span v-if="label" flex-1 ms-2 pointer-events-none>{{ label }}</span>
<span
2023-05-20 19:23:41 +00:00
:class="modelValue ? (iconChecked ?? 'i-ri:checkbox-line') : (iconUnchecked ?? 'i-ri:checkbox-blank-line')"
text-lg
aria-hidden="true"
/>
<input
v-model="modelValue"
type="checkbox"
sr-only
>
</label>
</template>
<style>
.common-checkbox:focus-within {
outline: none;
border-bottom: 1px solid var(--c-text-base);
}
</style>