Blame view

src/components/card/card.vue 2.07 KB
15bae144   梁灏   add Card component
1
2
  <template>
      <div :class="classes">
743d0278   梁灏   update Card
3
4
          <div :class="headClasses" v-if="showHead"><slot name="title"></slot></div>
          <div :class="extraClasses" v-if="showExtra"><slot name="extra"></slot></div>
fb8a7b3f   young   style(card): feat...
5
          <div :class="bodyClasses" :style="bodyStyles"><slot></slot></div>
15bae144   梁灏   add Card component
6
7
8
9
      </div>
  </template>
  <script>
      const prefixCls = 'ivu-card';
19d41352   梁灏   update Card
10
      const defaultPadding = 16;
15bae144   梁灏   add Card component
11
12
  
      export default {
6e2f40ea   Rijn   assign names to C...
13
14
          name: 'Card',
  
15bae144   梁灏   add Card component
15
16
17
18
19
20
21
22
23
24
25
26
          props: {
              bordered: {
                  type: Boolean,
                  default: true
              },
              disHover: {
                  type: Boolean,
                  default: false
              },
              shadow: {
                  type: Boolean,
                  default: false
fb8a7b3f   young   style(card): feat...
27
              },
19d41352   梁灏   update Card
28
29
30
31
              padding: {
                  type: Number,
                  default: defaultPadding
              }
15bae144   梁灏   add Card component
32
33
34
35
36
          },
          data () {
              return {
                  showHead: true,
                  showExtra: true
b0893113   jingsam   :art: add eslint
37
              };
15bae144   梁灏   add Card component
38
39
40
41
42
43
44
45
46
47
          },
          computed: {
              classes () {
                  return [
                      `${prefixCls}`,
                      {
                          [`${prefixCls}-bordered`]: this.bordered && !this.shadow,
                          [`${prefixCls}-dis-hover`]: this.disHover || this.shadow,
                          [`${prefixCls}-shadow`]: this.shadow
                      }
b0893113   jingsam   :art: add eslint
48
                  ];
15bae144   梁灏   add Card component
49
50
51
52
53
54
55
56
57
              },
              headClasses () {
                  return `${prefixCls}-head`;
              },
              extraClasses () {
                  return `${prefixCls}-extra`;
              },
              bodyClasses () {
                  return `${prefixCls}-body`;
fb8a7b3f   young   style(card): feat...
58
59
              },
              bodyStyles () {
19d41352   梁灏   update Card
60
                  if (this.padding !== defaultPadding) {
fb8a7b3f   young   style(card): feat...
61
                      return {
19d41352   梁灏   update Card
62
                          padding: `${this.padding}px`
ec4117cb   梁灏   tag add prop: name
63
                      };
19d41352   梁灏   update Card
64
65
                  } else {
                      return '';
fb8a7b3f   young   style(card): feat...
66
                  }
15bae144   梁灏   add Card component
67
68
              }
          },
a8cb711c   huixisheng   Support Card
69
          mounted () {
743d0278   梁灏   update Card
70
71
              this.showHead = this.$slots.title !== undefined;
              this.showExtra = this.$slots.extra !== undefined;
15bae144   梁灏   add Card component
72
          }
b0893113   jingsam   :art: add eslint
73
74
      };
  </script>