summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/vue_shared/components/tabs/tab.vue
blob: 9b2f46186acd300077b10d6870b9f30875afdd68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<script>
export default {
  props: {
    title: {
      type: String,
      required: false,
      default: '',
    },
    active: {
      type: Boolean,
      required: false,
      default: false,
    },
  },
  data() {
    return {
      // props can't be updated, so we map it to data where we can
      localActive: this.active,
    };
  },
  watch: {
    active() {
      this.localActive = this.active;
    },
  },
  created() {
    this.isTab = true;
  },
  updated() {
    if (this.$parent) {
      this.$parent.$forceUpdate();
    }
  },
};
</script>

<template>
  <div
    class="tab-pane"
    :class="{
      active: localActive
    }"
    role="tabpanel"
  >
    <slot></slot>
  </div>
</template>