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

kadira-storybook

v1.38.3

Published

React Storybook: Isolate React Component Development with Hot Reloading.

Downloads

12

Readme

React Storybook Build Status npm version

Now you can develop and design React UI components without running your app.

React Storybook Screenshot

You just load your UI components into the React Storybook and start developing them.

This functionality allows you to develop UI components rapidly without worrying about the app. It will improve your team’s collaboration and feedback loop.

Have a look at this article on Introducing React Storybook.

Features

  • Isolated environment for your components (with the use of various iframe tactics).
  • Hot module reloading (even for functional stateless components).
  • Works with any app (whether it's Redux, Relay or Meteor).
  • Support for CSS (whether it's plain old CSS, CSS modules or something fancy).
  • Clean and fast user interface.
  • Runs inside your project (so, it uses your app's NPM modules and babel configurations out of the box).
  • Serves static files (if you host static files inside your app).
  • Deploy the whole storybook as a static app.
  • Extendable as necessary (support for custom webpack loaders and plugins).

Demo

Let's look at what React Storybook does. First clone the following repo:

git clone https://github.com/kadira-samples/react-storybook-demo

It's a Redux to-do app (taken from the Redux repo).

Then apply the following commands:

npm install
npm run storybook

This will start your Storybook in http://localhost:9001. Open that URL in your browser. You will see the React Storybook UI:

React Storybook in action

Edit some of the components in the components directory and see how they reflect in the Storybook UI. We define stories inside the components/stories directory. Have a play with that as well.

Getting Started

Now let's add support for React Storybook to your app. First of all, add the @kadira/storybook NPM package to your app:

npm i --save-dev @kadira/storybook

Then, add the following NPM script into your package.json:

{
  ...
  "scripts": {
    "storybook": "start-storybook -p 9001"
  }
  ...
}

Now you can run npm run storybook and start developing components.

Wait... we are not there yet.

Writing Stories

Now you need to write some stories, which is how you can see your components inside the Storybook UI.

Basically, a story is a single view of a component. It's like a test case, but you can preview it (live) from the Storybook UI.

You can write your stories anywhere you want. But keeping them close to your components is a pretty good idea.

Let's write some stories:

// components/stories/button.js

import React from 'react';
import { storiesOf, action } from '@kadira/storybook';

storiesOf('Button', module)
  .add('with text', () => (
    <button onClick={action('clicked')}>My First Button</button>
  ))
  .add('with no text', () => (
    <button></button>
  ));

Here, we simply have two stories for the built-in button component. But, you can import any of your components and write stories for them instead.

Configurations

Now you need to tell Storybook where it should load the stories from. For that, you need to write a simple configuration file. Add the following content to .storybook/config.js:

import { configure } from '@kadira/storybook';

function loadStories() {
  require('../components/stories/button');
  // require as many stories as you need.
}

configure(loadStories, module);

That's it. Now simply run npm run storybook and start developing your components.

Check this app to see it in action: https://github.com/kadira-samples/react-storybook-simple-demo

Learn More

There are many things you can do with React Storybook. You can explore them with the following links:

New: React Storybook meets GitHub

Storybooks.io - UI Code Reviewing Done Right

Sample Apps

React Storybook is very powerful and you can use it with any kind of app. Here's a list of sample apps configured for React Storybook: