Skip to content

Commit 04a7110

Browse files
committed
Width can now set custom units. Timeout for notification hide can now be custom
1 parent 8f155fb commit 04a7110

File tree

7 files changed

+38
-17
lines changed

7 files changed

+38
-17
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@ npm install vue-notify-me --save
2424
| Properties | Type | Values |
2525
| :--------------- | :------- | :--------- |
2626
| `event-bus` | Object | <b>Central event Bus </b>|
27-
| `event-show` (not required) | String | <b>Default </b> 'notify-me'|
28-
| `event-hide` (not required) | String | <b>Default </b> 'hide-notify-me'|
29-
| `close` (not required) | String | <b>Default </b>'bulma', options: bootstrap or any other class for the closing icon|
27+
| `event-show` (not required) | String | <b>Default </b> `notify-me`|
28+
| `event-hide` (not required) | String | <b>Default </b> `hide-notify-me`|
29+
| `close` (not required) | String | <b>Default </b>`bulma`, options: bootstrap or any other class for the closing icon|
3030
| `permanent` (not required) | Bool | <b>Default </b>false|
31-
| `container` (not required) | String | <b>Default </b>'notification', (Class for the notification container)|
32-
| `status` (not required) | String | <b>Default </b>'is-success', (Class for the notification status)|
33-
| `width` (not required) | String | <b>Default </b>'350' |
31+
| `container` (not required) | String | <b>Default </b>`notification`, (Class for the notification container)|
32+
| `status` (not required) | String | <b>Default </b>`is-success`, (Class for the notification status)|
33+
| `width` (not required) | String | <b>Default </b>`350px`. It's **mandatory** to set the **unit** for the width. For example: `rem`, `em`, `px` |
34+
| `timeout` (not required) | Number | <b>Default `4000`</b>. If notification is not `permanent` you can set the timeout for it |
3435

3536
## Examples
3637

demo/App.vue

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@
9999
</div>
100100
</div>
101101
</div>
102+
<div class="column">
103+
<div class="field">
104+
<label class="label">Timeout</label>
105+
<div class="control">
106+
<input v-model="timeout" class="input" type="number">
107+
</div>
108+
</div>
109+
</div>
102110
</div>
103111
<div class="columns">
104112
<div class="column">
@@ -139,7 +147,7 @@
139147
</footer>
140148
<notify-me
141149
:event-bus="bus">
142-
<template slot="content" scope="{data}">
150+
<template slot="content" slot-scope="{data}">
143151
<div style="width: 100%; word-break: break-all; text-align: left">
144152
<h4><b>{{data.title}}</b></h4>
145153
<p style="margin: 0">{{data.text}}</p>
@@ -174,6 +182,7 @@
174182
status: 'is-success',
175183
permanent: false,
176184
text: 'Coded slow but effective',
185+
timeout: 4000,
177186
bus
178187
}
179188
},
@@ -182,6 +191,7 @@
182191
this.bus.$emit('notify-me', {
183192
permanent: this.permanent,
184193
status: this.status,
194+
timeout: parseInt(this.timeout),
185195
data: {
186196
title: 'The pygmy team :)',
187197
text: this.text

dist/build.js

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

dist/build.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.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-notify-me",
3-
"version": "1.0.6",
3+
"version": "1.1.0",
44
"description": "Stackable notification Alert for Vue",
55
"main": "src/index.js",
66
"repository": {

src/Notification.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
enter-active-class="animated quick fadeInRight"
44
leave-active-class="animated quick fadeOutRight"
55
>
6-
<div v-if="show" :class="[container,status, 'notify-me']" :style="{ width: width + 'px' }">
6+
<div v-if="show" :class="[container,status, 'notify-me']" :style="{ width: width }">
77
<slot name="content"></slot>
88
<button v-if="close === 'bulma'" class="delete" @click="hideMe"></button>
99
<button v-else-if="close === 'bootstrap'" type="button" class="close" aria-label="Close" @click="hideMe">
@@ -30,8 +30,12 @@
3030
default: 'alert-success'
3131
},
3232
width: {
33+
type: String,
34+
default: '350px'
35+
},
36+
timeout: {
3337
type: Number,
34-
default: 350
38+
default: 4000
3539
}
3640
3741
},
@@ -49,7 +53,7 @@
4953
if (!this.permanent) {
5054
setTimeout(() => {
5155
this.hideMe();
52-
}, 4000)
56+
}, this.timeout)
5357
}
5458
5559
}

src/Notify.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
:container="item.container"
66
:status="item.status"
77
:width="item.width"
8+
:timeout="item.timeout"
89
:close="item.close"
910
:content="item.content"
1011
@hide="hideChild(key)">
@@ -39,8 +40,12 @@
3940
default: 'is-success'
4041
},
4142
width: {
43+
type: String,
44+
default: '350px'
45+
},
46+
timeout: {
4247
type: Number,
43-
default: 350
48+
default: 4000
4449
},
4550
// central event bus
4651
eventBus: {
@@ -68,7 +73,8 @@
6873
content: obj.data,
6974
container: obj.container || this.container,
7075
status: obj.status || this.status,
71-
width: obj.width || this.width
76+
width: obj.width || this.width,
77+
timeout: obj.timeout || this.timeout
7278
};
7379
this.list.push(item);
7480
},

0 commit comments

Comments
 (0)