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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tonisanchez.dev/init-component

v1.0.8

Published

A script to generate a folder named as your component, containing a minimalist react-typescript (.tsx) template component with its jest test file, types file, stories file (storybook.js), and styles file (react-jss). Develop faster by creating all you nee

Readme

About

A script to generate a folder named as your component, containing a minimalist react-typescript (.tsx) template component with its jest test file, types file, stories file (storybook.js), and styles file (react-jss). Develop faster by creating all you need for your new component at once.

└── my-component
    │
    └── MyComponent.tsx
    └── MyComponent.types.tsx
    └── MyComponent.styles.tsx
    └── MyComponent.test.tsx
    └── MyComponent.stories.tsx
    └── index.ts

Installation

npm i -D @tonisanchez.dev/init-component

Alternatively

yarn add -D @tonisanchez.dev/init-component

How it works

Execute the script on your package.json like this:

// package.json
...
  "component": "node node_modules/@tonisanchez.dev/init-component/src 'YOUR_COMPONENTS_FOLDER_DIR'",
...

Everytime you call this script a new folder will be created containing 6 files:

  • Types file with a minimal type declaration for props.
  • Declaration of styles with a basic react-jss configuration.
  • Stories file for storybook.js code-level documentation.
  • Test file with a pre-built test that is passing.
  • Component file that renders a minimalistic component importing above files.
  • An index to use it optionally for repositories with an folder structure of "index" files.

Notice that the folder created containing the above files will be named after the component name you specify as first parameter. See next section.

Parameters

Component name

Using script as shown above, you can specify the name of your component with a following parameter as shown below:

npm run component MyComponent

Alternatively

yarn component MyComponent

subfolder

You can specify a subfolder with the second parameter. This is specially useful for projects that follows atomic design principles. With the second optional parameter you can specify the level of the component represented in the scale [atoms, molecules, organisms, templates, pages].

Examples

Assuming the following in your package.json

...
  "component": "node '@tonisanchez.dev/init-component' './src/components'"
...

And then running the script below

yarn run component MyComponent organisms

Will generate the next content

src
│
└───components
│   │
│   └── ...
│   │
│   └── organisms
│       │
│       └── my-component
│           │
│           └── MyComponent.tsx
│           └── MyComponent.types.tsx
│           └── MyComponent.styles.tsx
│           └── MyComponent.test.tsx
│           └── MyComponent.stories.tsx
│           └── index.ts
└─...

Default content of files generated

[COMPONENT.tsx]

import React from 'react'

import { useStyles } from './styles'
import { MyComponentProps } from './types'

const MyComponent = ({ children }: MyComponentProps) => {
  const classes = useStyles()
  return (
    <button className={classes.myButton}>
      <span className={classes.myLabel}>{children}</span>
    </button>
  )
}

export default MyComponent

[COMPONENT.types.tsx]

export type MyComponentProps = {
  children: string
}

[COMPONENT.styles.tsx]

import { createUseStyles } from 'react-jss'

export const useStyles = createUseStyles({
  myButton: {
    color: 'green',
    margin: {
      top: 5,
      right: 0,
      bottom: 0,
      left: '1rem'
    },
    '& span': {
      fontWeight: 'bold'
    }
  },
  myLabel: {
    fontStyle: 'italic'
  }
})

[COMPONENT.test.tsx]

import React from 'react'
import { render, screen } from '@testing-library/react'
import MyComponent from './component'

describe('Block of tests', () => {
  test('renders children text', () => {
    render(<MyComponent>Hola</MyComponent>)
    const demoElement = screen.getByText(/Hola/i)
    expect(demoElement).toBeInTheDocument()
  })
})

[COMPONENT.stories.tsx]

import React from 'react';
import { ComponentStory, ComponentMeta } from '@storybook/react';

import MyComponent from '.';

export default {
  title: 'Components/MyComponent',
  component: MyComponent,
} as ComponentMeta<typeof MyComponent>;

const Template: ComponentStory<typeof MyComponent> = (args: any) => <MyComponent {...args} />;

export const Primary = Template.bind({});
/* Primary.parameters = {
  backgrounds: { default: 'dark' }
};

Primary.args = {
  label: 'MyComponent',
  variant: MyComponentVariants.primary
};

export const Secondary = Template.bind({});
Secondary.args = {
  label: 'MyComponent',
  variant: MyComponentVariants.secondary
}; */

Have fun with it

I will be publishing newer versions and extend this simple and small tool. Meanwhile, I have more interesting projects on my Github @TonySapa or site tonisanchez.dev