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

load-json-icons

v1.0.1

Published

NPM Package for load icons based Font Awesome project

Downloads

5

Readme

NPM Load JSON Icons v1.0.1

NPM Package for load icons based Font Awesome project

NPM Load JSON Icons is based in BF Font Icons project. This project is used for read config.json file

This project will be written in NodeJS created and maintained by Bráulio Figueiredo. Stay up to date with the latest release and announcements on Twitter: @braulio_info.

Changelog

Contributing

If you want to contribute to this project, please send your sugestions in Issue page.

Instalation

npm install load-json-icons

Create JSON File

This file is interpreter by Fontello. Create a simple file named config.json with this structure

JSON File Structure

{
	"name": "<project name>",
	"css_prefix_text": "<'i' html tag prefix>",
	"css_use_suffix": false,
	"hinting": true,
	"units_per_em": 1000,
	"ascent": 850,
	"glyphs": [
		{
			"uid": "<numeric unique identification>",
			"css": "<icon name>",
			"code": <icon code>,
			"src": "<group icon>",
			"selected": true,
			"svg": {
				"path": "<svg path>",
				"width": <svg with (default 1000)>
			},
			"search": [<array of default search>],
			"group": "<group name for search>",
			"languages": [
				{
					"code": "<language code>",
					"description": "<language description>",
					"group_description": "<group name in this language>",
					"tags": [<array of tag names>]
				}
			]
		}
	]
}

JSON File Example

{
	"name": "load-icons-example",
	"css_prefix_text": "example-",
	"css_use_suffix": false,
	"hinting": true,
	"units_per_em": 1000,
	"ascent": 850,
	"glyphs": [
		{
			"uid": "1",
			"css": "american-football",
			"code": 59399,
			"src": "custom_icons",
			"selected": true,
			"svg": {
				"path": "M33.6 724.6L14.9 690.8C-9.2 842.1-0.6 966.8 16.3 983.7S158 1009.2 309.2 985.2C298.3 979.1 287.1 972.9 275.5 966.5 189.6 918.7 81.3 810.4 33.6 724.6ZM569.1 85.4L522.3 54.2C412.9 88.8 304.7 142.5 223.6 223.6 142.6 304.7 88.8 412.9 54.2 522.3 64.3 537.4 74.7 553 85.4 569.1 161.7 683.6 316.4 838.3 430.9 914.6L477.7 945.8C587.1 911.2 695.3 857.5 776.4 776.4S911.2 587.1 945.8 477.7C935.7 462.6 925.4 447 914.6 430.9 838.3 316.4 683.6 161.7 569.1 85.4ZM697.2 420.8C690.5 427.5 681.6 430.9 672.8 430.9S655.1 427.5 648.3 420.8L638.2 410.7 618 430.9 628.1 441C641.6 454.5 641.6 476.4 628.1 489.9 621.4 496.6 612.5 500 603.7 500S586 496.6 579.2 489.9L569.1 479.8 548.9 500 559 510.1C572.5 523.6 572.5 545.5 559 559 552.3 565.7 543.4 569.1 534.6 569.1S516.9 565.7 510.1 559L500 548.9 479.8 569.1 489.9 579.2C503.4 592.8 503.4 614.6 489.9 628.1 483.2 634.8 474.3 638.2 465.5 638.2S447.8 634.8 441 628.1L430.9 618 410.7 638.2 420.8 648.3C434.3 661.9 434.3 683.7 420.8 697.2 414.1 703.9 405.2 707.3 396.4 707.3S378.7 703.9 371.9 697.2L302.8 628.1C289.3 614.6 289.3 592.8 302.8 579.2S338.2 565.7 351.7 579.2L361.8 589.4 382.1 569.1 371.9 559C358.4 545.5 358.4 523.6 371.9 510.1 385.4 496.6 407.3 496.6 420.8 510.1L430.9 520.3 451.2 500 441 489.9C427.5 476.4 427.5 454.5 441 441S476.4 427.5 489.9 441L500 451.2 520.3 430.9 510.1 420.8C496.6 407.3 496.6 385.4 510.1 371.9 523.6 358.4 545.5 358.4 559 371.9L569.1 382.1 589.4 361.8 579.2 351.7C565.7 338.2 565.7 316.3 579.2 302.8S614.6 289.3 628.1 302.8L697.2 371.9C710.7 385.4 710.7 407.3 697.2 420.8ZM983.7 16.3C966.8-0.6 842.1-9.2 690.8 14.9 701.8 20.9 713 27.1 724.6 33.6 810.4 81.3 918.7 189.6 966.5 275.4L985.2 309.2C1009.2 158 1000.7 33.2 983.7 16.3Z",
				"width": 1000
			},
			"search": ["american-football"],
			"group": "sports",
			"languages": [
				{
					"code": "pt-BR",
					"description": "Português - Brasil",
					"group_description": "Esportes",
					"tags": ["futebol" , "americano" , "bola"]
				}
			]
		}
	]
}

Create Icon File

In Fontello, click in tool icon and import your config.json file

The Icons Object

The Icons object is used for manipulate a JSON file. To create new object, use require command and create a new "Icon" object.

// Import library and create new object
// Is required file name for load icons
var library = require("load-json-icons");
var icons = new library.Icons("files/config.json");

Methods

loadFilename

Return json filename

// Import library and create new object
// Is required file name for load icons
var library = require("load-json-icons");
var icons = new library.Icons("files/config.json");
var filename = icons.loadFilename();

loadCategories

Return all categories and your first icon

// Import library and create new object
// Is required file name for load icons
var library = require("load-json-icons");
var icons = new library.Icons("files/config.json");
var category = icons.loadFilename();

The result is:

{
	[
		"group": "<group name>",
		"icon": "<name of first icon>",
		"languages": [
			{
				"code": "<language code>",
				"groupDescription": "<group description>"
			}
		]
	]
}

count

Returns the total numbers of icons

// Import library and create new object
// Is required file name for load icons
var library = require("load-json-icons");
var icons = new library.Icons("files/config.json");
var count = icons.count();

findIcon

Parameters:

string iconName: name of icon

Return JSON Icon Object to name

// Import library and create new object
// Is required file name for load icons
var library = require("load-json-icons");
var icons = new library.Icons("files/config.json");
var icon = icons.findIcon("american-football");

Versioning

NPM Load JSON Icons will be maintained under the Semantic Versioning guidelines as much as possible. Releases will be numbered with the following format:

<major>.<minor>.<patch>

And constructed with the following guidelines:

  • Breaking backward compatibility bumps the major (and resets the minor and patch)
  • New additions, including new icons, without breaking backward compatibility bumps the minor (and resets the patch)
  • Bug fixes and misc changes bumps the patch

For more information on SemVer, please visit http://semver.org.

Author

  • Email: [email protected]
  • Twitter: http://twitter.com/braulio_info
  • GitHub: https://github.com/braulioti
  • Website: http://braulioti.com.br
  • NPM: https://www.npmjs.com/package/npm-load-json-icons