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

@productboard/svg-componentify

v2.5.0

Published

## Install

Downloads

48

Readme

@productboard/svg-componentify

Install

yarn add @productboard/svg-componentify -D

Idea

This tool seamlessly automate the work you have to do when you want from SVG file create React Component. At as a plus you will get optimized SVG structure.

From file like this:

<?xml version="1.0" encoding="UTF-8"?>
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <!-- Generator: Sketch 52.4 (67378) - http://www.bohemiancoding.com/sketch -->
    <title>Icon / 12 / Feature 2</title>
    <desc>Created with Sketch.</desc>
    <defs>
        <path d="M15,0 C15.6,0 16,0.4 16,1 L16,15 C16,15.6 15.6,16 15,16 L1,16 C0.4,16 0,15.6 0,15 L0,1 C0,0.4 0.4,0 1,0 L15,0 Z M14,14 L14,2 L2,2 L2,14 L14,14 Z M4,7 L12,7 L12,9 L4,9 L4,7 Z M4,4 L12,4 L12,6 L4,6 L4,4 Z M4,10 L8,10 L8,12 L4,12 L4,10 Z" id="path-1"></path>
    </defs>
    <g id="🎨-Style-guides" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
        <g id="Notifications" transform="translate(-230.000000, -853.000000)">
            <g id="Icon-/-12-/-Feature-2" transform="translate(230.000000, 853.000000)">
                <g id="Icon-/-12-/-Feature">
                    <g id="Icon-/-16-/-Feature">
                        <mask id="mask-2" fill="white">
                            <use xlink:href="#path-1"></use>
                        </mask>
                        <use id="Mask" fill="#BCC4CC" fill-rule="evenodd" xlink:href="#path-1"></use>
                    </g>
                </g>
            </g>
        </g>
    </g>
</svg>

You will get React Component like this:

/**
 * Copyright (c) ProductBoard, Inc.
 * All rights reserved.
 */

import React from 'react'
import cx from 'classnames'
import styles from './Icon.styles'

const Feature = ({ className }: { className: string }) => (
  <svg viewBox="0 0 16 16" className={cx(className, styles.icon, 'pb-icon')}>
    <path d="M15 0c.6 0 1 .4 1 1v14c0 .6-.4 1-1 1H1c-.6 0-1-.4-1-1V1c0-.6.4-1 1-1h14zm-1 14V2H2v12h12zM4 7h8v2H4V7zm0-3h8v2H4V4zm0 6h4v2H4v-2z" />
  </svg>
)

export default Feature

Configuration

⚠️ Currently there is not option to configure the transformator (#1) but you can always do a Fork, right. 💪 If you want this happen write us to to the issue, we will prioritize it.

Exported binary svg-componentify has this possible configuration (via arguments)

  • --icon-path (required) Where to look for SVG icons
  • --export-path (required) Where to export optimized icon React components
  • --extension (defaults to tsx)
  • --suffix (defaults to react)
  • --naming-convention (defaults to camelCase) Exported components file name convention. Options: camelCase | kebabCase | snakeCase
  • --only-staged (defaults to false) Transform only staged svg icons files
  • --all (defaults to false) Process all files
  • -v, --version to print actual version of the tool
  • -f, --force force all prompts to its default value

Example

{
  "scripts": {
    "icons:generate": " yarn run svg-componentify --icon-path='svg/app' --export-path='src/js/components/ui/Icons'"
  },
  "husky": {
    "hooks": {
      "pre-commit": "yarn run icons:generate --only-staged"
    }
  },
  "devDependencies": {
    "@productboard/svg-componentify": "2.0.1"
  }
}