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

angular-svg-icon-preloader2

v8.0.1

Published

An Angular library that pre loads SVG icons for use with angular-svg-icon

Downloads

4

Readme

MIT commitizen PRs styled with prettier All Contributors

Angular SVG Icon Preloader is a library to be used in conjunction with the angular-svg-icon library. The purpose is to allow you to provide a JSON file of icons that you will use frequently enough that they can be preloaded when the app bootstraps. You can still load icons after the app bootstraps the same way angular-svg-icon provides; this is just another way of loading the icons.

Features

  • ✅ Preload icons as files or SVG icon data
  • ✅ Use the icons as soon as the app loads without having to manually load the icon

Table of Contents

Installation

NPM

npm install angular-svg-icon-preloader

Yarn

yarn add angular-svg-icon-preloader

Usage

For the library to work, you need to first create a JSON file somewhere that your app can load. The easiest location is in the app's assets folder. The JSON file should have two top level attributes:

  • iconImageFiles: an array of IconImageFile items. These items have two attributes each, iconName and iconPath. Both are strings. iconName is how you'll refer to the icon later in your app. iconPath is the URL to the SVG image file. This can be in the app's asset folder, or anywhere else that your app has access to reference SVG images.
  • customIcons: an array of CustomIconData items. These items have two attributes each, iconName and iconData. Both are strings. iconName is how you'll refer to the icon later in your app. iconData is the SVG code that would go in your HTML file if you were using the raw SVG.

These arrays can have any number of icons in them, and they'll all be loaded automatically when the app bootstraps for you. Here's an example icons.json file:

{
	"iconImageFiles": [
		{
			"iconName": "badge-check",
			"iconPath": "/assets/icons/badge-check.svg"
		}
	],
	"customIcons": [
		{
			"iconName": "academic-cap",
			"iconData": "<svg xmlns=\"http://www.w3.org/2000/svg\" > <path d=\"...\" /> </svg>"
		}
	]
}

Once you've defined your JSON file with the icon information, just import the angular-svg-icon library and this library in your AppModule. Make sure to provide the path to the icons JSON file in the forRoot method of the AngularSvgIconPreloaderModule's forRoot method:

@NgModule({
	imports: [
		AngularSvgIconModule.forRoot(), // angular-svg-icon library module
		AngularSvgIconPreloaderModule.forRoot({
			configUrl: './assets/json/icons.json',
		}),
	]
})

At this point, everything is done. To use the academic-cap icon in the above mentioned customIcons array, you only need to use the svg-icon component from angular-svg-icon:

<svg-icon name="badge-check"></svg-icon>
<svg-icon name="academic-cap"></svg-icon>

Contributors ✨

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!