Skip to content

Commit

Permalink
callback icon pack support added
Browse files Browse the repository at this point in the history
  • Loading branch information
shakee93 committed Dec 2, 2018
1 parent e777299 commit b9e1c60
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -186,13 +186,13 @@ fullWidth|Boolean|false|Enable Full Width
fitToScreen|Boolean|false|Fits to Screen on Full Width
className|String, Array|null|Custom css class name of the toast
containerClass|String, Array|null|Custom css classes for toast container
iconPack|String|'material'| Icon pack type to be used <br> **['material', 'fontawesome', 'mdi', 'custom-class', 'callback']**
Icon|String, Object|null|Material icon name as string. [explained here](#icons-fire)
type|String|'default'| Type of the Toast **['success', 'info', 'error']**
theme|String|'toasted-primary'|Theme of the toast you prefer<br> **['toasted-primary', 'outline', 'bubble']**
onComplete|Function|null|Trigger when toast is completed
closeOnSwipe|Boolean|true|Closes the toast when the user swipes it
singleton|Boolean|false| Only allows one toast at a time.
iconPack|String|'material'| Icon pack type to be used <br> **['material', 'fontawesome', 'mdi', 'custom-class']**

### Methods

Expand Down
8 changes: 8 additions & 0 deletions dist/vue-toasted.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/vue-toasted.min.js

Large diffs are not rendered by default.

18 changes: 17 additions & 1 deletion examples/using-icons.js
Expand Up @@ -38,4 +38,20 @@ Vue.toasted.show(
icon: {
name: 'fal fa-check fa-spin fa-fw',
}
});
});


// Callback as icon pack
Vue.use(VueToasted, {
iconPack: 'callback'
});


Vue.toasted.show(
'hello there, i am a toast !!', {
// el is icon html element you can play with it
icon: (el) => {
el.innerText = 'my icon logic';
return el;
}
});
8 changes: 8 additions & 0 deletions src/js/show.js
Expand Up @@ -244,6 +244,14 @@ const createIcon = (options, toast) => {
})
}

break;
case 'callback' :
let callback = (options.icon && options.icon instanceof Function) ? options.icon : null;

if(callback) {
iel = callback(iel);
}

break;
default:
iel.classList.add('material-icons');
Expand Down

0 comments on commit b9e1c60

Please sign in to comment.