npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

storybook-configurator

v1.2.0

Published

Easier Storybook testing / setting

Downloads

93

Readme

Storybook Configurator

A versatile tool to set up your components interactively and efficiently.

HOW TO USE

  1. install
npm install -d storybook-configurator
yarn add -d storybook-configurator
  1. Change the layout parameter into 'fullscreen'
layout: 'fullscreen'
  1. On render function on Story, set states you want to change with useControlState

  2. Create a array with controller

  3. Place em all with Dashboard!

Table of Contents

Common Props

The following props are shared across all components:

| Prop | Type | Description | | ------------- | ------ | ---------------------------- | | title | string | Title of the component | | description | string | Description of the component |

Dashboard Component

The Dashboard component acts as the primary container for your interactive stories.

Props

| Prop | Type | Description | | ---------- | -------------------- | ---------------------------------------------------- | | controls | ReactNode[] | Array of control components to be placed on the left | | option | { minWidth: number } | Configuration option for the dashboard | | children | ReactNode | Components to display in the main area |

option

  • minWidth : minimum width of control section

Example Usage

const [state, setState] = useControlState({
    numberarray: [1, 2, 3],
    numberinput: 1,
    numberslider: 1,
    objecteditor: { key: 'value' },
    colorpicker: '#ff0000',
    textarray: ['one', 'two', 'three'],
    textinput: 'text',
    textselect: 'o',
    booltoggle: true,
});

const textselectOptions = ['one', 'two', 'three'];

const controls = [
    <NumberArray
        title="Number Array"
        description="Modify an array of numbers"
        key="numberarray"
        value={state.numberarray}
        setValue={setState.numberarray}
    />,
    <NumberInput
        title="Number Input"
        description="Input a single number"
        key="numberinput"
        value={state.numberinput}
        setValue={setState.numberinput}
    />,
    <NumberSlider
        title="Number Slider"
        description="Slide to select a number"
        key="numberslider"
        value={state.numberslider}
        setValue={setState.numberslider}
        option={{
            showInput: false,
        }}
    />,
    <ObjectEditor
        title="Object Editor"
        description="Edit an object"
        key="objecteditor"
        value={state.objecteditor}
        setValue={setState.objecteditor}
    />,
    <ColorPicker
        title="Color Picker"
        description="Pick a color"
        key="colorpicker"
        value={state.colorpicker}
        setValue={setState.colorpicker}
    />,
    <TextArray
        title="Text Array"
        description="Modify an array of text"
        key="textarray"
        value={state.textarray}
        setValue={setState.textarray}
    />,
    <TextInput
        title="Text Input"
        description="Input a single text"
        key="textinput"
        value={state.textinput}
        setValue={setState.textinput}
    />,
    <TextSelector
        title="Text Selector"
        description="Select a text from options"
        key="textselect"
        value={state.textselect}
        setValue={setState.textselect}
        select={textselectOptions}
    />,
    <BoolToggle
        title="Boolean Toggle"
        description="Toggle a boolean value"
        key="booltoggle"
        value={state.booltoggle}
        setValue={setState.booltoggle}
    />,
];

return (
    <Dashboard
        controls={controls}
        title="Dashboard"
        description="This is Dashboard for storybook"
    >
        <div>
            <h2>Interactive Controls</h2>
            <ul>
                <li>Number Array: {state.numberarray.join(', ')}</li>
                <li>Number Input: {state.numberinput}</li>
                <li>Number Slider: {state.numberslider}</li>
                <li>Object Editor: {JSON.stringify(state.objecteditor)}</li>
                <li>
                    Color Picker:{' '}
                    <span style={{ color: state.colorpicker }}>{state.colorpicker}</span>
                </li>
                <li>Text Array: {state.textarray.join(', ')}</li>
                <li>Text Input: {state.textinput}</li>
                <li>Text Selector: {state.textselect}</li>
                <li>Boolean Toggle: {state.booltoggle ? 'true' : 'false'}</li>
            </ul>
        </div>
    </Dashboard>
);

State Management

useControlState Hook

The useControlState hook simplifies managing multiple states for controls in your Storybook.

const [state, setState] = useControlState({
    numberarray: [1, 2, 3],
    numberinput: 1,
    numberslider: 1,
    objecteditor: { key: 'value' },
    colorpicker: '#ff0000',
    textarray: ['one', 'two', 'three'],
    textinput: 'text',
    textselect: 'one',
    booltoggle: true,
});

// Usage
state.numberarray; // Get the current state value

setState.numberarray([1, 3]); // Update the state with a new array
setState.numberarray((prev) => prev.filter((item) => item !== 1)); // Works like useState

How to deal with types

empty array
  • use as to set types for array
const [state, setState] = useControlState({
    numberarray: [] as number[],
    stringarray: [] as string[],
})

Control Components

1. NumberArray

A component for modifying an array of numbers.

Example

<NumberArray
    title="Number Array"
    description="Modify an array of numbers"
    key="numberarray"
    value={state.numberarray}
    setValue={setState.numberarray}
/>

Type

| Property | Type | Required | Description | | ---------- | ---------------------------------- | -------- | ------------------------ | | value | number[] | Yes | Current array of numbers | | setValue | Dispatch<SetStateAction<number[]>> | Yes | State setter function |

