91 lines
No EOL
1.6 KiB
Vue
91 lines
No EOL
1.6 KiB
Vue
<template>
|
|
<label class="checkbox" :class="{ isFilter }">
|
|
<input
|
|
:id="id"
|
|
class="checkbox__input"
|
|
type="checkbox"
|
|
:checked="modelValue"
|
|
@change="onChange"
|
|
/>
|
|
<span class="checkbox__block"></span>
|
|
<span class="checkbox__label">
|
|
<slot/>
|
|
</span>
|
|
</label>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
const props = defineProps<{
|
|
id: string,
|
|
modelValue: boolean,
|
|
isFilter: boolean
|
|
}>();
|
|
const emit = defineEmits<{
|
|
(e: 'update:modelValue', v: boolean): void
|
|
}>();
|
|
|
|
function onChange(e: Event) {
|
|
const checked = (e.target as HTMLInputElement).checked;
|
|
emit('update:modelValue', checked);
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.checkbox {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 5px;
|
|
cursor: pointer;
|
|
|
|
&.isFilter {
|
|
& .checkbox__block {
|
|
border: 2px solid $accent;
|
|
border-radius: $default_border_radius;
|
|
}
|
|
|
|
& .checkbox__label {
|
|
color: $accent;
|
|
}
|
|
}
|
|
|
|
&__input {
|
|
display: none;
|
|
opacity: 0;
|
|
}
|
|
|
|
&__block {
|
|
cursor: pointer;
|
|
display: inline-block;
|
|
width: 20px;
|
|
height: 20px;
|
|
border: 2px solid $black;
|
|
border-radius: $default_border_radius;
|
|
position: relative;
|
|
|
|
&::after {
|
|
content: "";
|
|
position: absolute;
|
|
top: 50%;
|
|
left: 50%;
|
|
transform: translate(-50%, -50%);
|
|
width: 10px;
|
|
height: 10px;
|
|
background-color: $accent;
|
|
border-radius: 2px;
|
|
opacity: 0;
|
|
}
|
|
}
|
|
|
|
&__label {
|
|
cursor: pointer;
|
|
color: #2B2B2B;
|
|
font-size: 12px;
|
|
font-weight: 500;
|
|
line-height: 16px;
|
|
}
|
|
}
|
|
|
|
.checkbox__input:checked + .checkbox__block::after {
|
|
opacity: 1;
|
|
}
|
|
</style> |