Skip to content

Commit

Permalink
fix: handle both static and unmount
Browse files Browse the repository at this point in the history
  • Loading branch information
noook committed Mar 30, 2024
1 parent 1c1b617 commit 8b81735
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions src/runtime/components/elements/Accordion.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,31 @@
</slot>
</HDisclosureButton>

<DefinePanelTemplate>
<HDisclosurePanel
:class="[ui.item.base, ui.item.size, ui.item.color, ui.item.padding]"
:unmount="unmount"
:static="!unmount"
>
<slot :name="item.slot || 'item'" :item="item" :index="index" :open="open" :close="close">
{{ item.content }}
</slot>
</HDisclosurePanel>
</DefinePanelTemplate>

<Transition
v-bind="ui.transition"
@enter="onEnter"
@after-enter="onAfterEnter"
@before-leave="onBeforeLeave"
@leave="onLeave"
>
<HDisclosurePanel :class="[ui.item.base, ui.item.size, ui.item.color, ui.item.padding]" :unmount="unmount">
<slot :name="item.slot || 'item'" :item="item" :index="index" :open="open" :close="close">
{{ item.content }}
</slot>
</HDisclosurePanel>
<PanelTemplate v-if="unmount" />
<template v-else>
<div v-show="open">
<PanelTemplate />
</div>
</template>
</Transition>
</HDisclosure>
</div>
Expand All @@ -52,6 +65,7 @@
<script lang="ts">
import { ref, computed, toRef, defineComponent, watch } from 'vue'
import type { PropType } from 'vue'
import { createReusableTemplate } from '@vueuse/core'
import { Disclosure as HDisclosure, DisclosureButton as HDisclosureButton, DisclosurePanel as HDisclosurePanel, provideUseId } from '@headlessui/vue'
import UIcon from '../elements/Icon.vue'
import UButton from '../elements/Button.vue'
Expand All @@ -67,13 +81,18 @@ const config = mergeConfig<typeof accordion>(appConfig.ui.strategy, appConfig.ui
const configButton = mergeConfig<typeof button>(appConfig.ui.strategy, appConfig.ui.button, button)
const [DefinePanelTemplate, PanelTemplate] = createReusableTemplate()
export default defineComponent({
components: {
HDisclosure,
HDisclosureButton,
HDisclosurePanel,
UIcon,
UButton
UButton,
DefinePanelTemplate,
PanelTemplate,

Check failure on line 95 in src/runtime/components/elements/Accordion.vue

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 18)

Unexpected trailing comma
},
inheritAttrs: false,
props: {
Expand Down

0 comments on commit 8b81735

Please sign in to comment.