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

@sumcode/svgify

v2.0.0

Published

A lightweight React component designed to dynamically render and style SVG icons.

Downloads

1,166

Readme

Svgify

Features

  • Dynamic SVG Rendering: Fetches and displays SVG icons based on the provided IconName.
  • Customizable Styling: Supports inline styles, CSS classes, and different font weights (fill, stroke, or both).
  • Scalable Icons: Adjust the size of your icons with the Scale factor that will be multiplied by css font-size property.
  • Icons Caching: Icons is being cached in localstorage for better performance.

npm version npm downloads bundle size license dependencies TypeScript issues GitHub stars

The project is still in its beta version so some errors may occur or some icons may not accept the changes .. so please be helpful and report us for any problems you face.

Updates

  • Fix caching issues by provide icons version controlling through context provider.
    • All you need is to change current version through your provider and cached icons will change.

Testing

For Exhaustive click here

Installation

Install the package via npm:

npm install @sumcode/svgify

Add StyleSheet to your App.jsx file.

import "@sumcode/svgify/styles";

Initiate folder structure:

  • Make folder public/assets/icons.
  • Download your YOUR_ICON_NAME.svg in the folder.
.
└── my-project
    ├── node_modules
    ├── public
    │   └── assets
    │       └── icons (Add your svg icons here)
    │           └── YOUR_ICON_NAME.svg
    └── src
        └── app.jsx (Add stylesheet here)

Example

import "./App.css";
import Svgify from "@sumcode/svgify";

function App() {
    return (
        <>
            <Svgify IconName="YOUR_ICON_NAME" Scale={1.2} FontWeight="stroke" />
        </>
    );
}

export default App;

For version controlling (optional)

import React from "react";
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import App from "./App.tsx";
import { Svgifier } from "@sumcode/svgify";

createRoot(document.getElementById("root")!).render(
    <StrictMode>
        {/* Add Svgify Provider around your routes */}
        <Svgifier version={1} clearForOldVersion>
            <App />
        </Svgifier>
    </StrictMode>
);

| Parameter | Type | Initial value | Usage | | :------------------- | :--------- | :------------ | :-------------------------------------------------------------------------------------------------------------------------------------------- | | version | Number* | 1 | Your current icon's version should be different from the old one | | clearForOldVersion | Boolean? | false | needs to be activated for upgrading from versions older than 2.0.0 (recommended to be disabled if starting with version >= 2.0.0) |

Parameters

| Parameter | Type | Initial value | Usage | | :---------------- | :----------------------- | :------------ | :--------------------------------------------------------------- | | IconName | string* | "" | The name of the icon in the mentioned path without its extension | | FontWeight | string? | fill | Specifies the type of the icon "stroke" , "fill" , "both" | | Scale | float? | 1 | The factor to be multiplied by the styled font-size | | className | string? | "" | Custom ClassName to be passed to the span element | | LoadingElement | "" \| React.ReactNode? | "" | The text or element to be displayed while fetching the svg | | NotFoundElement | "" \| React.ReactNode? | "" | The text or element to be displayed on fetch error |

Author