api-client/components/app/Section.vue

68 lines
1.4 KiB
Vue
Raw Normal View History

<template>
<fieldset :id="label.toLowerCase()">
2020-12-11 16:54:34 +00:00
<legend v-if="!noLegend" @click.prevent="collapse">
2019-10-25 08:14:34 +00:00
<span>{{ label }}</span>
2020-09-24 02:52:54 +00:00
<i class="ml-2 align-middle 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>
2020-02-25 16:10:40 +00:00
<div class="collapsible" :class="{ hidden: isCollapsed(label.toLowerCase()) }">
<slot />
</div>
</fieldset>
</template>
<style scoped lang="scss">
2020-06-19 17:37:40 +00:00
fieldset {
2020-12-11 16:54:34 +00:00
@apply my-4;
2020-09-22 17:06:37 +00:00
@apply rounded-lg;
@apply bg-bgDarkColor;
@apply transition;
@apply ease-in-out;
@apply duration-150;
2021-03-16 09:11:19 +00:00
@apply w-full;
2020-06-19 17:37:40 +00:00
legend {
2020-12-11 16:54:34 +00:00
@apply px-4;
2020-09-22 17:06:37 +00:00
@apply text-fgColor;
@apply font-bold;
@apply cursor-pointer;
@apply transition;
@apply ease-in-out;
@apply duration-150;
2020-06-19 17:37:40 +00:00
}
2019-11-02 05:32:21 +00:00
}
</style>
<script lang="ts">
import Vue from "vue"
export default Vue.extend({
2019-11-02 05:32:21 +00:00
computed: {
sectionString(): string {
2020-02-25 16:33:02 +00:00
return `${this.$route.path.replace(/\/+$/, "")}/${this.label}`
2020-02-25 16:10:40 +00:00
},
2019-11-02 05:32:21 +00:00
},
props: {
label: {
type: String,
default: "Section",
2019-10-22 12:02:26 +00:00
},
2020-12-11 16:54:34 +00:00
noLegend: {
type: Boolean,
default: false,
},
2019-11-02 05:32:21 +00:00
},
2019-11-02 05:32:21 +00:00
methods: {
2020-11-12 01:18:40 +00:00
collapse() {
2020-02-25 07:04:10 +00:00
// Save collapsed section into the collapsedSections array
2020-02-25 16:10:40 +00:00
this.$store.commit("setCollapsedSection", this.sectionString)
2020-02-24 18:44:50 +00:00
},
isCollapsed(_label: string) {
2020-02-25 16:10:40 +00:00
return this.$store.state.theme.collapsedSections.includes(this.sectionString) || false
},
},
})
2019-08-25 08:37:21 +00:00
</script>