GithubHelp home page GithubHelp logo

mondaycom / storybook-addon-playground Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 0.0 1.4 MB

Storybook plugin to enable a playground

License: MIT License

JavaScript 0.93% TypeScript 92.81% CSS 5.23% Mermaid 1.03%

storybook-addon-playground's Introduction

Playground - Storybook Addon

This addon enhances your Storybook experience by allowing you to interactively play with your components. It's perfect for developers looking to experiment in real time, debug issues, or build complex compositions.

img.png

Installation

To install the addon, run one of the following commands in your project directory:

yarn add -D storybook-addon-playground
# or
npm install -D storybook-addon-playground

Configuration

Add the addon to your Storybook configuration in .storybook/main.js or .storybook/main.ts:

const config = {
  addons: [
    // rest of your addons ...
    "storybook-addon-playground",
  ],
};

The addon configuration is done through Storybook's preview parameters.

Parameter Required Default Description
storyId true The story id that your playground has on Storybook.
components true An object with the components that should be rendered in the playground. The key is the component name and the value is the component itself.
autocompletions false [] An array of autocompletions that should be used on the playground. Recommended to use react-docgen for generating documentation outputs.
editorTheme false Your Storybook theme The theme that should be used on the playground.
initialCode false Empty editor The initial code ("welcome") that should be rendered on the playground.
share false false Whether to allow share capabilities.

On your .storybook/preview.ts file, you should add something similar to the following:

import MyComponentsLibrary from "my-components-library";
import MyIconsLibrary from "my-icons-library";
import reactDocgenOutput from "./react-docgen-output.json";
import { generateAutocompletions } from "storybook-addon-playground";

const preview = {
  parameters: {
    playground: {
      storyId: "playground",
      components: { ...MyComponentsLibrary, ...MyIconsLibrary },
      autocompletions: generateAutocompletions(reactDocgenOutput),
      editorTheme: "light",
      introCode: { jsx: `<div>Welcome to my Playground!</div>`, css: "" },
    },
  },
};

Set up the playground environment in your Storybook stories:

import { withPlayground } from "storybook-addon-playground";

export default {
  title: "Playground",
  decorators: [withPlayground],
};

export const Playground = {};

Usage

To use the Playground, navigate to the Storybook UI and select a story that has the playground decorator. In your addons panel, see an interactive code editor alongside your component, where you can modify the code and immediately see your changes reflected.

Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request.

Develop locally

Install dependencies and start

yarn
yarn start

Go to localhost:6006

Add new icons

Icons are generated using svgr.

In order to add new icons to the addon, drop the icons somewhere in the repo and run the following command:

yarn build:icons path/to/your/icons

Build

Rollup

Rollup is used to build the addon for publishing.

Vite

Vite serves the build to a local Storybook for testing and dev purposes.

storybook-addon-playground's People

Contributors

yossisaadi avatar talkor avatar

Stargazers

 avatar Shlomi Toussia-Cohen avatar  avatar  avatar

Watchers

Shlomi Toussia-Cohen avatar  avatar  avatar

storybook-addon-playground's Issues

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can fix this πŸ’ͺ.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here are some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Invalid npm token.

The npm token configured in the NPM_TOKEN environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/.

If you are using Two Factor Authentication for your account, set its level to "Authorization only" in your account settings. semantic-release cannot publish with the default "
Authorization and writes" level.

Please make sure to set the NPM_TOKEN environment variable in your CI with the exact value of the npm token.


Good luck with your project ✨

Your semantic-release bot πŸ“¦πŸš€

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can fix this πŸ’ͺ.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here are some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Invalid npm token.

The npm token configured in the NPM_TOKEN environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/.

If you are using Two Factor Authentication for your account, set its level to "Authorization only" in your account settings. semantic-release cannot publish with the default "
Authorization and writes" level.

Please make sure to set the NPM_TOKEN environment variable in your CI with the exact value of the npm token.


Good luck with your project ✨

Your semantic-release bot πŸ“¦πŸš€

