forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQAlert.js
More file actions
94 lines (91 loc) · 2.36 KB
/
QAlert.js
File metadata and controls
94 lines (91 loc) · 2.36 KB
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
import QIcon from '../icon/QIcon.js'
import QBtn from '../btn/QBtn.js'
export default {
name: 'QAlert',
props: {
type: {
type: String,
validator: v => ['positive', 'negative', 'warning', 'info'].includes(v)
},
color: {
type: String,
default: 'negative'
},
textColor: String,
message: String,
detail: String,
icon: String,
avatar: String,
actions: Array
},
computed: {
computedIcon () {
return this.icon
? this.icon
: this.$q.icon.type[this.type || this.color]
},
classes () {
return `bg-${this.type || this.color} text-${this.textColor || 'white'}`
}
},
render (h) {
const
side = [],
detail = this.$slots.detail || this.detail
if (this.avatar) {
side.push(
h('img', {
staticClass: 'avatar',
attrs: { src: this.avatar }
})
)
}
else if (this.icon || this.type) {
side.push(
h(QIcon, {
props: { name: this.computedIcon }
})
)
}
return h('div', [
h('div', {
staticClass: 'q-alert row no-wrap shadow-2',
'class': this.classes
}, [
side.length
? h('div', { staticClass: 'q-alert-side col-auto row flex-center' }, side)
: null,
h('div', {
staticClass: 'q-alert-content col self-center'
}, [
h('div', this.$slots.default || this.message),
detail ? h('div', { staticClass: 'q-alert-detail' }, [ detail ]) : null
]),
this.actions && this.actions.length
? h('div', {
staticClass: 'q-alert-actions col-auto gutter-xs column flex-center'
},
this.actions.map(action =>
h('div', { staticClass: 'full-width' }, [
h(QBtn, {
staticClass: 'full-width',
props: {
flat: true,
dense: true,
align: 'left',
icon: action.icon,
label: action.closeBtn === true
? (typeof action.label === 'string' ? action.label : this.$q.i18n.label.close)
: action.label
},
on: {
click: () => action.handler()
}
})
])
))
: null
])
])
}
}