-
Notifications
You must be signed in to change notification settings - Fork 966
/
Alert.vue
58 lines (57 loc) · 1.46 KB
/
Alert.vue
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
<template>
<b-alert :variant="galaxyKwdToBootstrap" :show="showP" v-bind="$props">
<slot> {{ message }} </slot>
</b-alert>
</template>
<script>
export default {
props: {
message: {
type: String,
default: ""
},
status: {
type: String,
default: ""
},
variant: {
type: String,
default: "done"
},
dismissible: Boolean,
dismissLabel: String,
show: [Boolean, Number],
fade: Boolean
},
computed: {
galaxyKwdToBootstrap() {
let variant = this.variant;
if (this.status !== "") {
variant = this.status;
}
const galaxyKwdToBoostrapDict = {
done: "success",
info: "info",
warning: "warning",
error: "danger"
};
if (variant in galaxyKwdToBoostrapDict) {
return galaxyKwdToBoostrapDict[variant];
} else {
return variant;
}
},
showP() {
if (this.show) {
// explicit show prop overwrites all other checks
return this.show;
} else if (this.message !== "" || this.$slots.default) {
// show if data is passed
return true;
} else {
return false;
}
}
}
};
</script>