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

@icon-magic/build

v2.8.0-beta.0

Published

Icon magic blueprint package.

Downloads

6

Readme

@icon-magic/build

The build is responsible for constructing all the various flavors that an icon can exist in from it's different variants, after applying the build plugins on the variants. It moves these resulting flavors to the destination folder renaming the icon if necessary. It also generates a config file, one for each icon and stores it along with the icon it's in output folder.

Build transforms the variants into flavors by applying all the build plugins on each variant of each icon. Plugins are applied in the order in which they appear. This will result in different flavors of the icon, which are added to the icons config. @param iconConfig a map of the iconPaths to it's config json

Interface

build(iconConfig: IconConfigHash): Promise

The build function that takes in a mapping of the path to the icon directory and a configuration of the icon itself. For example, we contain a directory (as below) for nav-icons (navigation icons). This directory contains one icon, the home icon which has two variants - filled.svg and outline.svg.

nav-icons
├── home
│   ├── filled.svg
│   └── outline.svg
    computer
│   ├── filled.svg
│   └── outline.svg
├── iconrc.json

nav-icons also contains an iconrc.json that is applicable to all the icons within nav-icons including the home and computer icon. After we get the config from config-reader's getIconConfigSet(), each Icon will have it's own config with resolved iconPaths as below:

[
  '/Users/rchitloo/workspace/icon-magic/packages/@icon-magic/config-reader/test/fixtures/nav-icons/home',
  {
    iconPath:
      '/Users/rchitloo/workspace/icon-magic/packages/@icon-magic/config-reader/test/fixtures/nav-icons/home',
    variants: [
      { path: './filled.svg' },
      { name: 'someOtherName', path: './outline.svg' }
    ],
    build: { outputPath: './out' },
    sourceConfigFile:
      '/Users/rchitloo/workspace/icon-magic/packages/@icon-magic/config-reader/test/fixtures/nav-icons/iconrc.json'
  }
];

With this input set of icons, build creates Icon classes in memory and then goes on to apply all the build plugins on each variant of the icon, transforming it into one or multiple flavors and writing the resulting flavors into the output. All the while, the icon in memory is updated with the newly generated flavors. After all the plugins are applied, the build then writes the config of each icon to form an icon bundle consisting of

  1. The icon config file (iconrc.json)
  2. The various flavors of the icon in their svg formats

build() then returns a Map of the path to the icon directory and it's corresponding Icon class so it can be chained to the next steps of the icon generation process

build/plugins

Currently, we don't have any default build plugins but these are an ideal place to add css classes on the .svg icon for to generate different color themes of the icon. All .svg manipulations to generate flavors are done as part of the build process via build plugins

For more details on the interfaces, refer to @icon-magic/icon-models