npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

svg2symbol

v1.0.2

Published

Simple svg symbols generator with basic attributes stripping options.

Downloads

2

Readme

svg2symbol

Simple and quick symbol maker. Can strip fills, strokes, styles - all, the key one, or except the key one. Also allows for CSS background use with help of svg fragment identifier. Use examples coming soon.

Quick start

Install

npm i svg2symbol --save-dev

Package.json script

Define your script in package.json:

scripts: {
    "svg": "svg2symbol -i ./test/svgs -o ./test/symbols.svg"
}

Run your script

npm run svg

Run cmd

On linux or mac you can call

npm run env svg2symbol -- -i ./test/svgs -o ./test/symbols.svg

On windows and linux, mac

npm exec svg2symbol -- -i ./test/svgs -o ./test/symbols.svg

Parameters

Required

--input, -i Folder input path

--output, -o File output path

Optional

--stripFills (Boolean|String) [false]

If set to true module will strip every fill from svg. If you will specify key value like "#FF0000" it will strip only fills with "#FF0000" value. To remove all fills except key value write "!#FF0000".

--stripStrokes (Boolean|String) [false]

Similar to stripFills. Set to true to remove every stroke from svg. Specify key value like "red" to strip only strokes with "red" value. To remove all strokes except key value write "!red".

--stripStyles (Boolean) [false]

Strip styles attribute

--prefix (String) ['']

String to be prefixed to your symbol name.

--suffix (String) ['']

String to be suffixed to your symbol name.

--hideClass (String) ['hidden']

Add specific class to generated svg. By default adds hidden as it is typical for "display: none".

--hideDisplay (Boolean) [false]

Sets "display: none" in generated svg inline style. If this is used then hideClass is ignored. (?)

--cssBgSupport (Boolean) [false]

Adds new svg elements (view, g, use) to allow use of svg fragments as css background property. Prepends -v to view id as it can't be the same as symbol id. In the end you call it like this:

background: url(symbols.svg#symbolname-v) no-repeat;

Notice: cssBgSupport adds global style (specific for svg2symbol generated svgs only) inside the svg file - it is needed to properly display stacked fragments. If you create multiple symbols collection files then consider adding the css style to your css file and set cssBgSupportStyle to false.

--cssBgSupportStyle (Boolean) [false]

By default it's set to false, but if you set --cssBgSupport true then cssBgSupportStyle by default is also true and if you need you can disable it with --cssBgSupportStyle false Adds below css style which is required to properly display svg views as css background.

.svg2symbol view + g {
    display: none;
}
.svg2symbol view:target + g {
    display: inline;
}

Usage examples

To be written

What if I need minifying or other stuff?

Use SVGO.