Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Add Custom Icons to mt-icon Component #260

Open
runelaenen opened this issue Aug 26, 2024 · 1 comment
Open

Enhancement: Add Custom Icons to mt-icon Component #260

runelaenen opened this issue Aug 26, 2024 · 1 comment

Comments

@runelaenen
Copy link

I would like to request a feature that allows the ability to add and render custom icons easily within the mt-icon component. In the previous version (sw-icon in the Shopware codebase), as a user I was able to extend the component and load custom icons from within my Shopware Administration application.

The mt-icon component was created differently compared to sw-icon, which has led to this not being possible anymore as far as I can see. Currently, there is no documented way to load custom icons with mt-icon. For users who have specific design or branding needs, the ability to add custom icons is essential.

@runelaenen
Copy link
Author

Just for extra information, with sw-icon it was very easy to add custom icons by overriding the component like this.

Shopware.Component.override('sw-icon-deprecated', {
    methods: {
        loadIconSvgData(variant, iconName, iconFullName) {
            if (variant === 'xyz') { // Only handle our custom icon names
                return import(`./icons/${variant}/${iconName}.svg`).then((iconSvgData) => {
                    if (iconSvgData.default) {
                        this.iconSvgData = iconSvgData.default;
                    } else {
                        // note this only happens if the import exists but does not export a default
                        console.error(`The SVG file for the icon name ${iconFullName} could not be found and loaded.`);
                        this.iconSvgData = '';
                    }
                });
            }

            return this.$super('loadIconSvgData', variant, iconName, iconFullName);
        },
    },
})

@shopware shopware deleted a comment Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant