api-client/components/section.vue

61 lines
1.3 KiB
Vue
Raw Normal View History

<template>
<fieldset :id="label.toLowerCase()" :class="{ 'no-colored-frames': noFrameColors }">
2019-10-25 08:14:34 +00:00
<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);
}
2019-10-22 12:02:26 +00:00
.icon {
margin-right: 8px;
}
</style>
<script>
2019-10-25 08:14:34 +00:00
export default {
computed: {
noFrameColors() {
return this.$store.state.postwoman.settings.DISABLE_FRAME_COLORS || false;
}
},
2019-10-25 08:14:34 +00:00
data() {
return {
isCollapsed: false
};
},
2019-10-25 08:14:34 +00:00
props: {
label: {
type: String,
default: "Section"
},
icon: {
type: String,
default: "lens"
},
collapsed: {
type: Boolean
}
2019-10-22 12:02:26 +00:00
},
2019-10-25 08:14:34 +00:00
methods: {
collapse({ target }) {
const parent = target.parentNode.parentNode;
parent.querySelector(".collapsible").classList.toggle("hidden");
this.isCollapsed = !this.isCollapsed;
}
}
2019-10-25 08:14:34 +00:00
};
2019-08-25 08:37:21 +00:00
</script>