summaryrefslogtreecommitdiff
path: root/src/components/_sila/Global/Collapse.vue
blob: 367785710dfa31bec9585442235ab834a1551dbb (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
<template>
  <div class="collapse-divider">
    <b-button
      v-b-toggle="id"
      variant="collapse"
      class="d-flex flex-nowrap justify-content-start"
      @click="onClick"
    >
      <slot name="image"></slot>
      {{ title }}
      <component :is="iconChevronUp" class="icon-expand" />
    </b-button>
    <b-collapse :id="id" visible>
      <slot></slot>
    </b-collapse>
  </div>
</template>
<script>
import iconChevronUp from '@carbon/icons-vue/es/chevron--up/20';

export default {
  name: 'Collapse',
  props: {
    id: {
      type: String,
      default: null,
    },
    title: {
      type: String,
      default: null,
    },
  },
  data() {
    return {
      opened: true,
      iconChevronUp: iconChevronUp,
    };
  },
  methods: {
    onClick() {
      this.opened = !this.opened;
      this.$emit('opened', this.opened);
    },
  },
};
</script>