1.6.0 • Published 5 years ago

short-story v1.6.0

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

short-story

Beautiful component previews for design, docs and demos.

⚠️ Work in progress! The knobs API may change in future updates.

👉 CodeSandbox Demo.

Install

npm install --save short-story

Usage

ShortStory is a render props component. It accepts a prop knobs, an object describing different knobs, creates an interface for setting the values of those knobs, and passes those values into its child function.

See example for a collection of different knob types.

import React from "react"
import ReactDOM from "react-dom";
import ShortStory from "short-story"

import MyComponent from "./MyComponent"

const knobs = {
  text: {
    label: "Text Content",
    type: "text",
    default: "Click here!"
  },

function App() {
  return (
    <div className="App">
      <ShortStory knobs={knobs}>
        {(state) => <MyComponent text={state.text} />}
      </ShortStory>
    </div>
  );
}

const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);

The component calls its child function with an object argument that maps to the knobs prop it received, where each key evaluates to the current value of the knob as set through the interface it generates. (Easier seen than said.) In the example above, the component creates a text field for the knobs.text knob, and passes the value of that text field into the child function as state.text.

See https://codesandbox.io/s/3rwj7kqm15 for a full demo.

License

MIT © steveruizok

1.6.0

5 years ago

1.5.9

5 years ago

1.5.8

5 years ago

1.5.7

5 years ago

1.5.6

5 years ago

1.5.5

5 years ago

1.5.4

5 years ago

1.5.3

5 years ago

1.5.2

5 years ago

1.5.1

5 years ago

1.5.0

5 years ago

1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.3

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago