close
Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

dreact/helper-book

It provides helpers for easier creating books with Storybook.

Example

import { storiesOf } from 'dreact/helper-book'

Exported

  • ⛔️ storiesOf (deprecated)

  • array

  • boolean

  • button

  • color

  • date

  • files

  • number

  • object

  • options

  • radios

  • select

  • text

  • action

Custom

  • Title

    Component to render the title in stories

  • List and Item

    Components to organize multiple items in one story

  • withState

    It allows creating stories with local state inside:

    import { withState } from 'dreact/helper-book'
    
    export default {
      title: 'Example',
    }
    
    export function Default() {
      return pug`
        p Hello, I'm a default message
      `
    }
    
    const initialState = { visible: false }
    
    export const Example = withState(initialState, ({ state }) => {
      return pug`
        button(onClick=() => state.toggle('visible')) Toggle
    
        = state.get('visible') ? 'Visible' : 'Hidden'
      `
    })

    state has the following interface:

    state.set(updates) // `updates` will be passedd to `this.setState`
    state.get([key]) // Will return the whole state or the value related to `key`
    state.toggle(key) // Will get value for key and set the negated version