Blame view

src/components/collapse/panel.vue 1.68 KB
49306c7a   梁灏   add Collapse comp...
1
2
3
4
5
6
  <template>
      <div :class="itemClasses">
          <div :class="headerClasses" @click="toggle">
              <Icon type="arrow-right-b"></Icon>
              <slot></slot>
          </div>
b80c48ff   Aresn   Collapse support ...
7
8
9
10
11
          <collapse-transition>
              <div :class="contentClasses" v-show="isActive">
                  <div :class="boxClasses"><slot name="content"></slot></div>
              </div>
          </collapse-transition>
49306c7a   梁灏   add Collapse comp...
12
13
14
      </div>
  </template>
  <script>
b923c818   梁灏   update Tree
15
      import Icon from '../icon/icon.vue';
b80c48ff   Aresn   Collapse support ...
16
      import CollapseTransition from '../base/collapse-transition';
49306c7a   梁灏   add Collapse comp...
17
18
19
      const prefixCls = 'ivu-collapse';
  
      export default {
34ee7b4a   梁灏   support Tree & ad...
20
          name: 'Panel',
b80c48ff   Aresn   Collapse support ...
21
          components: { Icon, CollapseTransition },
49306c7a   梁灏   add Collapse comp...
22
          props: {
a190ce84   梁灏   support Collapse
23
              name: {
49306c7a   梁灏   add Collapse comp...
24
25
26
27
28
                  type: String
              }
          },
          data () {
              return {
a190ce84   梁灏   support Collapse
29
                  index: 0, // use index for default when name is null
49306c7a   梁灏   add Collapse comp...
30
                  isActive: false
b0893113   jingsam   :art: add eslint
31
              };
49306c7a   梁灏   add Collapse comp...
32
33
34
35
36
37
38
39
          },
          computed: {
              itemClasses () {
                  return [
                      `${prefixCls}-item`,
                      {
                          [`${prefixCls}-item-active`]: this.isActive
                      }
b0893113   jingsam   :art: add eslint
40
                  ];
49306c7a   梁灏   add Collapse comp...
41
42
43
44
              },
              headerClasses () {
                  return `${prefixCls}-header`;
              },
a190ce84   梁灏   support Collapse
45
              contentClasses () {
49306c7a   梁灏   add Collapse comp...
46
47
48
49
50
51
52
53
                  return `${prefixCls}-content`;
              },
              boxClasses () {
                  return `${prefixCls}-content-box`;
              }
          },
          methods: {
              toggle () {
49306c7a   梁灏   add Collapse comp...
54
                  this.$parent.toggle({
a190ce84   梁灏   support Collapse
55
                      name: this.name || this.index,
49306c7a   梁灏   add Collapse comp...
56
57
58
59
                      isActive: this.isActive
                  });
              }
          }
b0893113   jingsam   :art: add eslint
60
61
      };
  </script>