-
Notifications
You must be signed in to change notification settings - Fork 352
/
Copy pathBaseAlert.vue
54 lines (53 loc) · 1.27 KB
/
BaseAlert.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
<template>
<fade-transition>
<div v-if="visible" class="alert" :class="[`alert-${type}`, { 'alert-with-icon': withIcon }]" role="alert">
<slot v-if="!dismissible"></slot>
<div v-else class="container">
<slot></slot>
<slot name="dismiss-icon">
<button type="button" class="close" aria-label="Close" @click="dismissAlert">
<span aria-hidden="true">
<i class="tim-icons icon-simple-remove"></i>
</span>
</button>
</slot>
</div>
</div>
</fade-transition>
</template>
<script>
import { FadeTransition } from 'vue2-transitions';
export default {
name: 'base-alert',
components: {
FadeTransition
},
props: {
type: {
type: String,
default: 'default',
description: 'Alert type'
},
dismissible: {
type: Boolean,
default: false,
description: 'Whether alert is dismissible (closeable)'
},
withIcon: {
type: Boolean,
default: false,
description: 'Whether alert contains icon'
}
},
data() {
return {
visible: true
}
},
methods: {
dismissAlert() {
this.visible = false;
}
}
}
</script>