File tree Expand file tree Collapse file tree 3 files changed +75
-1
lines changed
Expand file tree Collapse file tree 3 files changed +75
-1
lines changed Original file line number Diff line number Diff line change 11<template >
22 <div id =" app" >
33 <NavBar />
4+ <NotificationContainer />
45 <router-view :key =" $route.fullPath" />
56 </div >
67</template >
78
89<script >
910import NavBar from ' @/components/NavBar.vue'
11+ import NotificationContainer from ' @/components/NotificationContainer.vue'
1012
1113export default {
1214 components: {
13- NavBar
15+ NavBar,
16+ NotificationContainer
1417 }
1518}
1619 </script >
Original file line number Diff line number Diff line change 1+ <template >
2+ <div class =" notification-bar" :class =" notificationTypeClass" >
3+ <p >{{ notification.message }}</p >
4+ </div >
5+ </template >
6+
7+ <script >
8+ import { mapActions } from ' vuex'
9+
10+ export default {
11+ props: {
12+ notification: {
13+ type: Object ,
14+ required: true
15+ }
16+ },
17+ data () {
18+ return {
19+ timeout: null
20+ }
21+ },
22+ mounted () {
23+ this .timeout = setTimeout (() => this .remove (this .notification ), 5000 )
24+ },
25+ beforeDestroy () {
26+ clearTimeout (this .timeout )
27+ },
28+ computed: {
29+ notificationTypeClass () {
30+ return ` -text-${ this .notification .type } `
31+ }
32+ },
33+ methods: mapActions (' notification' , [' remove' ])
34+ }
35+ </script >
36+
37+ <style scoped>
38+ .notification-bar {
39+ margin : 1em 0 1em ;
40+ }
41+ </style >
Original file line number Diff line number Diff line change 1+ <template >
2+ <div class =" notification-container" >
3+ <NotificationBar
4+ v-for =" notification in notifications"
5+ :key =" notification.id"
6+ :notification =" notification"
7+ />
8+ </div >
9+ </template >
10+
11+ <script >
12+ import NotificationBar from ' @/components/NotificationBar.vue'
13+ import { mapState } from ' vuex'
14+
15+ export default {
16+ components: {
17+ NotificationBar
18+ },
19+ computed: mapState (' notification' , [' notifications' ])
20+ }
21+ </script >
22+
23+ <style scoped>
24+ .notification-container {
25+ position : fixed ;
26+ bottom : 0 ;
27+ right : 0 ;
28+ padding-right : 40px ;
29+ }
30+ </style >
You can’t perform that action at this time.
0 commit comments