forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPositioning.vue
More file actions
100 lines (94 loc) · 3.41 KB
/
Positioning.vue
File metadata and controls
100 lines (94 loc) · 3.41 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
95
96
97
98
99
100
<template>
<div class="q-pa-md q-gutter-y-sm column items-center">
<div>
<div class="row q-gutter-sm">
<q-btn round size="sm" color="secondary" @click="showNotif('top-left')">
<q-icon name="arrow_back" class="rotate-45" />
</q-btn>
<q-btn round size="sm" color="accent" @click="showNotif('top')">
<q-icon name="arrow_upward" />
</q-btn>
<q-btn round size="sm" color="secondary" @click="showNotif('top-right')">
<q-icon name="arrow_upward" class="rotate-45" />
</q-btn>
</div>
</div>
<div>
<div class="row q-gutter-sm">
<div>
<q-btn round size="sm" color="accent" @click="showNotif('left')">
<q-icon name="arrow_back" />
</q-btn>
</div>
<div>
<q-btn round size="sm" color="accent" @click="showNotif('center')">
<q-icon name="fullscreen_exit" />
</q-btn>
</div>
<div>
<q-btn round size="sm" color="accent" @click="showNotif('right')">
<q-icon name="arrow_forward" />
</q-btn>
</div>
</div>
</div>
<div>
<div class="row q-gutter-sm">
<div>
<q-btn round size="sm" color="secondary" @click="showNotif('bottom-left')">
<q-icon name="arrow_forward" class="rotate-135" />
</q-btn>
</div>
<div>
<q-btn round size="sm" color="accent" @click="showNotif('bottom')">
<q-icon name="arrow_downward" />
</q-btn>
</div>
<div>
<q-btn round size="sm" color="secondary" @click="showNotif('bottom-right')">
<q-icon name="arrow_forward" class="rotate-45" />
</q-btn>
</div>
</div>
</div>
</div>
</template>
<script>
const alerts = [
{ color: 'negative', message: 'Woah! Danger! You are getting good at this!', icon: 'report_problem' },
{ message: 'You need to know about this!', icon: 'warning' },
{ message: 'Wow! Nice job!', icon: 'thumb_up' },
{ color: 'teal', message: 'Quasar is cool! Right?', icon: 'tag_faces' },
{ color: 'purple', message: 'Jim just pinged you', avatar: 'https://cdn.quasar.dev/img/boy-avatar.png' },
{ multiLine: true, message: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Hic quisquam non ad sit assumenda consequuntur esse inventore officia. Corrupti reiciendis impedit vel, fugit odit quisquam quae porro exercitationem eveniet quasi.' }
]
export default {
methods: {
showNotif (position) {
const { color, textColor, multiLine, icon, message, avatar } = alerts[ Math.floor(Math.random(alerts.length) * 10) % alerts.length ]
const random = Math.random() * 100
const twoActions = random > 70
const buttonColor = color ? 'white' : void 0
this.$q.notify({
color,
textColor,
icon: random > 30 ? icon : null,
message,
position,
avatar,
multiLine,
actions: twoActions
? [
{ label: 'Reply', color: buttonColor, handler: () => { /* console.log('wooow') */ } },
{ label: 'Dismiss', color: 'yellow', handler: () => { /* console.log('wooow') */ } }
]
: (random > 40
? [ { label: 'Reply', color: buttonColor, handler: () => { /* console.log('wooow') */ } } ]
: null
),
timeout: Math.random() * 5000 + 3000
})
}
}
}
</script>