0.1.1 • Published 5 years ago

@noname-land/svg-sprite-data v0.1.1

Weekly downloads
2
License
-
Repository
github
Last release
5 years ago

@noname-land/svg-sprite-data

Note: The project is a fork of the same called package svg-sprite-data! It was created because the original one was abandoned for a long time, but there's a possibility that the author of that project has already returned and continued to support it. So go and check the status of that project first.

An attempt to make the svg-sprite lib work on strings only which will allow everyone to create their own awesome libs on top of it.

The idea is to remove ALL file-system access and leave all that to the authors who create tools on top of this. So, this module only has a couple of methods, only accepts strings & only returns data - it never touches anything on the file-system.

Usage

const SpriteData = require('svg-sprite-data');
const fs  = require('fs');

const config = {
  common: 'icon',
  dims: true,
  layout: 'diagonal',
  render: {
    css: true
  }
};

// Create instance
const spriter = new SpriteData(config);

// Read a file however you like
const path = './test/fixtures/fb.svg';
const svg  = fs.readFileSync(path, 'utf-8');

// Add the files CONTENTS only.
spriter.add(path, svg).compile(function (err, svg) {
  // Do crazy-ass shit with templates etc
  console.log(svg);
});