summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/vue_shared/components/content_transition.vue
blob: 446610d6b91be0fb3b3f78dba6610db2356bb9f4 (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
<script>
export default {
  props: {
    currentSlot: {
      type: String,
      required: true,
    },
    slots: {
      type: Array,
      required: true,
    },
    transitionName: {
      type: String,
      required: true,
    },
  },
  methods: {
    shouldShow(key) {
      return this.currentSlot === key;
    },
  },
};
</script>
<template>
  <div>
    <transition v-for="{ key, attributes } in slots" :key="key" :name="transitionName">
      <div v-show="shouldShow(key)" v-bind="attributes">
        <slot :name="key"></slot>
      </div>
    </transition>
  </div>
</template>