2. NumberInput

A component for entering a single numeric value.

Option

option?: {
    min?: number;
    // Minimum allowable input
    max?: number;
    // Maximum allowable input
    step?: number;
    // Step intervals for the input buttons
};

Example

<NumberInput
    title="Number Input"
    description="Input a single number"
    key="numberinput"
    value={state.numberinput}
    setValue={setState.numberinput}
/>

Type

| Property | Type | Required | Description | | ---------- | --------------------------------- | -------- | --------------------- | | value | number | Yes | Current number value | | setValue | Dispatch<SetStateAction<number>> | Yes | State setter function | | option | option | No | Configuration options |

3. NumberSlider

A slider for selecting numeric values.

Option

option?: {
    min?: number;
    // Minimum slider value
    max?: number;
    // Maximum slider value
    step?: number;
    // Step increment for the slider
    showInput?: boolean;
    // Display an input box below the slider
};

Example

<NumberSlider
    title="Number Slider"
    description="Slide to select a number"
    key="numberslider"
    value={state.numberslider}
    setValue={setState.numberslider}
    option={{
        showInput: false,
    }}
/>

Type

| Property | Type | Required | Description | | ---------- | --------------------------------- | -------- | ---------------------------- | | value | number | Yes | Current slider value | | setValue | Dispatch<SetStateAction<number>> | Yes | State setter function | | option | option | No | Slider configuration options |

4. ObjectEditor

A component for editing objects and arrays.

Option

option?: {
    height?: string;
    // Editor display height
    readOnly?: boolean;
    // Specifies if the editor is read-only
};

Example

<ObjectEditor
    title="Object Editor"
    description="Edit an object"
    key="objecteditor"
    value={state.objecteditor}
    setValue={setState.objecteditor}
/>

Type

| Property | Type | Required | Description | | ---------- | ---------------------------------- | -------- | ---------------------------- | | value | unknown | Yes | Current object value | | setValue | Dispatch<SetStateAction<unknown>> | Yes | State setter function | | option | ObjectEditorOptions | No | Editor configuration options |

5. ColorPicker

A component for selecting and displaying colors.

Example

<ColorPicker
    title="Color Picker"
    description="Pick a color"
    key="colorpicker"
    value={state.colorpicker}
    setValue={setState.colorpicker}
/>

Type

| Property | Type | Required | Description | | ---------- | --------------------------------- | -------- | -------------------------------- | | value | string | Yes | Current color value (hex format) | | setValue | Dispatch<SetStateAction<string>> | Yes | State setter function |

6. TextArray

A component for managing an array of text values.

Example

<TextArray
    title="Text Array"
    description="Modify an array of text"
    key="textarray"
    value={state.textarray}
    setValue={setState.textarray}
/>

Type

| Property | Type | Required | Description | | ---------- | ---------------------------------- | -------- | ------------------------ | | value | string[] | Yes | Current array of strings | | setValue | Dispatch<SetStateAction<string[]>> | Yes | State setter function |

7. TextInput

A component for entering text values.

Option

option?: {
    placeholder?: string;
    // Placeholder text for the input field
    maxLength?: number;
    // Maximum character length allowed
};

Example

<TextInput
    title="Text Input"
    description="Input a single text"
    key="textinput"
    value={state.textinput}
    setValue={setState.textinput}
/>

Type

| Property | Type | Required | Description | | ---------- | --------------------------------- | -------- | --------------------------- | | value | string | Yes | Current text value | | setValue | Dispatch<SetStateAction<string>> | Yes | State setter function | | option | option | No | Input configuration options |

8. TextSelector

A dropdown component for choosing from predefined options.

Example

const textselectOptions = ['one', 'two', 'three'];

<TextSelector
    title="Text Selector"
    description="Select a text from options"
    key="textselect"
    value={state.textselect}
    setValue={setState.textselect}
    select={textselectOptions}
/>;

Type

| Property | Type | Required | Description | | ---------- | --------------------------------- | -------- | --------------------------- | | value | string | Yes | Current selected value | | setValue | Dispatch<SetStateAction<string>> | Yes | State setter function | | select | string[] | Yes | Array of selectable options |

9. TextArea

A component for entering multi lined text values.

Example

<TextArea
    title="Text Area"
    description="Input a large text"
    key="textarea"
    value={state.textarea}
    setValue={setState.textarea}
    option={{
        maxLength: 100,
        maxLines: 10,
    }}
/>

Option

option?: {
    placeholder?: string;
    // Placeholder for string
    maxLength?: number;
    // Maximum length
    maxLines?: number;
    // Maximum lines
};

Type

| Property | Type | Required | Description | | ---------- | --------------------------------- | -------- | ---------------------- | | value | string | Yes | Current selected value | | setValue | Dispatch<SetStateAction<string>> | Yes | State setter function |

10. BoolToggle

A switch for toggling boolean values.

Example

<BoolToggle
    title="Boolean Toggle"
    description="Toggle a boolean value"
    key="booltoggle"
    value={state.booltoggle}
    setValue={setState.booltoggle}
/>

Type

| Property | Type | Required | Description | | ---------- | ---------------------------------- | -------- | --------------------- | | value | boolean | Yes | Current toggle state | | setValue | Dispatch<SetStateAction<boolean>> | Yes | State setter function |