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

storybook-addon-react-live-edit

v2.0.4

Published

storybook.js addon providing live react story editing and preview

Downloads

525

Readme

storybook-addon-react-live-edit

DEMO

Installation

yarn add -D storybook-addon-react-live-edit

Configure storybook

To get this addon in your story book you have to register the panel, addLiveSource story creator and optionally add a scope decorator to make additional components and utilities available in live editor scope

Register the panel

Add to .storybook/addons.js

import 'storybook-addon-react-live-edit/dist/register';

Register the addLiveSource story creator

Add to .storybook/config.js

import {setAddon} from '@storybook/react';
import LiveEdit, {setOptions} from 'storybook-addon-react-live-edit';

setOptions({ theme: 'darcula', presets: ['react'] });

setAddon(LiveEdit);

Add withLiveEditScope story decorator

addDecorator to .storybook/config.js

import {addDecorator} from '@storybook/react';
import {withLiveEditScope} from 'storybook-addon-react-live-edit';

import ExternalComponent from 'a-apackage';

addDecorator(withLiveEditScope({ ExternalComponent }));

or

addDecorator to particular stories

import {withLiveEditScope} from 'storybook-addon-react-live-edit';
import ExternalComponent from 'a-apackage';

storiesOf("Demo", module)
  .addDecorator(withLiveEditScope({ React, ExternalComponent }))
  .addLiveSource('demo', `return <div>{scopeTest}</div>`);

Usage

When LiveEdit addon is registered with storybooks setAddon function new method addLiveSource to add a story from source provided as a string. This source can be edited in "Live edit" panel

storiesOf("Demo", module)
  .addLiveSource('demo', `return <div>{scopeTest}</div>`);

or

You can use withLiveEdit story creator

storiesOf("Demo", module)
  .add('demo', withLiveEdit(`return <div>{scopeTest}</div>`));

API

addLiveSource

addLiveSource(name, source[, scope]) 
  • name (string, required) - the story name
  • source (string, required) - story source to be rendered in preview and available for editing in "Live edit" panel
  • scope (object, optional) - variables provided to rendered story, these can be additional components, utilities or any other data. Scope is merged with all variables previously provided by withLiveEditScope decorators.

withLiveEdit

withLiveEdit(source[, scope]) 
  • source (string, required) - story source to be rendered in preview and available for editing in "Live edit" panel
  • scope (object, optional) - variables provided to rendered story, these can be additional components, utilities or any other data. Scope is merged with all variables previously provided by withLiveEditScope decorators.

withLiveEditScope decorator

withLiveEditScope(scope)
  • scope (object, required) - variables provided to rendered story, these can be additional components, utilities or any other data. Scope is merged with all variables previously provided by withLiveEditScope decorators. React should be imported and provided within the scope object.

Example

To run provided example execute following command, storybook will run on port 3000

yarn example