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

@greenberry/storybook-template

v1.0.12

Published

Template project for component libraries

Downloads

6

Readme

Storybook template

This is a template project. To use this in a new project follow the instructions in first steps.

First steps

  • Fork this repository
    • Click the plus button on the left side of the screen
    • Click fork
    • Provide the name for the fork
  • Clone the forked repository to your machine
  • Update name property package.json to reflect your project. Ensure it begins with @greenberry to make it private
  • Set this template repo as upstream so you can rebase for updates
    • Inside your local repository run the following command;
    • git remote add upstream [email protected]:greenberrynl/storybook.git
    • Do a fetch git fetch upstream master

File structure

src/
  constants/
    myConstants.js   <-- Global constants are used in multiple places or exposed to the world
  components/
    MyComponent/
      index.js       <-- The component
      index.story.js <-- The component's story
      index.spec.js  <-- (Optional) Component unit tests
      utils.js       <-- (Optional) Local utils are only used by this component
      utils.spec.js  <-- Tests of local utils
      constants.js   <-- (Optional) Local constants
      assets/        <-- Assets and resources used by the component can be put here
        image.svg
  utils/             <-- Global utils are used by multiple components
    myUtil/
      index.js       <-- The util
      index.spec.js  <-- The util tests
      constants.js   <-- (Optional) Local constants

Story format

Example

import React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { text } from '@storybook/addon-knobs';

import Button from './index';

storiesOf('UI|Button', module)
  .addParameters({ options: { selectedPanel: 'storybook/actions/panel' } })
  .add(
    'with text',
    () => <Button onClick={action('onClick')}>Hello Button</Button>,
    { info: 'Describe your components usage here' }
  )

Testing

For running test we use Jest a test running framework created by Facebook. By using "Storyshots" we are able to automatically generate snapshots for each story. This means that all the cases/states visualised inside Storybook are automatically tests and verified.

For learning more about Jest consult their documentation

Running tests

yarn test

Update outdated snapshots

yarn test -u

Publishing

To use the latest changes we will need to publish the a new version to the NPM registry for this we will use Yarn.

yarn publish

When running the publish command a "hook" will be fired triggering the prepublish command configured in the package.json. This will prompt you to specify a new version. For versioning we use Semver. So given a version number MAJOR.MINOR.PATCH(1.0.0), increment the:

  • MAJOR version when you make incompatible API changes,
  • MINOR version when you add functionality in a backwards compatible manner, and
  • PATCH version when you make backwards compatible bug fixes.

Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.

When you are not signed in to NPM yet, you will be prompted to sign in after which it will start uploading the package.

Addons

By default, Storybook comes with a way to list stories and visualize them. Addons implement extra features for Storybooks to make them more useful. Addons in this project;