Files
hoppscotch/components/section.vue
2019-10-25 14:56:24 -03:00

61 lines
1.3 KiB
Vue

<template>
<fieldset :id="label.toLowerCase()" :class="{ 'no-colored-frames': !frameColorsEnabled }">
<legend @click.prevent="collapse">
<i class="material-icons icon">{{ icon }}</i>
<span>{{ label }}</span>
<i class="material-icons" v-if="isCollapsed">expand_more</i>
<i class="material-icons" v-if="!isCollapsed">expand_less</i>
</legend>
<div class="collapsible" :class="{ hidden: collapsed }">
<slot />
</div>
</fieldset>
</template>
<style>
fieldset.no-colored-frames legend {
color: var(--fg-color);
}
.icon {
margin-right: 8px;
}
</style>
<script>
export default {
computed: {
frameColorsEnabled() {
return this.$store.state.postwoman.settings.FRAME_COLORS_ENABLED || false;
}
},
data() {
return {
isCollapsed: false
};
},
props: {
label: {
type: String,
default: "Section"
},
icon: {
type: String,
default: "lens"
},
collapsed: {
type: Boolean
}
},
methods: {
collapse({ target }) {
const parent = target.parentNode.parentNode;
parent.querySelector(".collapsible").classList.toggle("hidden");
this.isCollapsed = !this.isCollapsed;
}
}
};
</script>