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

react-beauty-flags

v1.0.0

Published

A template for creating an icon library for your application. This template is heavily based on [heroicons](https://github.com/tailwindlabs/heroicons) and you should check it out to see if those icons can help you out.

Downloads

47

Readme

React Icon Library Template

A template for creating an icon library for your application. This template is heavily based on heroicons and you should check it out to see if those icons can help you out.

Table of Contents

How It Works

When the build script is run, every SVG icon in the src directory will:

  1. Solid icons will have their fill attribute set to currentColor while outline icons will have their stroke attribute set to currentColor.

  2. The icon will be optimized and copied to the ./optimized directory.

  3. The icon will be transformed into a React component with it's name being a PascalCase version of the SVG file name and the word Icon added at the end. For example, an icon named foo-bar will be turned into a component named FooBarIcon.

  4. Each icon will be exported from the ./solid/index.tsx or ./outline/index.tsx files. This means that the icons can be imported individually or in groups from their solid or outline directories.

Adding Icons

To add an icon to the icon library:

  1. Get the SVG code for your icon and figure out which directory the icon belongs in. If the icon has a fill, it should go in the ./src/solid directory. Otherwise, if it has only a stroke or outline, it should go in the ./src/outline directory.

  2. Create a file for your icon in the directory that it belongs to. Make sure you name the file with the kebab case version of the name you want your React component to have. For example, an icon named foo-bar will be turned into a component named FooBarIcon. Make sure that you don't add the word "icon" to the name of your svg file as the build scripts adds it to the component name automatically.

  3. Run the build command with npm run build. This will optimize the icons, add/remove certain attributes, and create the React components from the icons. It will also add the icons to the index.tsx file that corresponds to that style.

  4. Use the icon in your application. This can differ depending on your setup but in general, you can import one or more icons like so:

// Import a single icon.
import YourIcon from "your-icon-library/outline/YourIcon";

// Import multiple icons of the same style.
import { YourFirstIcon, YourSecondIcon } from "your-icon-library/solid";

Tests

There are a couple basic tests to make sure solid and outline icons have the correct attributes. These work by using a test icon, which in the src directory is named __jest-test.svg and in the built files is named JestTestIcon.

These icons are imported into the tests/icons.test.tsx file and checked for the necessary attributes.

You can run the tests using npm test which will build the icon library and run the tests.

GitHub Actions

The workflow at .github/workflows/build.yml will run whenever a pull request is made.

This action will install dependencies, run a build of the icon library, and run the available tests.

Keeping Up To Date With Template Changes

This template will be updated when dependencies need updating, new packages are added, and new or better concepts are found. To keep up with changes you might want from the template:

  1. Add the template repository as a remote:
git remote add template [email protected]:robertcorponoi/react-icon-library-template.git
  1. Fetch the changes:
git fetch --all
  1. Merge the changes from the main branch of the template repository:
git merge template/main

License

MIT