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

Add ability to remove icon from icon component #285

Closed
beauwest opened this issue Dec 15, 2020 · 4 comments
Closed

Add ability to remove icon from icon component #285

beauwest opened this issue Dec 15, 2020 · 4 comments
Assignees
Labels
bug Things that aren't working right in the library.

Comments

@beauwest
Copy link

Is your feature request related to a problem? Please describe.
In my application, I need to be able to dynamically apply icons, and sometimes remove them.

Describe the solution you'd like
I'd like to be able to set icon.name = ''; or icon.name = null; and have that remove the current icon.

Describe alternatives you've considered
I can currently use the custom resolver with a magic truthy string and a blank SVG to accomplish what I need, but it'd be a lot simpler to be able to remove the icon.

@beauwest beauwest added the feature Feature requests. label Dec 15, 2020
@claviska
Copy link
Member

Wouldn't this be better done with visibility: hidden or similar CSS?

@beauwest
Copy link
Author

beauwest commented Dec 15, 2020

At least for my application, I don't think so. I have a library of >6,800 icons that users can choose from, or they can choose no icon at all. I'd have to add logic to every component that implements an icon to handle the falsey scenario.

Honestly, this would be easier if the library resolver got called even if the icon name was falsey, but how it's written right now, I don't feel like I have any generic way to handle the "no icon" scenario.

Inside of setIcon()

    if (this.name && library) {
      url = library.resolver(this.name);
    }

I wonder if it's as simple as letting the library resolver have a shot at it.

@claviska
Copy link
Member

Ah, yeah I see setting name to '' doesn't clear out the icon, which I'd consider a bug. Never thought to try that.

Rather than make the resolver deal with it, an empty icon should probably just not be drawn — just like <img src=""> works.

@claviska claviska added bug Things that aren't working right in the library. and removed feature Feature requests. labels Dec 15, 2020
@beauwest
Copy link
Author

That sounds prefect to me, thank you so much Cory!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Things that aren't working right in the library.
Projects
None yet
Development

No branches or pull requests

2 participants