vue-nt-toast 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -6
- package/package.json +1 -1
- package/src/index.js +5 -2
- package/src/toast.js +4 -1
- package/src/toast.scss +114 -11
package/README.md
CHANGED
|
@@ -63,19 +63,21 @@ app.use(NtToast, defaultOptions)
|
|
|
63
63
|
|
|
64
64
|
```javascript
|
|
65
65
|
// get Proxy in current instance
|
|
66
|
-
import { getCurrentInctance } from 'vue';
|
|
67
|
-
|
|
66
|
+
// import { getCurrentInctance } from 'vue';
|
|
67
|
+
import { inject } from 'vue'
|
|
68
68
|
// composition api or setup
|
|
69
|
-
const { proxy } = getCurrentInstance();
|
|
69
|
+
// const { proxy } = getCurrentInstance();
|
|
70
|
+
|
|
71
|
+
const toast = inject('$ntToast')
|
|
70
72
|
```
|
|
71
73
|
### Creating toast (Show toast)
|
|
72
74
|
```javascript
|
|
73
75
|
// show success toast
|
|
74
|
-
|
|
76
|
+
toast.show('success', ..., ...)
|
|
75
77
|
|
|
76
78
|
// show another type
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
toast.show('info', ..., ...)
|
|
80
|
+
toast.show('danger', ..., ...)
|
|
79
81
|
```
|
|
80
82
|
---
|
|
81
83
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -12,7 +12,8 @@ const defaultOptions = {
|
|
|
12
12
|
clickToClose: true,
|
|
13
13
|
displayOnTop: false,
|
|
14
14
|
snackbar: false,
|
|
15
|
-
freeze: true
|
|
15
|
+
freeze: true,
|
|
16
|
+
transition: 'swing'
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
let extendOptions = {}
|
|
@@ -23,6 +24,8 @@ const setOption = option => {
|
|
|
23
24
|
export default {
|
|
24
25
|
install(app, options = {}) {
|
|
25
26
|
extendOptions = setOption(options)
|
|
26
|
-
app.config.globalProperties.$
|
|
27
|
+
app.config.globalProperties.$ntToast = new ToastBoard(extendOptions)
|
|
28
|
+
|
|
29
|
+
app.provide('$ntToast', new ToastBoard(extendOptions))
|
|
27
30
|
}
|
|
28
31
|
}
|
package/src/toast.js
CHANGED
|
@@ -22,6 +22,7 @@ class Toast {
|
|
|
22
22
|
this.toast = document.createElement('div')
|
|
23
23
|
this.toast.classList.add('toast', 'swing')
|
|
24
24
|
// const contents = document.createElement('div')
|
|
25
|
+
|
|
25
26
|
const contents = this.setContents()
|
|
26
27
|
this.setIcon()
|
|
27
28
|
if (this.options.round) {
|
|
@@ -52,11 +53,13 @@ class Toast {
|
|
|
52
53
|
// clearTimeout(this.interval)
|
|
53
54
|
// })
|
|
54
55
|
// }
|
|
56
|
+
|
|
57
|
+
|
|
55
58
|
setIcon() {
|
|
56
59
|
if (!this.options.useIcon || this.options.theme === 'line') return
|
|
57
60
|
this.icon = document.createElement('div')
|
|
58
61
|
this.icon.classList.add('toast-icon')
|
|
59
|
-
const iconClass = statusIcon[this.type] || '
|
|
62
|
+
const iconClass = statusIcon[this.type] || 'exclamation-circle'
|
|
60
63
|
this.icon.innerHTML = `<i class="fa fa-${iconClass}" />`
|
|
61
64
|
// this.icon.innerHTML = `<img src="./icons/success.svg" />`
|
|
62
65
|
// this.toast.appendChild(this.icon)
|
package/src/toast.scss
CHANGED
|
@@ -228,17 +228,24 @@ $colors: (
|
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
231
|
+
&:is(.top-left, .bottom-left) .toast {
|
|
232
|
+
animation-name: swing-reverse-off;
|
|
233
|
+
&.swing {
|
|
234
|
+
animation-name: swing-reverse;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
&:is(.top-center, .top-full) .toast {
|
|
238
|
+
animation-name: pull-down-off;
|
|
239
|
+
&.swing {
|
|
240
|
+
animation-name: pull-down;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
&:is(.bottom-center, .bottom-full) .toast {
|
|
244
|
+
animation-name: pull-up-off;
|
|
245
|
+
&.swing {
|
|
246
|
+
animation-name: pull-up;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
242
249
|
}
|
|
243
250
|
@keyframes swing {
|
|
244
251
|
0% {
|
|
@@ -273,4 +280,100 @@ $colors: (
|
|
|
273
280
|
//opacity: 0;
|
|
274
281
|
}
|
|
275
282
|
|
|
283
|
+
}
|
|
284
|
+
@keyframes swing-reverse {
|
|
285
|
+
0% {
|
|
286
|
+
transform: translateX(-300px);
|
|
287
|
+
opacity: 0;
|
|
288
|
+
}
|
|
289
|
+
25% {
|
|
290
|
+
transform: translateX(-20px);
|
|
291
|
+
}
|
|
292
|
+
75% {
|
|
293
|
+
transform: translateX(10px);
|
|
294
|
+
opacity: 0.95;
|
|
295
|
+
}
|
|
296
|
+
100% {
|
|
297
|
+
transform: translateX(0px);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
@keyframes swing-reverse-off {
|
|
301
|
+
0% {
|
|
302
|
+
transform: translateX(0px);
|
|
303
|
+
}
|
|
304
|
+
25% {
|
|
305
|
+
transform: translateX(10px);
|
|
306
|
+
//opacity: 0.95;
|
|
307
|
+
}
|
|
308
|
+
75% {
|
|
309
|
+
transform: translateX(-20px);
|
|
310
|
+
}
|
|
311
|
+
100% {
|
|
312
|
+
transform: translateX(-300px);
|
|
313
|
+
//opacity: 0;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
@keyframes pull-up {
|
|
317
|
+
0% {
|
|
318
|
+
transform: translateY(30px);
|
|
319
|
+
opacity: 0;
|
|
320
|
+
}
|
|
321
|
+
25% {
|
|
322
|
+
transform: translateY(10px);
|
|
323
|
+
}
|
|
324
|
+
75% {
|
|
325
|
+
transform: translateY(-5px);
|
|
326
|
+
opacity: 0.95;
|
|
327
|
+
}
|
|
328
|
+
100% {
|
|
329
|
+
transform: translateY(0px);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
@keyframes pull-up-off {
|
|
333
|
+
0% {
|
|
334
|
+
transform: translateY(0px);
|
|
335
|
+
}
|
|
336
|
+
25% {
|
|
337
|
+
transform: translateY(5px);
|
|
338
|
+
//opacity: 0.95;
|
|
339
|
+
}
|
|
340
|
+
75% {
|
|
341
|
+
transform: translateY(-10px);
|
|
342
|
+
}
|
|
343
|
+
100% {
|
|
344
|
+
transform: translateY(-30px);
|
|
345
|
+
//opacity: 0;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
@keyframes pull-down {
|
|
349
|
+
0% {
|
|
350
|
+
transform: translateY(-30px);
|
|
351
|
+
opacity: 0;
|
|
352
|
+
}
|
|
353
|
+
25% {
|
|
354
|
+
transform: translateY(-10px);
|
|
355
|
+
}
|
|
356
|
+
75% {
|
|
357
|
+
transform: translateY(5px);
|
|
358
|
+
opacity: 0.95;
|
|
359
|
+
}
|
|
360
|
+
100% {
|
|
361
|
+
transform: translateY(0px);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
@keyframes pull-down-off {
|
|
365
|
+
0% {
|
|
366
|
+
transform: translateY(0px);
|
|
367
|
+
}
|
|
368
|
+
25% {
|
|
369
|
+
transform: translateY(-5px);
|
|
370
|
+
//opacity: 0.95;
|
|
371
|
+
}
|
|
372
|
+
75% {
|
|
373
|
+
transform: translateY(10px);
|
|
374
|
+
}
|
|
375
|
+
100% {
|
|
376
|
+
transform: translateY(30px);
|
|
377
|
+
//opacity: 0;
|
|
378
|
+
}
|
|
276
379
|
}
|