All Projects → SimeonC → storybook-xstate-addon

SimeonC / storybook-xstate-addon

Licence: MIT license
A storybook addon to assist with writing stories that rely on xstate

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects
shell
77523 projects

Projects that are alternatives of or similar to storybook-xstate-addon

storybook-addon-headless
A Storybook addon to preview content from a headless CMS in components
Stars: ✭ 23 (-52.08%)
Mutual labels:  addon, storybook, storybook-addon
storybook-addon-mock
This addon allows you to mock fetch or XMLHttpRequest in the storybook.
Stars: ✭ 67 (+39.58%)
Mutual labels:  addon, storybook, storybook-addon
storybook-styled-components
No description or website provided.
Stars: ✭ 76 (+58.33%)
Mutual labels:  addon, storybook
msw-storybook-addon
Mock API requests in Storybook with Mock Service Worker.
Stars: ✭ 168 (+250%)
Mutual labels:  addon, storybook
Storybook Addon A11y
REPO/PACKAGE MOVED - Storybook addon to help, improving accessibility within you're react components.
Stars: ✭ 37 (-22.92%)
Mutual labels:  addon, storybook
storybook-addon-next
A no config Storybook addon that makes Next.js features just work in Storybook
Stars: ✭ 184 (+283.33%)
Mutual labels:  addon, storybook
create-material-ui-app
create-react-app + storybook + storybook-addon-material-ui
Stars: ✭ 55 (+14.58%)
Mutual labels:  addon, storybook
Storybook Addon Material Ui
Addon for storybook wich wrap material-ui components into MuiThemeProvider. 📃 This helps and simplifies development of material-ui based components.
Stars: ✭ 513 (+968.75%)
Mutual labels:  addon, storybook
storybook-graphql-kit
Write GraphQL queries and pass response data to your components
Stars: ✭ 19 (-60.42%)
Mutual labels:  storybook, storybook-addon
React Storybook Addon Props Combinations
Given possible values for each prop, renders your component with all combinations of prop values.
Stars: ✭ 130 (+170.83%)
Mutual labels:  addon, storybook
Storybook Addon
Develop themable components with Emotion/Styled Components/Material-UI with help of Storybook & React Theming
Stars: ✭ 122 (+154.17%)
Mutual labels:  addon, storybook
Addon Smart Knobs
🧠 This Storybook plugin uses @storybook/addon-knobs but creates the knobs automatically based on PropTypes.
Stars: ✭ 215 (+347.92%)
Mutual labels:  addon, storybook
storybook-addon-intl
Addon to provide a locale switcher and react-intl for storybook
Stars: ✭ 84 (+75%)
Mutual labels:  storybook, storybook-addon
Storybook Addon Jest
REPO/PACKAGE MOVED - React storybook addon that show component jest report
Stars: ✭ 177 (+268.75%)
Mutual labels:  addon, storybook
storybook-addon-matrix
Storybook addon for rendering components with a matrix of props
Stars: ✭ 32 (-33.33%)
Mutual labels:  storybook, storybook-addon
Storycap
A Storybook Addon, Save the screenshot image of your stories 📷 via puppeteer.
Stars: ✭ 451 (+839.58%)
Mutual labels:  addon, storybook
storybook-addon-xd-designs
For adobe XD. Demo at https://morgs32.github.io/storybook-addon-xd-designs
Stars: ✭ 41 (-14.58%)
Mutual labels:  storybook, storybook-addon
Storybook Addon Preview
Storybook Addon Preview can show user selected knobs in various framework code in Storybook
Stars: ✭ 43 (-10.42%)
Mutual labels:  addon, storybook
Storybook Addon Styled Component Theme
storybook addon
Stars: ✭ 168 (+250%)
Mutual labels:  addon, storybook
Addon Jsx
This Storybook addon show you the JSX / template of the story
Stars: ✭ 209 (+335.42%)
Mutual labels:  addon, storybook

xState Storybook Addon

Installation

npm install -D @storybook/addons storybook-xstate-addon @xstate/inspect @xstate/react

Usage

To use this in storybook simply add addons: ["storybook-xstate-addon/preset"] to your storybook config.

If you want to enable the inspector in all stories, set the following in your /.storybook/preview.js file. With this setting on you can disable the inspector in certain stories

export const parameters = {
  xstate: true,
};

To enable the inspector in a single story/stories file, set the xstate parameter to true or an options object.

// this will turn on the inspector for all stories in the current file
export default {
  title: "Example",
  parameters: {
    xstate: true,
    // this option is passed to the inspect function
    xstateInspectOptions: {
      url: 'https://stately.ai/viz?inspect',
      serialize: null
    }
  },
};

// this turns the inspector on for only a single story
StoryComponent.parameters = {
  xstate: true,
};

To assist with viewing larger state charts, you can pass the height option in the xstate parameter to force the height of the inspector.

StoryComponent.parameters = {
  xstate: {
    height: "1000px",
  },
};

Additionally, you can send events to a machine by id when it is registered by adding the xstate parameter.

For more example usages see [./stories/Button.stories.tsx] and [./stories/Machines.stories.tsx].

StoryComponent.parameters = {
  xstate: {
    machine_id1: {
      events: "event",
    },
    machine_id2: {
      events: { type: "event" },
    },
    machine_id3: {
      events: [{ type: "event1" }, { type: "event2" }],
    },
    machine_id4: {
      events: (state) => "event",
    },
    machine_id5: {
      events: ["event1", "event2"],
      delay: 2.5e3, // milliseconds to delay before sending the next event
      shouldRepeatEvents: true, // for looping event sequences
    },
  },
};

If you wish to use the Inspector as the main story itself, simply use the following snippet (uses react).

import { RenderMachine } from 'storybook-xstate-addon/RenderMachine';

export const MachinePreview = () => <RenderMachine machine={confirmMachine.withConfig({ ... })} events={[...events]} />;
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].