Skip to content

Commit

Permalink
refactor: use defineModel for collapse props
Browse files Browse the repository at this point in the history
  • Loading branch information
caro3801 committed Dec 6, 2024
1 parent 3e429ab commit f7959d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
16 changes: 4 additions & 12 deletions src/components/Form/FormStep/FormStep.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@ import { computed } from 'vue'
import FormStepHeading from '@/components/Form/FormStep/FormStepHeading'
import FormStepContent from '@/components/Form/FormStep/FormStepContent'
const props = defineProps({
collapse: {
type: Boolean
},
const collapse = defineModel('collapse', { type: Boolean, default: false })
defineProps({
title: {
type: String,
required: true
Expand All @@ -19,18 +16,13 @@ const props = defineProps({
})
const classList = computed(() => ({
'form-step--collapsed': props.collapse
'form-step--collapsed': collapse.value === true
}))
</script>

<template>
<div class="form-step bg-tertiary-subtle p-3 rounded-4" :class="classList">
<form-step-heading
:title="title"
:index="index"
:collapse="collapse"
@update:collapse="$emit('update:collapse', $event)"
>
<form-step-heading v-model:collapse="collapse" :title="title" :index="index">
<template #title>
<slot name="title" />
</template>
Expand Down
5 changes: 2 additions & 3 deletions src/components/Form/FormStep/FormStepHeading.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import FormStepHeadingIndex from './FormStepHeadingIndex'
import FormStepHeadingTitle from './FormStepHeadingTitle'
import FormStepHeadingToggler from './FormStepHeadingToggler'
const collapse = defineModel('collapse', { type: Boolean, default: false })
defineProps({
title: {
type: String,
Expand All @@ -11,9 +13,6 @@ defineProps({
index: {
type: Number,
required: true
},
collapse: {
type: Boolean
}
})
</script>
Expand Down

0 comments on commit f7959d8

Please sign in to comment.