Skip to content

Commit 8e58e9d

Browse files
committed
Further Notify work
1 parent 8c816b5 commit 8e58e9d

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

dev/components/components/notify.vue

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
</div>
2828
<div>
2929
<q-btn round small color="tertiary" @click="alertAsMethod('center')">
30-
<q-icon name="arrow_upward" />
30+
<q-icon name="fullscreen_exit" />
3131
</q-btn>
3232
</div>
3333
<div>
@@ -84,12 +84,13 @@ export default {
8484
},
8585
methods: {
8686
alertAsMethod (position) {
87-
const { color, icon, message } = alerts[Math.floor(Math.random(5) * 10) % 4]
87+
const { color, icon, message } = alerts[ Math.floor(Math.random(5) * 10) % 4 ]
8888
this.$q.notify({
8989
color,
9090
icon,
9191
message,
92-
position: position
92+
position,
93+
timeout: Math.random() * 5000 + 3000
9394
})
9495
}
9596
}
@@ -123,6 +124,7 @@ export default {
123124
display inline-block
124125
margin 10px 10px 0
125126
transition all 1s
127+
z-index 9999 // $z-max
126128
127129
.q-notification-
128130
&top-enter,
@@ -141,31 +143,38 @@ export default {
141143
&bottom-enter, &bottom-leave-to
142144
opacity 0
143145
transform translateY(50px)
146+
z-index 9998 // $z-max - 1
144147
145148
&center-leave-active,
146149
&top-leave-active
147150
position absolute
148151
top 0
149152
margin 10px 0
153+
z-index 9998 // $z-max - 1
150154
&right-leave-active,
151155
&top-right-leave-active
152156
position absolute
153157
right 0
158+
z-index 9998 // $z-max - 1
154159
&left-leave-active,
155160
&top-left-leave-active
156161
position absolute
157162
left 0
163+
z-index 9998 // $z-max - 1
158164
159165
&bottom-leave-active
160166
position absolute
161167
bottom 0
162168
margin 10px 0
169+
z-index 9998 // $z-max - 1
163170
&bottom-right-leave-active
164171
position absolute
165172
bottom 0
166173
right 0
174+
z-index 9998 // $z-max - 1
167175
&bottom-left-leave-active
168176
position absolute
169177
bottom 0
170178
left 0
179+
z-index 9998 // $z-max - 1
171180
</style>

src/plugins/notify.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,29 @@ export default {
3232
}
3333
},
3434
methods: {
35+
validate (notif) {
36+
if (
37+
![
38+
'center', 'left', 'right', 'top', 'bottom',
39+
'top-left', 'top-right', 'bottom-left', 'bottom-right'
40+
].includes(notif.position)
41+
) {
42+
console.error(`Notify: wrong position: ${notif.position}`)
43+
return false
44+
}
45+
46+
return true
47+
},
3548
add (notif) {
49+
if (!this.validate(notif)) { return }
50+
3651
notif.__uid = uid()
37-
console.log(notif.position)
3852
const action = notif.position.indexOf('top') > -1 ? 'unshift' : 'push'
3953
this.notifs[notif.position][action](notif)
54+
55+
notif.timeout && setTimeout(() => {
56+
this.remove(notif)
57+
}, notif.timeout)
4058
},
4159
remove (notif) {
4260
const index = this.notifs[notif.position].indexOf(notif)

0 commit comments

Comments
 (0)