Feature: Option to Disable Playground for Certain Stories

Is it possible to disable the playground addon for certain stories? I'd like it to only show up on the Playground story I created, but currently it shows up in all of them. Maybe a parameter option to disable playground on a per-story basis?

It should be installed `classnames` package

storybook-addon-playground need to install the classnames package, can you please remove this dependency and deploy it?

✘ [ERROR] Could not resolve "classnames"

    node_modules/storybook-addon-playground/dist/components/Editor/EditorTab.js:3:15:
      3 β”‚ import cx from 'classnames';
        β•΅                ~~~~~~~~~~~~

  You can mark the path "classnames" as external to exclude it from the bundle, which will remove
  this error.

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can fix this πŸ’ͺ.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here are some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Invalid npm token.

The npm token configured in the NPM_TOKEN environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/.

If you are using Two Factor Authentication for your account, set its level to "Authorization only" in your account settings. semantic-release cannot publish with the default "
Authorization and writes" level.

Please make sure to set the NPM_TOKEN environment variable in your CI with the exact value of the npm token.


Good luck with your project ✨

Your semantic-release bot πŸ“¦πŸš€

Bug: editorState undefined on load

Everything is set up the way it is in the documentation. The playground story renders correctly for a second but then crashes with this error. I am on Storybook 7.2.0 with React 16.9.0 and Webpack 5
Screenshot 2024-05-13 at 2 56 43β€―PM

Panel.tsx:83 Uncaught TypeError: Cannot read properties of undefined (reading 'undefined')
    at Panel.tsx:83:13
    at updateMemo (chunk-SJD7EFYL.js:69:12591)
    at Object.useMemo (chunk-SJD7EFYL.js:69:23917)
    at useMemo (chunk-DP4DR4LA.js:9:1378)
    at Rxe (Panel.tsx:81:30)
    at renderWithHooks (chunk-SJD7EFYL.js:69:936)
    at updateFunctionComponent (chunk-SJD7EFYL.js:69:48263)
    at beginWork (chunk-SJD7EFYL.js:71:21338)
    at HTMLUnknownElement.callCallback2 (chunk-SJD7EFYL.js:2:1918)
    at Object.invokeGuardedCallbackDev (chunk-SJD7EFYL.js:2:2442)
chunk-SJD7EFYL.js:75 The above error occurred in the <Rxe> component:
    in Rxe
    in div (created by Styled(div))
    in Styled(div)
    in div (created by Styled(div))
    in Styled(div)
    in Unknown
    in Unknown
    in Unknown
    in Unknown (created by ManagerConsumer)
    in ManagerConsumer (created by Panel2)
    in Panel2 (created by Layout)
    in div (created by Styled(div))
    in Styled(div) (created by Panel)
    in Panel (created by Layout)
    in div (created by ToggleVisibility)
    in ToggleVisibility (created by QueryLocation)
    in QueryLocation (created by QueryMatch)
    in QueryMatch (created by Route)
    in Route (created by Layout)
    in div (created by ToggleVisibility)
    in ToggleVisibility (created by QueryLocation)
    in QueryLocation (created by QueryMatch)
    in QueryMatch (created by Route)
    in Route (created by Layout)
    in div (created by Styled(div))
    in Styled(div) (created by Main)
    in div (created by Styled(div))
    in Styled(div) (created by Main)
    in Main (created by Layout)
    in Layout (created by WithTheme(Layout))
    in WithTheme(Layout)
    in Unknown (created by App)
    in div (created by Styled(div))
    in Styled(div) (created by App)
    in App
    in ThemeProvider
    in Unknown (created by ManagerConsumer)
    in ManagerConsumer (created by Manager)
    in EffectOnMount (created by Manager)
    in Manager (created by QueryLocation)
    in QueryLocation (created by Main2)
    in Main2 (created by Root4)
    in Router (created by LocationProvider)
    in LocationProvider (created by Root4)
    in HelmetProvider (created by Root4)
    in Root4```

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.