This package has been deprecated

Author message:

The saxicon module is no longer maintained and will not receive any further security updates or fixes.

saxicon

1.5.1 • Public • Published

🎷 saxicon

npm version License Build Status

The saxicon module transforms SVGs into a SASS snippet that allows you to generate colorized SVGs (with both single or multi-colored shapes) within SASS, with each SVG embedded as a data-URI.

Saxicon is useful when you want to:

  1. Colorise your icon SVGs into a number of different colors, where these icons are embedded in your SCSS as a data-URI. For example, for theming support or reducing the overhead of manually editing icons to match changes to your styleguide.
  2. When you want to store your SVGs in CSS, and directly embedding them in your HTML is not applicable. For example, when working with a CMS.

Features

  • Significantly faster than grunt-icon or plugins for inlining SVGs with PostCSS.
  • Robust unit and visual tests
  • Works with libsass and Dart Sass (replaces Ruby Sass)

Task runners:

Documentation

Quick start

const fs = require('fs');
const { Saxicon } = require('saxicon');
 
// Initialise a new Saxicon instance
const sax = new Saxicon();
 
// Parse a single SVG file
sax.parseSync('path/to/icon1.svg');
 
// Parse multiple SVG files
sax.parseSync([
    'path/to/icon2.svg',
    'path/to/icon3.svg',
]);
 
// Parse a string as a SVG file 
sax.parseString(someMarkup);
 
// Write SCSS to file
fs.writeFile('saxicon.scss', sax.scss(), (err) => {
    if (err) {
        throw new Error(err);
    }
});

Then in your SCSS:

@import 'saxicon';
 
.icon1 {
    background-image: sax(icon1, #F00);
}

Will compile to:

.icon1 {
    background-image: url("data:image/svg+xml,...");
}

Dependencies (2)

Dev Dependencies (4)

Package Sidebar

Install

npm i saxicon

Weekly Downloads

16

Version

1.5.1

License

BSD-3-Clause

Unpacked Size

20.8 kB

Total Files

9

Last publish

Collaborators

  • lachlanmcdonald