1.0.4 • Published 9 months ago

storybook-react-live-decorator v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

storybook-react-live

react-live decorator for Storybook v6+

npm NPM

Screenshot

Screenshot

Demo

Installation

npm i -D storybook-react-live-decorator

Usage

// Component.stories.js

import { ReactLiveDecorator } from 'storybook-react-live-decorator';

const code = `() => (
  <Wrapper>
    <Button type="primary" size="large">
      Default
    </Button>
  </Wrapper>
)`;

export const LiveEdit = {
    decorators: [ReactLiveDecorator({ code, scope: { Button, Wrapper } })]
};

Props of ReactLiveDecorator

All props accepted by \<LiveProvider /> and:

NamePropTypeDescription
codePropTypes.stringCode string
scopePropTypes.objectscope object
themePropTypes.objectA prism-react-renderer existing theme or theme object. See more here
fontFamilyPropTypes.stringcss font-family to use in the edirot default monospace
debugPropTypes.boolLogs whatever goes through decorator into console.log

Extend globally via .storybook/preview.js

Add property reactLive to parameters object. Accepts: scope and theme

const preview = {
    parameters: {
        reactLive: {
            theme: themes.dracula, // import from `prism-react-renderer`
            scope: {Button, Wrapper},
            debug: false,
            fontFamily: 'monospace'
        }
    }
};

export default preview;

:)

1.0.4

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago