0.3.1 • Published 3 years ago

storybook-class-stories v0.3.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Storybook Class Stories

ECMAScript / TypeScript decorator for class-style Storybook stories.

This library fully depends on storybook 6.x, so please read its README before using this library.

npm

Install

npm i -S storybook-class-stories

Decorators

  • @Story
  • @Template

Example

import { createButton } from './Button'
import { Story, Template } from 'storybook-class-stories'

const HtmlTemplate = ({ label, ...args }) => {
  return createButton({ label, ...args })
}

@Story({
  title: 'New way/Button Class'
})
class ButtonStory {
  @Template({
    template: HtmlTemplate.bind({}),
    args: {
      label: 'Button',
      primary: true
    }
  })
  Primary: Function

  @Template({
    template: HtmlTemplate.bind({}),
    args: { label: 'Button' }
  })
  Secondary: Function
}

module.exports = ButtonStory

is equivalent to

import { createButton } from './Button'
import { Story, Template } from 'storybook-class-stories'

const HtmlTemplate = ({ label, ...args }) => {
  return createButton({ label, ...args })
}

export default {
  title: 'New way/Button Class'
}

export const Primary = HtmlTemplate.bind({})

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


export const Secondary = HtmlTemplate.bind({})

Secondary.args = { label: 'Button' }

License

MIT

0.3.0

3 years ago

0.3.1

3 years ago

0.2.0

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago