• Stars
    star
    204
  • Rank 192,063 (Top 4 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 5 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🧩 Design with Playroom inside Storybook, using each story source as a starting point

Storybook Playroom Addon

npm package version Build status Dependencies status

🧩 Design with Playroom inside Storybook, using each story source as a starting point.

Demo

View demo β†’

Getting started

Note: Playroom must be set up and running before using this addon, see instructions.

npm install --save-dev storybook-addon-playroom
// .storybook/main.js
export default {
  addons: ['storybook-addon-playroom'],
}

Configuration

The addon can be configured via the playroom parameter. The following options are available:

Option Type Description Default
url string the Playroom URL http://localhost:9000
code string code to be used instead of story source
disable boolean whether to disable the addon false
reactElementToJSXStringOptions object react-element-to-jsx-string options { sortProps: false }

To configure for all stories, set the playroom parameter in .storybook/preview.js:

export const parameters = {
  playroom: {
    url: 'http://localhost:9000',
  },
}

You can also configure on per-story or per-component basis using parameter inheritance:

// Button.stories.js

// Use predefined code instead of story source in all Button stories
export default {
  title: 'Button',
  parameters: {
    playroom: {
      code: '<Button>Hello Button</Button>',
    },
  },
}

// Disable addon in Button/Large story only
export const Large = Template.bind({})
Large.parameters = {
  playroom: {
    disable: true,
  },
}

Note: Disabling the addon does not hide the Playroom tab from preview. For that, you must use Storybook's own previewTabs parameter:

Story.parameters = {
  previewTabs: {
    'storybook/playroom/panel': {
      hidden: true,
    },
  },
}

Generating Playroom snippets from stories

Note: This is an experimental feature.

Playroom addon comes with a sb-playroom CLI tool that can auto-generate Playroom snippets from Storybook stories via the gen-snippets command:

$ sb-playroom gen-snippets --help
Usage: sb-playroom gen-snippets [options] [config-dir]

generate Playroom snippets from stories (experimental)

Options:
  -o, --out-file <path>     output file (default: "snippets.json")
  -c, --config-file <path>  Babel config file
  -h, --help                display help for command

By default, gen-snippets will fetch the Storybook configuration from the .storybook directory and output the snippets to a snippets.json file. Different input and output paths can be passed as arguments.

You can then reference the output file in playroom.config.js.

Babel configuration

Because Playroom addon programmatically runs Storybook to collect story sources, Babel is used to compile stories on the fly. If the loaded Babel configuration does not work with your Storybook, a Babel config file can be defined with the -c, --config-file option.

More Repositories

1

resumed

πŸ‘” Lightweight JSON Resume builder, no-frills alternative to resume-cli
TypeScript
256
star
2

jest-it-up

πŸŒπŸ“ˆ Automatically bump up global Jest thresholds whenever coverage goes above them
JavaScript
62
star
3

devcpp-monokai

🎨 Monokai theme for Dev-C++
42
star
4

storybook-addon-paddings

πŸ”² A Storybook addon to add different paddings to your preview
TypeScript
29
star
5

jsonresume-theme-even

A flat JSON Resume theme, compatible with the latest resume schema
JavaScript
21
star
6

sro

πŸ“¦πŸ” Friendly Correios SRO API wrapper and command-line utility
JavaScript
11
star
7

matter-now

πŸ“… Append the current date to the YAML front matter of Markdown files
JavaScript
11
star
8

countryquest

πŸ—ΊοΈ An interactive scratch off map. Keep track of which places you have been, how much of the world you have conquered, and where to go next.
TypeScript
11
star
9

carteiro

🧒 A beautifully designed, free Android package tracking app for the Brazilian postal service
Java
10
star
10

metalsmith-collection-metadata

A Metalsmith plugin to add metadata to every file in a collection
JavaScript
10
star
11

metalsmith-move-up

A Metalsmith plugin for moving the full contents of a directory up one or more levels.
JavaScript
10
star
12

tweetscroll

Automatically show new tweets on Twitter web interface
JavaScript
4
star
13

episodic

πŸ“Ί An opinionated CLI tool to automatically rename TV show releases
JavaScript
4
star
14

rbardini.com

Rafael Bardini's blog
TypeScript
3
star
15

carteiro.app

Carteiro for Android's website
Astro
2
star
16

pokedex

πŸŽ’ A server-rendered universal JavaScript application for PokΓ©mon trainers
TypeScript
2
star
17

tweetspeak

Listen to any tweet in its original language on Twitter web interface
JavaScript
2
star
18

browseraxis

Easily retrieve the width and height of your browser viewport
HTML
1
star
19

html

Tiny html tag function for no-build JSX-like syntax, compatible with all modern browsers and runtimes.
TypeScript
1
star
20

colorexa

Quickly lookup for a color by typing its hexadecimal code
JavaScript
1
star
21

.github

1
star
22

bandeco

Isomorphic Flux application for checking out the meals served by the University Restaurant at USP SΓ£o Carlos
JavaScript
1
star
23

advent-of-code-2021

My solutions to the puzzles from Advent of Code 2021
JavaScript
1
star
24

dashes

A quick reference guide to the use of dashes
HTML
1
star
25

bandex

🍴 O que tem no bandejão hoje?
JavaScript
1
star
26

rbardini

1
star