-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNotification.vue
68 lines (62 loc) · 1.21 KB
/
Notification.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
59
60
61
62
63
64
65
66
67
68
<template>
<transition name="slide-down">
<div class="notification" v-if="notification">
<p class="notification__message fs-12">{{ notification }}</p>
</div>
</transition>
</template>
<script>
export default {
data() {
return {
timeout: null
}
},
watch: {
notification(value) {
if (value) {
clearTimeout(this.timeout);
this.timeout = setTimeout(() => {
this.$store.commit('utils/setNotification', null);
}, 3000);
}
}
},
computed: {
notification() {
return this.$store.state.utils.notification;
}
}
}
</script>
<style lang="scss" scoped>
.notification {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
z-index: 1002;
}
.notification__message {
background-color: color(primary);
padding: 1rem;
margin: 0;
color: white;
}
.slide-down-enter-active {
animation: slide-down 0.3s;
}
.slide-down-leave-active {
animation: slide-down 0.3s reverse;
}
@keyframes slide-down {
from {
transform: translateY(100%);
opacity: 0;
}
to {
transform: translateY(0);
opacity: 1;
}
}
</style>