2021-11-15 14:55:40 +00:00
|
|
|
<template>
|
|
|
|
|
<div
|
2022-11-27 17:49:19 +00:00
|
|
|
class="inline-flex items-center justify-center transition cursor-pointer flex-nowrap group hover:text-secondaryDark"
|
2022-03-01 06:41:53 +00:00
|
|
|
role="checkbox"
|
|
|
|
|
:aria-checked="on"
|
2022-09-29 05:25:21 +00:00
|
|
|
@click="emit('change')"
|
2021-11-15 14:55:40 +00:00
|
|
|
>
|
|
|
|
|
<input
|
|
|
|
|
id="checkbox"
|
|
|
|
|
type="checkbox"
|
|
|
|
|
name="checkbox"
|
2022-12-03 07:31:47 +00:00
|
|
|
class="checkbox"
|
2021-11-15 14:55:40 +00:00
|
|
|
:checked="on"
|
2022-09-29 05:25:21 +00:00
|
|
|
@change="emit('change')"
|
2021-11-15 14:55:40 +00:00
|
|
|
/>
|
|
|
|
|
<label
|
|
|
|
|
for="checkbox"
|
2022-11-27 17:49:19 +00:00
|
|
|
class="pl-0 font-semibold truncate align-middle cursor-pointer"
|
2023-12-04 17:21:18 +00:00
|
|
|
:class="{
|
|
|
|
|
'before:mr-2': labelSlot.default
|
|
|
|
|
}"
|
2021-11-15 14:55:40 +00:00
|
|
|
>
|
|
|
|
|
<slot></slot>
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
2022-09-29 05:25:21 +00:00
|
|
|
<script setup lang="ts">
|
2023-12-04 17:21:18 +00:00
|
|
|
import { useSlots } from 'vue';
|
|
|
|
|
|
2022-09-29 05:25:21 +00:00
|
|
|
defineProps({
|
|
|
|
|
on: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
default: false,
|
2021-11-15 14:55:40 +00:00
|
|
|
},
|
|
|
|
|
})
|
2022-09-29 05:25:21 +00:00
|
|
|
|
|
|
|
|
const emit = defineEmits<{
|
|
|
|
|
(e: "change"): void
|
|
|
|
|
}>()
|
2023-12-04 17:21:18 +00:00
|
|
|
|
|
|
|
|
// used to check if the default slot is used and add a margin to the label if exists
|
|
|
|
|
const labelSlot = useSlots()
|
2021-11-15 14:55:40 +00:00
|
|
|
</script>
|
|
|
|
|
|
2022-09-29 05:25:21 +00:00
|
|
|
<style lang="scss" scoped>
|
2022-12-03 07:31:47 +00:00
|
|
|
.checkbox[type="checkbox"] {
|
2021-11-15 14:55:40 +00:00
|
|
|
@apply appearance-none;
|
|
|
|
|
@apply hidden;
|
|
|
|
|
|
|
|
|
|
& + label {
|
|
|
|
|
@apply inline-flex items-center justify-center;
|
|
|
|
|
@apply cursor-pointer;
|
|
|
|
|
|
|
|
|
|
&::before {
|
2022-12-03 07:31:47 +00:00
|
|
|
@apply border-2 border-divider;
|
2021-11-15 14:55:40 +00:00
|
|
|
@apply rounded;
|
2023-11-01 15:25:08 +00:00
|
|
|
@apply group-hover:border-accentDark;
|
2021-11-15 14:55:40 +00:00
|
|
|
@apply inline-flex;
|
|
|
|
|
@apply items-center;
|
|
|
|
|
@apply justify-center;
|
|
|
|
|
@apply text-transparent;
|
|
|
|
|
@apply h-4;
|
|
|
|
|
@apply w-4;
|
|
|
|
|
@apply font-icon;
|
|
|
|
|
@apply transition;
|
2023-08-24 18:25:22 +00:00
|
|
|
@apply content-["\e5ca"];
|
2021-11-15 14:55:40 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&:checked + label::before {
|
|
|
|
|
@apply bg-accent;
|
|
|
|
|
@apply border-accent;
|
|
|
|
|
@apply text-accentContrast;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|