Add checkbox group component, update checkbox component

This commit is contained in:
Ramon Wenger 2022-12-22 11:09:32 +01:00
parent 28a193e22a
commit 7bb8910a18
2 changed files with 45 additions and 2 deletions

View File

@ -1,13 +1,16 @@
<script setup lang="ts">
import log from "loglevel";
interface Props {
checked?: boolean;
disabled?: boolean;
label?: string;
}
const props = withDefaults(defineProps<Props>(), {
checked: false,
disabled: false,
label: undefined,
});
const emit = defineEmits(["toggle"]);
@ -33,10 +36,10 @@ const input = (e: Event) => {
'opacity-50': disabled,
'cursor-not-allowed': disabled,
}"
class="w-8 h-8 cursor-pointer"
class="cursor-pointer inline-flex grow"
>
<label
class="w-8 h-8 block flex-none bg-contain disabled:opacity-50 cy-checkbox cy-checkbox-checked"
class="block bg-contain disabled:opacity-50 cy-checkbox cy-checkbox-checked bg-no-repeat pl-8 h-8 flex items-center"
:class="
checked
? 'bg-[url(/static/icons/icon-checkbox-checked.svg)] hover:bg-[url(/static/icons/icon-checkbox-checked-hover.svg)]'
@ -55,6 +58,10 @@ const input = (e: Event) => {
@keydown="keydown"
@input="input"
/>
<span v-if="label" class="ml-4">
{{ label }}
</span>
</label>
</div>
</template>

View File

@ -0,0 +1,36 @@
<template>
<div
:model-value="modelValue"
class="border p-12"
@update:modelValue="$emit('update:modelValue', $event)"
>
<h2 class="text-5xl mb-12 leading-normal font-bold block">{{ label }}</h2>
<div class="flex flex-col justify-start align-items-start justify-items-start">
<ItCheckbox
v-for="item in items"
:key="item.id"
:label="item.name"
class="mb-4"
/>
</div>
</div>
</template>
<script setup lang="ts">
import type { RadioItem } from "@/components/learningPath/feedback.types";
import ItCheckbox from "@/components/ui/ItCheckbox.vue";
import {
RadioGroup,
// RadioGroupDescription,
RadioGroupLabel,
RadioGroupOption,
} from "@headlessui/vue";
defineProps<{
modelValue: any;
items: RadioItem<any>[];
label: string;
}>();
defineEmits(["update:modelValue"]);
</script>