Skip to content

Commit b9e1c60

Browse files
committed
callback icon pack support added
1 parent e777299 commit b9e1c60

File tree

5 files changed

+35
-3
lines changed

5 files changed

+35
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,13 @@ fullWidth|Boolean|false|Enable Full Width
186186
fitToScreen|Boolean|false|Fits to Screen on Full Width
187187
className|String, Array|null|Custom css class name of the toast
188188
containerClass|String, Array|null|Custom css classes for toast container
189+
iconPack|String|'material'| Icon pack type to be used <br> **['material', 'fontawesome', 'mdi', 'custom-class', 'callback']**
189190
Icon|String, Object|null|Material icon name as string. [explained here](#icons-fire)
190191
type|String|'default'| Type of the Toast **['success', 'info', 'error']**
191192
theme|String|'toasted-primary'|Theme of the toast you prefer<br> **['toasted-primary', 'outline', 'bubble']**
192193
onComplete|Function|null|Trigger when toast is completed
193194
closeOnSwipe|Boolean|true|Closes the toast when the user swipes it
194195
singleton|Boolean|false| Only allows one toast at a time.
195-
iconPack|String|'material'| Icon pack type to be used <br> **['material', 'fontawesome', 'mdi', 'custom-class']**
196196

197197
### Methods
198198

dist/vue-toasted.js

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

dist/vue-toasted.min.js

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

examples/using-icons.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,20 @@ Vue.toasted.show(
3838
icon: {
3939
name: 'fal fa-check fa-spin fa-fw',
4040
}
41-
});
41+
});
42+
43+
44+
// Callback as icon pack
45+
Vue.use(VueToasted, {
46+
iconPack: 'callback'
47+
});
48+
49+
50+
Vue.toasted.show(
51+
'hello there, i am a toast !!', {
52+
// el is icon html element you can play with it
53+
icon: (el) => {
54+
el.innerText = 'my icon logic';
55+
return el;
56+
}
57+
});

src/js/show.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,14 @@ const createIcon = (options, toast) => {
244244
})
245245
}
246246

247+
break;
248+
case 'callback' :
249+
let callback = (options.icon && options.icon instanceof Function) ? options.icon : null;
250+
251+
if(callback) {
252+
iel = callback(iel);
253+
}
254+
247255
break;
248256
default:
249257
iel.classList.add('material-icons');

0 commit comments

Comments
 (0)