JSPM

@toptal/davinci-storybook-live-edit-addon

0.2.3-alpha-fx-3225-convert-davinci-workflow-to-esm-f0681463.42+f0681463
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 12
  • Score
    100M100P100Q136361F
  • License ISC

Live edit addon for Storybook

Package Exports

  • @toptal/davinci-storybook-live-edit-addon
  • @toptal/davinci-storybook-live-edit-addon/dist/preset.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@toptal/davinci-storybook-live-edit-addon) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Storybook Addon Live Edit

Storybook Addon Live Edit allows user editing code in realtime

Installation

1. Install addon

yarn add -D @toptal/davinci-storybook-live-edit-addon

2. Register this addon to Storybook

module.exports = {
  addons: ['@toptal/davinci-storybook-live-edit-addon']
}

This live-edit addon also brings @toptal/davinci-storybook-theme.

Usage

Instead of overriding the whole Canvas, this addon extends the default DocStory component and keeps default Canvas. Basically, it adds a new button Live Edit next to Show Code button.

NOTE: You must specify a scope for each story, beforehand. It means, all variables that are used inside story must be specified inside the scope

// extra variables that are used inside stories
const extraVariable = 1;
const MyCustomComponent = () => null

export default {
  title: 'Example/Button',
  component: Button,
  parameters: {
    scope: {
      // all variables that are used inside stories must be defined inside the scope
      Button,
      extraVariable,
      MyCustomComponent
    },
  },
} as ComponentMeta<typeof Button>;

export const Primary = (args) => {
  return (
    <MyCustomComponent> // <-- MyCustomComponent must be defined
      <Button {...args}> // <-- Button must be defined
        {extraVariable} // <-- extraVariable must be defined
      </Button>
    </MyCustomComponent>
  )
};

Primary.args = {
  primary: true,
  label: 'Button',
};

Implementation

This addon uses react-live under the hood.