Add checkbox group component, update checkbox component
This commit is contained in:
parent
28a193e22a
commit
7bb8910a18
|
|
@ -1,13 +1,16 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import log from "loglevel";
|
import log from "loglevel";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
checked?: boolean;
|
checked?: boolean;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
|
label?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
checked: false,
|
checked: false,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
|
label: undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(["toggle"]);
|
const emit = defineEmits(["toggle"]);
|
||||||
|
|
@ -33,10 +36,10 @@ const input = (e: Event) => {
|
||||||
'opacity-50': disabled,
|
'opacity-50': disabled,
|
||||||
'cursor-not-allowed': disabled,
|
'cursor-not-allowed': disabled,
|
||||||
}"
|
}"
|
||||||
class="w-8 h-8 cursor-pointer"
|
class="cursor-pointer inline-flex grow"
|
||||||
>
|
>
|
||||||
<label
|
<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="
|
:class="
|
||||||
checked
|
checked
|
||||||
? 'bg-[url(/static/icons/icon-checkbox-checked.svg)] hover:bg-[url(/static/icons/icon-checkbox-checked-hover.svg)]'
|
? '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"
|
@keydown="keydown"
|
||||||
@input="input"
|
@input="input"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<span v-if="label" class="ml-4">
|
||||||
|
{{ label }}
|
||||||
|
</span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
Loading…
Reference in New Issue