SVG sprite for the Entypo+ icon collection.
This is a node module that packages the Entypo+ icon collection as a SVG sprite.
411 carefully crafted premium pictograms by Daniel Bruce - CC BY-SA 4.0.
See entypo.com for more information.
A SVG sprite is a hidden SVG element inserted at the top of the body element that defines a set of icons with unique IDs. These icons can later be referenced throughout the document with the <use>
element.
Read Icon System with SVG Sprites by Chris Coyier for more information.
npm install entypo
In your JavaScript:
const entypo = require('entypo')
document.body.insertBefore(entypo.getNode(), document.body.firstChild)
In your HTML:
<svg><use xlink:href="#entypo-star" /></svg>
In your CSS:
svg {
fill: #fff;
}
- function: returns svg sprite file contents as utf-8 text
You can insert this into the page easily using the DOM API. This works by specifying brfs in the browserify transform field. You may need a special fs loader in webpack if its not picking up the transform.
- function: returns svg sprite DOM node
This a convenience function that returns the svg sprite as a DOM Node so that it can be inserted into the body
element using the DOM API.
document.body.insertBefore(entypo.getNode(), document.body.firstChild)
- function: converts a string to a DOM node
This is a utility function used by getNode()
to convert the raw SVG text provided by the main entypo()
function into a DOM node.
- string: path to svg sprite (e.g.
node_modules/entypo/dist/sprite.svg
)
To see an example implementation, try npm run example
. Source code is in example.js
.
Contributions welcome! Please read the contributing guidelines first.
Daniel Bruce, if you are reading this, send me an email if you want commit / release access.
- Module: ISC
- Icons: CC BY-SA 4.0.