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

Register from file #104

Open
ferndot opened this issue May 2, 2018 · 11 comments
Open

Register from file #104

ferndot opened this issue May 2, 2018 · 11 comments

Comments

@ferndot
Copy link

ferndot commented May 2, 2018

First off, I really appreciate this library. It has been valuable to my work.

It would be really great if it supported registering icons from an SVG file. The current manual creation of paths and shapes is cumbersome and hard to update. Also, the raw option doesn't fit this need very well because it seems to only work with the contents of a layer, rather than the entire svg file.

@SBeator
Copy link

SBeator commented Jun 14, 2018

I also want to have this feature.
What's more, can we import some svg files and register them together?

@Justineo Do you have any plan to implement this feature?
I can help on this if you want.

@Justineo
Copy link
Owner

Hi, do you have a proposed usage for this feature?

@SBeator
Copy link

SBeator commented Jun 14, 2018

@Justineo The usage is like this:

We have some customized icons in our website from design. We need to register them before we can use them.

And our designer can give us some SVG files for these icons.

Now I am thinking if we can register the custom icons from the SVG files directly.

Then we can have these benefits:

  1. We don't need to copy the content of the SVG file to JS file for registering.
  2. We can just maintain the SVG files. So it can easily change the icons in future if needed.
  3. We can easily preview the icons by just open the SVG files.

@Justineo
Copy link
Owner

I’m aware of your use case. What I ask earlier is about the proposed API. Currently it’s easy to achieve this by add some webpack loader or a custom script to automatically convert SVG files into JS modules without any modification on the runtime API.

@SBeator
Copy link

SBeator commented Jun 14, 2018

Agree, this is also what I want to do.
I am trying to set the webpack loader to import SVG files and register them. And of course I can implement that feature without change any of your API.

But I am still thinking if you can provide a formal way to do this, so that any other people (like me) can easily use the new feature and don't need to spend much time to think how to set the loader or write some custom script.

@ferndot
Copy link
Author

ferndot commented Jun 14, 2018

For my use case, it would be great if something like this were implemented:

import Icon from 'vue-awesome/components/Icon'

Icon.register({
  'custom-icon': {
    file: 'path/to/icon.svg'
  }
})

@ghost
Copy link

ghost commented Feb 28, 2020

@joshua-s Have you found any practical solution until now?

@Justineo
Copy link
Owner

import Icon from 'vue-awesome/components/Icon'

Icon.register({
  'custom-icon': {
    file: 'path/to/icon.svg'
  }
})

This is not possible without a build step (eg. webpack loader).

@ferndot
Copy link
Author

ferndot commented Feb 28, 2020

@andreiscripcaru22 I have not, actually. I currently update the icons manually when things change.

@GregHattJr
Copy link

@joshua-s So you have custom SVG images that you import and then compile using Vue Awesome? I've been really really struggling to figure out how I can import a provided SVG and register it with Vue Awesome as an icon.

@ferndot
Copy link
Author

ferndot commented Mar 1, 2021

@GregHattJr I've just been manually copying in the SVG code and using it like this section explains:
https://github.com/Justineo/vue-awesome#registering-custom-icons

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

4 participants