Section.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <fieldset :id="label.toLowerCase()" :class="{ 'no-colored-frames': !frameColorsEnabled }">
  3. <legend v-if="!noLegend" @click.prevent="collapse">
  4. <span>{{ label }}</span>
  5. <i class="ml-2 align-middle material-icons">
  6. {{ isCollapsed(label) ? "expand_more" : "expand_less" }}
  7. </i>
  8. </legend>
  9. <div class="collapsible" :class="{ hidden: isCollapsed(label.toLowerCase()) }">
  10. <slot />
  11. </div>
  12. </fieldset>
  13. </template>
  14. <style scoped lang="scss">
  15. fieldset {
  16. @apply my-4;
  17. @apply rounded-lg;
  18. @apply bg-bgDarkColor;
  19. @apply transition;
  20. @apply ease-in-out;
  21. @apply duration-150;
  22. legend {
  23. @apply px-4;
  24. @apply text-fgColor;
  25. @apply font-bold;
  26. @apply cursor-pointer;
  27. @apply transition;
  28. @apply ease-in-out;
  29. @apply duration-150;
  30. }
  31. &.blue legend {
  32. @apply text-blue-400;
  33. }
  34. &.green legend {
  35. @apply text-green-400;
  36. }
  37. &.teal legend {
  38. @apply text-teal-400;
  39. }
  40. &.purple legend {
  41. @apply text-purple-400;
  42. }
  43. &.orange legend {
  44. @apply text-orange-400;
  45. }
  46. &.pink legend {
  47. @apply text-pink-400;
  48. }
  49. &.red legend {
  50. @apply text-red-400;
  51. }
  52. &.yellow legend {
  53. @apply text-yellow-400;
  54. }
  55. }
  56. fieldset.no-colored-frames legend {
  57. @apply text-fgColor;
  58. }
  59. </style>
  60. <script>
  61. export default {
  62. computed: {
  63. frameColorsEnabled() {
  64. return this.$store.state.postwoman.settings.FRAME_COLORS_ENABLED || false
  65. },
  66. sectionString() {
  67. return `${this.$route.path.replace(/\/+$/, "")}/${this.label}`
  68. },
  69. },
  70. props: {
  71. label: {
  72. type: String,
  73. default: "Section",
  74. },
  75. noLegend: {
  76. type: Boolean,
  77. default: false,
  78. },
  79. },
  80. methods: {
  81. collapse() {
  82. // Save collapsed section into the collapsedSections array
  83. this.$store.commit("setCollapsedSection", this.sectionString)
  84. },
  85. isCollapsed(label) {
  86. return this.$store.state.theme.collapsedSections.includes(this.sectionString) || false
  87. },
  88. },
  89. }
  90. </script>