-
Notifications
You must be signed in to change notification settings - Fork 58
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
[Bug] Do not strip custom local icons of their classes #210
Comments
At this line: Line 359 in 1b28ec2
While /cc @cyberalien is that something Iconify would consider in scope? If so I'd happy to send PR upstream to get this supported |
@antfu EDIT: |
This is a tricky issue. Current implementation is by design. Why is it so? Editors like Adobe Illustrator (the worst of them, closely followed by Inkscape) add massive amounts of garbage to SVG it generates, all of it is always unused. The most common example of such garbage on SVG tag exported by various editors is Not having additional attributes makes it easy to deal with icon when rendering it. All that is added to SVG tag is Should it be changed? For this use case it makes sense to keep attributes. Custom loaders should not modify user's icon. In this case it is absolutely safe. In cases when user provides a really bad icon with lots of Illustrator stuff without optimising it, it should still be kept as is and should be up to user to make sure icon is correct. This was not considered many years ago when type was created, but I think it is about time to change it. |
Need to think of a temporary solution for this issue. Proper solution would require changing type, but simply adding extra attributes to type is not a good idea because I'd rather completely rebuild all types. What I want to do with
Additionally, for However, this is a huge task because first need to finalise types to make sure everything is included, then change tools to handle both new and old types, then change all components to handle new type, only then actually use new type. So it won't work for this issue because it will take a lot of time. |
@cyberalien I'm not sure if this is a valid suggestion, but the only needed attribute here is the Would this pipeline work?
|
Unfortunately I don't think it would. Can't figure out how to make it work. Icons are converted to icon set in I think best option for now is to change your icons. You know names of icons, which have those custom class names. When using those icons in code, you can add necessary class names to icon component. Proper support can be added later with types redesign. |
I noticed a behavior that I consider a bug, but I'm not sure if this is wanted.
Anyway, I noticed that when using custom local icons, i.e. loaded from the
assets
folder, classes applied to their rootsvg
element are stripped when the icon is actually loaded in the template.This is not really a good behavior, because some classes could be used to apply animations to the said icon, and removing them will cause them to not be animated.
I prepared a simple reproduction here https://github.com/stefanobartoletti/icon-test, everything should be pretty much self-explanatory, but right now, the SVG icon directly pasted into the template can be animated via the custom
icon-animation
class, while the same SVG loaded with theIcon
component cannot, because it is stripped of the said class.A possible workaround right now could be to give this class to the
Icon
component, instead of the source SVG icon, but this is not optimal, since the same exact icon could be needed in many places in a project and it would make sense to give this class only once to the source, instead of needing to apply it to every and each instance of theIcon
component using it.Also, I noticed that the classes are stripped only from the root
svg
element, if you have classes in nestedg
orpath
elements, they remain in place.Hopefully it is all clear, anyway, feel free to ask for more info if needed.
Edit:
I forgot to add that I'm talking about a configuration using the
svg
mode to load icons, where the source icon is inlined in the template.The text was updated successfully, but these errors were encountered: