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

icons-to-react-svg

v0.0.2

Published

Icons to React SVG / Font-family / Experimental pseudo-element

Downloads

4

Readme

Icons to React SVG / Font-family / Experimental pseudo-element

This package is for creating react component with svg icon, or font-family or icons based on :before pseudo-element using one click.


Important

1) Do not use unicode bigger than 1000 (it is not working)!

2) Use underscores in the icon file name!

Installation:

just install it, ie: yarn

Adding new icons:

  1. Add icon into icon folder

  2. Optional: You can add icon number into scripts/icons.json file.

    {[icon_file_name], [unicode (it need to be uniq)].

    It will produce an icon with this unicode. If you will miss this step script will generate code for you. Everything you'll find in scripts/icons.json file.

  3. Run yarn build

    It will produce icon components (lib folder) + experimental pseudo-elements with SVGs (lib/styles.css) + font-family (dist folder) + cleared icons in .icons

PS. For a preview, you can check dist/icons.html in the browser.

Base usage:

1) SVG as component:

import { Add } from 'icons-to-react-svg';

return (
	<Add
		color={STRING}
		size={NUMBER || STRING}
		{other props}
	/>
)

2) Font-family:

  1. you need to set new icon in you icon file
  2. you're able to use this icon by unicode, ie: @include icon(directions, '\e993');

this mixin will create an icon in css .icon-directions and scss placeholder %icon-directions

3) Experimental SVG icons insider :before / :after - for now, it is OFF:

  1. you need to import styles lib/styles.css into you repo
  2. Icons are working with double dash as prefix ie:
  • .icon--add - it is using :before pseudo-element
  • .icon--add-after - it is using :after pseudo-element

How yarn build works:

  1. Remove files (files inside src and .icons)
  2. Copy icon folder into folder .icons
  3. Clean all .icons using svgo (it is removing useless SVG tags)
  4. Generate react component with SVG in folder src
  5. Generate experimental styles for using SVG inside pseudo-elements (src/styles.css)
  6. Generate font-family inside dist folder
  7. Copy files from src into lib
  8. Remove temporary files inside src

Components

sort_ascending.svg

  1. import { SortAscending } from 'icons-to-react-svg';
  2. unicode: e007
  3. .icon--sort-ascending:before, .icon--sort-ascending-after:after

sort_descending.svg

  1. import { SortDescending } from 'icons-to-react-svg';
  2. unicode: e006
  3. .icon--sort-descending:before, .icon--sort-descending-after:after