api-client/components/section.vue

62 lines
1.4 KiB
Vue
Raw Normal View History

<template>
2020-02-24 18:44:50 +00:00
<fieldset :id="label.toLowerCase()" :class="{ 'no-colored-frames': !frameColorsEnabled }">
2019-10-25 08:14:34 +00:00
<legend @click.prevent="collapse">
<span>{{ label }}</span>
2019-12-02 15:20:20 +00:00
<i class="material-icons">
{{ isCollapsed(label) ? "expand_more" : "expand_less" }}
2019-12-02 15:20:20 +00:00
</i>
2019-10-25 08:14:34 +00:00
</legend>
<div
class="collapsible"
:class="{ hidden: isCollapsed(label.toLowerCase()) }"
>
<slot />
</div>
</fieldset>
</template>
<style scoped lang="scss">
2019-11-02 05:32:21 +00:00
fieldset.no-colored-frames legend {
color: var(--fg-color);
}
</style>
<script>
2019-11-02 05:32:21 +00:00
export default {
computed: {
frameColorsEnabled() {
return this.$store.state.postwoman.settings.FRAME_COLORS_ENABLED || false;
2020-02-24 18:44:50 +00:00
},
sectionString() {
return `${this.$route.path}/${this.label}`;
2020-02-24 18:44:50 +00:00
}
2019-11-02 05:32:21 +00:00
},
2019-10-25 08:14:34 +00:00
2019-11-02 05:32:21 +00:00
props: {
label: {
type: String,
default: "Section",
2019-10-22 12:02:26 +00:00
},
2019-11-02 05:32:21 +00:00
collapsed: {
2020-02-24 18:44:50 +00:00
type: Boolean,
},
2019-11-02 05:32:21 +00:00
},
2019-11-02 05:32:21 +00:00
methods: {
collapse({ target }) {
const parent = target.parentNode.parentNode;
parent.querySelector(".collapsible").classList.toggle("hidden");
2020-02-25 07:04:10 +00:00
// Save collapsed section into the collapsedSections array
this.$store.commit("setCollapsedSection", this.sectionString);
2020-02-24 18:44:50 +00:00
},
isCollapsed(label) {
return (
this.$store.state.theme.collapsedSections.includes(
this.sectionString
) || false
);
}
}
};
2019-08-25 08:37:21 +00:00
</script>