shakee93 / vue-toasted

🖖 Responsive Touch Compatible Toast plugin for VueJS 2+
https://shakee93.github.io/vue-toasted/
MIT License
2.21k stars 195 forks source link

Mdi icon pack not working #86

Closed agcty closed 6 years ago

agcty commented 6 years ago

I just tried using the mdi icon pack but this doesn't work unfortunately, when looking into the source of the most recent release there also is no trace of a case for iconPack: "mdi"

var createIcon = function createIcon(options, toast) {

    // add material icon if available
    if (options.icon) {

        var iel = document.createElement('i');

        switch (options.iconPack) {
            case 'fontawesome':

                iel.classList.add('fa');

                var faName = options.icon.name ? options.icon.name : options.icon;

                if (faName.includes('fa-')) {
                    iel.classList.add(faName.trim());
                } else {
                    iel.classList.add('fa-' + faName.trim());
                }

                break;
            default:
                iel.classList.add('material-icons');
                iel.textContent = options.icon.name ? options.icon.name : options.icon;
        }

        if (options.icon.after) {
            iel.classList.add('after');
        }

        appendIcon(options, iel, toast);
    }
};
agcty commented 6 years ago

Additional info:

It looks like in the dist folder of github there is support for mdi:

var createIcon = function createIcon(options, toast) {

    // add material icon if available
    if (options.icon) {

        var iel = document.createElement('i');

        switch (options.iconPack) {
            case 'fontawesome':

                iel.classList.add('fa');

                var faName = options.icon.name ? options.icon.name : options.icon;

                if (faName.includes('fa-')) {
                    iel.classList.add(faName.trim());
                } else {
                    iel.classList.add('fa-' + faName.trim());
                }

                break;
            case 'mdi':

                iel.classList.add('mdi');

                var mdiName = options.icon.name ? options.icon.name : options.icon;

                if (mdiName.includes('mdi-')) {
                    iel.classList.add(mdiName.trim());
                } else {
                    iel.classList.add('mdi-' + mdiName.trim());
                }

                break;

            default:
                iel.classList.add('material-icons');
                iel.textContent = options.icon.name ? options.icon.name : options.icon;
        }

        if (options.icon.after) {
            iel.classList.add('after');
        }

        appendIcon(options, iel, toast);
    }
};

However when installing through npm there isn't

shakee93 commented 6 years ago

it was actually not published to npm. now its available on the latest version. 🙌