hughsk / svgify

A browserify transform for requiring SVG files to embed directly in your code.
Other
7 stars 4 forks source link

Usage? #1

Open zeke opened 10 years ago

zeke commented 10 years ago

Howdy Hugh,

Do you have examples of this module in use in another project? I think this module is what I'm looking for, but I'm a bit perplexed by the usage example in the README.

Once I've got a better handle on it, I'd be happy to help update the docs. :)

hughsk commented 10 years ago

Hey Zeke,

Unfortunately I've only used this in closed-source projects so don't have a good example right now! svgify extracts the contents of an SVG file, and exposes a function you can call that returns the contents wrapped up in a group element.

The API actually needs a bit of a rework, I think, and I might go and clean that up in the next couple of days or so. Though if you wanted to use it now:

var createGroupElement = require('./icon.svg')
var node = createGroupElement()

Will create something along these lines:

<g>
  <g>
    ...
    <icon-contents>
    ...
  </g>
</g>

Which you can then append to an SVG element (it won't work just being appended directly to the DOM). Does that make more sense? :)

zeke commented 10 years ago

That helps! Thanks for taking the time to reply. Looking forward to playing with this, and will keep my eyes out for your updates.