File tree 4 files changed +151
-0
lines changed
4 files changed +151
-0
lines changed Original file line number Diff line number Diff line change
1
+ node_modules
Original file line number Diff line number Diff line change
1
+ # Notification
2
+
3
+ Notification component for Vue Bulma.
4
+
5
+ ## Badges
6
+
7
+ ![ ] ( https://img.shields.io/badge/license-MIT-blue.svg )
8
+ ![ ] ( https://img.shields.io/badge/status-stable-green.svg )
9
+
10
+ ---
11
+
12
+ > [ fundon.me] ( https://fundun.me )   ;· ;  ;
13
+ > GitHub [ @fundon ] ( https://github.com/fundon )   ;· ;  ;
14
+ > Twitter [ @_ fundon] ( https://twitter.com/_fundon )
15
+
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " vue-bulma-notification" ,
3
+ "version" : " 1.0.0" ,
4
+ "description" : " Notification component for Vue Bulma" ,
5
+ "main" : " src/Notification.vue" ,
6
+ "devDependencies" : {
7
+ "bulma" : " 0.1.0" ,
8
+ "vue" : " 1.0.26"
9
+ },
10
+ "scripts" : {
11
+ "test" : " echo \" Error: no test specified\" && exit 1"
12
+ },
13
+ "repository" : " git+https://github.com/vue-bulma/notification.git" ,
14
+ "keywords" : [
15
+ " vue" ,
16
+ " bulma" ,
17
+ " vue-bulma" ,
18
+ " vue-bulma-component" ,
19
+ " vue-bulma-notification" ,
20
+ " notification"
21
+ ],
22
+ "author" :
" Fangdun Cai <[email protected] >" ,
23
+ "license" : " MIT"
24
+ }
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <div :class =" ['notification', 'animated', type ? `is-${type}` : '']" :transition =" transition" transition-mode =" in-out" >
3
+ <button class =" delete touchable" @click =" close()" ></button >
4
+ <div class =" title is-5" v-if =" title" >{{ title }}</div >
5
+ {{ message }}
6
+ </div >
7
+ </template >
8
+
9
+ <script >
10
+ import Vue from ' vue'
11
+
12
+ export default {
13
+
14
+ props: {
15
+ type: String ,
16
+ title: String ,
17
+ message: String ,
18
+ direction: {
19
+ type: String ,
20
+ default: ' right'
21
+ },
22
+ duration: {
23
+ type: Number ,
24
+ default: 4500
25
+ },
26
+ container: {
27
+ type: String ,
28
+ default: ' .notifications'
29
+ }
30
+ },
31
+
32
+ data () {
33
+ return {
34
+ $_parent_: null
35
+ }
36
+ },
37
+
38
+ created () {
39
+ let $parent = this .$parent
40
+ if (! $parent) {
41
+ let parent = document .querySelector (this .container )
42
+ if (! parent) {
43
+ // Lazy creating `div.notifications` container.
44
+ parent = document .createElement (' div' )
45
+ parent .classList .add (this .container .replace (' .' , ' ' ))
46
+ const Notifications = Vue .extend ()
47
+ $parent = new Notifications ({
48
+ el: parent
49
+ }).$appendTo (document .body )
50
+ }
51
+ // Hacked.
52
+ this .$_parent_ = parent .__vue__
53
+ }
54
+ },
55
+
56
+ compiled () {
57
+ if (this .$_parent_ ) {
58
+ this .$appendTo (this .$_parent_ .$el )
59
+ delete this .$_parent_
60
+ }
61
+ },
62
+
63
+ ready () {
64
+ if (this .duration > 0 ) {
65
+ this .timer = setTimeout (() => this .close (), this .duration )
66
+ }
67
+ },
68
+
69
+ computed: {
70
+ transition () {
71
+ return ` bounce-${ this .direction } `
72
+ }
73
+ },
74
+
75
+ methods: {
76
+ close () {
77
+ clearTimeout (this .timer )
78
+ this .$destroy (true )
79
+ }
80
+ }
81
+ }
82
+ </script >
83
+
84
+ <style lang="scss">
85
+ @import ' ~bulma/sass/utilities/variables' ;
86
+ @import ' ~bulma/sass/utilities/mixins' ;
87
+
88
+ .notifications {
89
+ position : fixed ;
90
+ top : 50px ;
91
+ right : 0 ;
92
+ z-index : 1024 + 233 ;
93
+ pointer-events : none ;
94
+
95
+ @include tablet () {
96
+ max-width : 320px ;
97
+ }
98
+
99
+ .notification {
100
+ margin : 20px ;
101
+ }
102
+ }
103
+
104
+ .notification {
105
+ position : relative ;
106
+ min-width : 240px ;
107
+ backface-visibility : hidden ;
108
+ transform : translate3d (0 , 0 , 0 );
109
+ pointer-events : all ;
110
+ }
111
+ </style >
You can’t perform that action at this time.
0 commit comments