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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161 | 18x
18x
18x
18x
18x
18x
18x
127x
127x
127x
7x
120x
7x
127x
| <template>
<component :is="tag" :class="['card',cardVariant,cardAlign,cardInverse]">
I <!-- Card Image Slot-->
<slot name="img" ref="img">
E <img v-if="img" :src="img" :alt="imgAlt" :class="['card-img', 'img-fluid']">
</slot>
<!-- Card Header-->
<component v-if="header || $slots['header']"
:is="headerTag"
:class="['card-header', headerVariant?('bg-'+headerVariant):'', headerClass]"
>
<slot name="header">
<div v-html="header"></div>
</slot>
</component>
<!--Show custom block when no-block prop is set-->
<template v-if="noBlock">
<slot></slot>
</template>
<!-- Card Standard Blocks-->
<div :class="blockClass" v-else>
<h4 v-if="title" :is="titleTag" class="card-title" v-html="title"></h4>
<h6 v-if="subTitle" :is="subTitleTag" class="card-subtitle mb-2 text-muted" v-html="subTitle"></h6>
<slot></slot>
</div>
<!-- Card Footer-->
<component v-if="footer || $slots['footer']"
:is="footerTag"
:class="['card-footer', footerVariant?('bg-'+footerVariant):'', footerClass]"
>
<slot name="footer">
<div v-html="footer"></div>
</slot>
</component>
</component>
</template>
<script>
export default {
computed: {
blockClass() {
return [
'card-block',
this.overlay ? 'card-img-overlay' : null
];
},
cardVariant() {
return this.variant ? `card-${this.variant}` : null;
},
cardInverse() {
if (this.overlay || this.inverse) {
return 'card-inverse';
}
// Auto inverse colored cards
if (this.inverse === null && this.variant && this.variant.length > 0 &&
this.variant.indexOf('outline') === -1) {
return 'card-inverse';
}
},
cardAlign() {
return this.align ? `text-${this.align}` : null;
}
},
props: {
align: {
type: String,
default: null
},
inverse: {
type: Boolean,
// It should remain null for auto inverse
default: null
},
variant: {
type: String,
default: null
},
tag: {
type: String,
default: 'div'
},
// Header
header: {
type: String,
default: null
},
headerVariant: {
type: String,
default: null
},
headerClass: {
type: [String, Array],
default: ''
},
headerTag: {
type: String,
default: 'div'
},
// Footer
footer: {
type: String,
default: null
},
footerVariant: {
type: String,
default: null
},
footerClass: {
type: [String, Array],
default: ''
},
footerTag: {
type: String,
default: 'div'
},
// Main block
title: {
type: String,
default: null
},
titleTag: {
type: String,
default: 'h4'
},
subTitle: {
type: String,
default: null
},
subTitleTag: {
type: String,
default: 'h6'
},
noBlock: {
type: Boolean,
default: false
},
// Image
img: {
type: String,
default: null
},
imgAlt: {
type: String,
default: null
},
overlay: {
type: Boolean,
default: false
}
}
};
</script>
|