Skip to content

Commit 5a8bf46

Browse files
committed
Add pointer cursor when hovering notifications
Add option to render a custom component Close notification when clicking on it
1 parent 5dc1394 commit 5a8bf46

14 files changed

+74
-35
lines changed

dist/vue-notifyjs.common.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* vue-notifyjs v0.1.3
2+
* vue-notifyjs v0.1.4
33
* (c) 2017-present cristij <joracristi@gmail.com>
44
* Released under the MIT License.
55
*/
@@ -31,6 +31,9 @@ var Notification = {
3131
default: function _default() {
3232
return new Date();
3333
}
34+
},
35+
component: {
36+
type: [Object, Function]
3437
}
3538
},
3639
data: function data() {
@@ -78,19 +81,21 @@ var Notification = {
7881
setTimeout(this.close, this.timeout);
7982
}
8083
},
81-
render: function render() {
82-
var h = arguments[0];
83-
84+
render: function render(h) {
85+
var componentName = this.component;
8486
return h(
8587
'div',
8688
{
89+
on: {
90+
'click': this.close
91+
},
8792
attrs: {
8893
'data-notify': 'container',
8994

9095
role: 'alert',
9196

9297
'data-notify-position': 'top-center' },
93-
'class': ['col-xs-11 col-sm-4 alert open ', { 'alert-with-icon': this.icon }, this.verticalAlign, this.horizontalAlign, this.alertType], style: this.customPosition },
98+
'class': ['alert open ', { 'alert-with-icon': this.icon }, this.verticalAlign, this.horizontalAlign, this.alertType], style: this.customPosition },
9499
[h(
95100
'button',
96101
{
@@ -116,7 +121,11 @@ var Notification = {
116121
{
117122
attrs: { 'data-notify': 'message' }
118123
},
119-
[this.message]
124+
[this.message !== undefined && this.message, this.component !== undefined && h(
125+
this.component,
126+
null,
127+
[]
128+
)]
120129
)]
121130
);
122131
}
@@ -166,7 +175,8 @@ var Notifications = {
166175
icon: notification.icon,
167176
message: notification.message,
168177
timeout: notification.timeout,
169-
type: notification.type
178+
type: notification.type,
179+
component: notification.component
170180
},
171181
key: notification, on: {
172182
'close': function close() {

dist/vue-notifyjs.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* vue-notifyjs v0.1.3
2+
* vue-notifyjs v0.1.4
33
* (c) 2017-present cristij <joracristi@gmail.com>
44
* Released under the MIT License.
55
*/
@@ -35,6 +35,9 @@ var Notification = {
3535
default: function _default() {
3636
return new Date();
3737
}
38+
},
39+
component: {
40+
type: [Object, Function]
3841
}
3942
},
4043
data: function data() {
@@ -82,19 +85,21 @@ var Notification = {
8285
setTimeout(this.close, this.timeout);
8386
}
8487
},
85-
render: function render() {
86-
var h = arguments[0];
87-
88+
render: function render(h) {
89+
var componentName = this.component;
8890
return h(
8991
'div',
9092
{
93+
on: {
94+
'click': this.close
95+
},
9196
attrs: {
9297
'data-notify': 'container',
9398

9499
role: 'alert',
95100

96101
'data-notify-position': 'top-center' },
97-
'class': ['col-xs-11 col-sm-4 alert open ', { 'alert-with-icon': this.icon }, this.verticalAlign, this.horizontalAlign, this.alertType], style: this.customPosition },
102+
'class': ['alert open ', { 'alert-with-icon': this.icon }, this.verticalAlign, this.horizontalAlign, this.alertType], style: this.customPosition },
98103
[h(
99104
'button',
100105
{
@@ -120,7 +125,11 @@ var Notification = {
120125
{
121126
attrs: { 'data-notify': 'message' }
122127
},
123-
[this.message]
128+
[this.message !== undefined && this.message, this.component !== undefined && h(
129+
this.component,
130+
null,
131+
[]
132+
)]
124133
)]
125134
);
126135
}
@@ -170,7 +179,8 @@ var Notifications = {
170179
icon: notification.icon,
171180
message: notification.message,
172181
timeout: notification.timeout,
173-
type: notification.type
182+
type: notification.type,
183+
component: notification.component
174184
},
175185
key: notification, on: {
176186
'close': function close() {

dist/vue-notifyjs.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vue-notifyjs.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/App.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
</div>
99
</template>
1010
<script>
11+
let msg = {
12+
functional:true,
13+
render(){
14+
return (<span> Welcome to <b>Paper Dashboard</b> - a beautiful freebie for every web developer</span>)
15+
}
16+
}
1117
import Vue from 'vue'
1218
import Notifications from '../src/index'
1319
import Notification from "../src/Notification";
@@ -17,11 +23,11 @@
1723
addNotification(verticalAlign='top', horizontalAlign='right'){
1824
this.$notify(
1925
{
20-
message: 'Welcome ',
2126
horizontalAlign: horizontalAlign,
2227
verticalAlign: verticalAlign,
2328
type: "info",
24-
timeout: 30000
29+
timeout: 30000,
30+
component: msg
2531
})
2632
}
2733
}

example/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Vue from 'vue'
22
import App from './App.vue'
3-
import '../themes/_now-ui.scss'
3+
import '../themes/now-ui.scss'
44

55
new Vue({
66
el: '#app',

src/Notification.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ export default {
2222
timestamp:{
2323
type: Date,
2424
default: ()=>new Date()
25+
},
26+
component: {
27+
type: [Object, Function]
2528
}
2629
},
2730
data () {
@@ -66,11 +69,12 @@ export default {
6669
setTimeout(this.close, this.timeout)
6770
}
6871
},
69-
render(){
70-
return (
71-
<div
72+
render(h){
73+
let componentName = this.component
74+
return (
75+
<div onClick={this.close}
7276
data-notify="container"
73-
class={['col-xs-11 col-sm-4 alert open ',{'alert-with-icon':this.icon}, this.verticalAlign, this.horizontalAlign, this.alertType]}
77+
class={['alert open ',{'alert-with-icon':this.icon}, this.verticalAlign, this.horizontalAlign, this.alertType]}
7478
role="alert"
7579
style={this.customPosition}
7680
data-notify-position="top-center">
@@ -85,8 +89,10 @@ export default {
8589
this.icon && <span data-notify="icon" class={['alert-icon', this.icon]}></span>
8690
}
8791
<span data-notify="message">
88-
{this.message}
89-
</span>
92+
{this.message!==undefined && this.message}
93+
{this.component!==undefined &&
94+
<this.component></this.component>}
95+
</span>
9096
</div>
9197
)
9298
}

src/Notifications.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export default {
3636
message={notification.message}
3737
timeout={notification.timeout}
3838
type={notification.type}
39+
component ={notification.component}
3940
key={notification} onClose={() => this.removeNotification(index)}/>
4041
}
4142
)

themes/default.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ button.close {
4545
font-size: 14px;
4646
z-index: 100;
4747
display: inline-block;
48-
position: fixed;
49-
transition: all 0.5s ease-in-out; }
48+
position: fixed !important;
49+
transition: all 0.5s ease-in-out;
50+
cursor: pointer; }
5051
.alert.center {
5152
left: 0px;
5253
right: 0px;

themes/default.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ button.close {
2626
font-size: 14px;
2727
z-index: 100;
2828
display: inline-block;
29-
position: fixed;
29+
position: fixed !important;
3030
transition: all 0.5s ease-in-out;
31+
cursor: pointer;
3132
&.center {
3233
left: 0px;
3334
right: 0px;

0 commit comments

Comments
 (0)