Files
716d43a9a8 Nuxt 3 migration (#4342)
Update the nuxt3 version.

Co-authored-by: Jonathan Adeline <jonathan@baserow.io>
Co-authored-by: Bram Wiepjes <bramw@protonmail.com>
Co-authored-by: Cezary <cezary@baserow.io>
Co-authored-by: Tsering Paljor <tsering@baserow.io>
Co-authored-by: Przemyslaw Kukulski <przemyslaw+gh@baserow.io>
Co-authored-by: Bram <bram2w@users.noreply.github.com>
2026-01-22 10:27:19 +01:00

83 lines
1.6 KiB
Vue

<template>
<div
class="expandable"
:class="{
'expandable--expanded': expanded,
}"
>
<div
class="expandable__header"
:class="{
'expandable__header--card': card,
'expandable--toggle-on-click': toggleOnClick,
}"
@click="onClick()"
>
<slot name="header" :toggle="toggle" :expanded="expanded" />
</div>
<div
v-if="expanded"
class="expandable__content"
:class="{ 'expandable__content--card': card }"
>
<slot :toggle="toggle" :expanded="expanded" />
</div>
</div>
</template>
<script>
export default {
name: 'Expandable',
props: {
defaultExpanded: {
type: Boolean,
required: false,
default: false,
},
forceExpanded: {
type: Boolean,
required: false,
default: null,
},
card: {
type: Boolean,
required: false,
default: false,
},
/**
* If true, then clicking on any part of the heading will toggle the content
*/
toggleOnClick: {
type: Boolean,
required: false,
default: false,
},
},
emits: ['toggle'],
data() {
return { expandedState: this.defaultExpanded }
},
computed: {
expanded() {
if (this.forceExpanded !== null) {
return this.forceExpanded
} else {
return this.expandedState
}
},
},
methods: {
onClick() {
if (this.toggleOnClick) {
this.toggle()
}
this.$emit('toggle')
},
toggle() {
this.expandedState = !this.expandedState
},
},
}
</script>