2022-07-15 07:23:55 +00:00
|
|
|
<template>
|
2024-01-11 23:29:00 +00:00
|
|
|
<span :class="value && 'checked'">
|
2024-03-19 22:48:12 +00:00
|
|
|
<input v-bind="$attrs" v-model="value" :checked="value" type="checkbox">
|
2022-07-15 07:23:55 +00:00
|
|
|
</span>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2024-01-11 23:29:00 +00:00
|
|
|
import { computed } from 'vue'
|
2022-07-15 07:23:55 +00:00
|
|
|
|
2024-01-11 23:29:00 +00:00
|
|
|
const props = withDefaults(defineProps<{ modelValue?: any }>(), { modelValue: false })
|
2022-07-15 07:23:55 +00:00
|
|
|
|
2022-11-13 15:18:24 +00:00
|
|
|
const emit = defineEmits<{ (e: 'update:modelValue', value: boolean): void }>()
|
2022-07-15 07:23:55 +00:00
|
|
|
|
2024-01-11 23:29:00 +00:00
|
|
|
const value = computed({
|
|
|
|
get: () => props.modelValue,
|
|
|
|
set: value => emit('update:modelValue', value)
|
|
|
|
})
|
2022-07-15 07:23:55 +00:00
|
|
|
</script>
|
|
|
|
|
2024-01-11 22:24:45 +00:00
|
|
|
<style lang="scss" scoped>
|
2022-07-15 07:23:55 +00:00
|
|
|
span {
|
|
|
|
position: relative;
|
2024-01-11 19:51:35 +00:00
|
|
|
vertical-align: bottom;
|
|
|
|
display: inline-block;
|
|
|
|
width: 32px;
|
|
|
|
height: 20px;
|
|
|
|
background: #c2c2c2;
|
|
|
|
border-radius: 99rem;
|
|
|
|
box-shadow: inset 0 1px 5px 0 rgba(0, 0, 0, .2);
|
|
|
|
cursor: pointer;
|
|
|
|
transition: all .2s ease-in-out;
|
|
|
|
margin-right: .5rem;
|
|
|
|
|
|
|
|
&::after {
|
|
|
|
content: '';
|
|
|
|
height: 16px;
|
|
|
|
aspect-ratio: 1/1;
|
|
|
|
position: absolute;
|
|
|
|
background: #fff;
|
|
|
|
top: 2px;
|
|
|
|
left: 2px;
|
|
|
|
border-radius: 99rem;
|
|
|
|
transition: all .2s ease-in-out;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.checked {
|
|
|
|
background: var(--color-highlight);
|
|
|
|
|
|
|
|
&::after {
|
|
|
|
left: 14px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
input {
|
|
|
|
display: none;
|
|
|
|
}
|
2022-07-15 07:23:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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>
|