playroom
Design with code, powered by your own component library
Last updated 3 days ago by seek-oss-ci .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install playroom 
SYNC missed versions from official npm registry.
Playroom

npm Build Status


Playroom Demo

Simultaneously design across a variety of themes and screen sizes, powered by JSX and your own component library.

Playroom allows you to create a zero-install code-oriented design environment, built into a standalone bundle that can be deployed alongside your existing design system documentation.

  • Iterate on your designs in the final medium.
  • Create quick mock-ups and interactive prototypes with real code.
  • Exercise and evaluate the flexibility of your design system.
  • Share your work with others by simply copying the URL.

Demos

SEEK Style Guide

Braid Design System (Themed)

Fannypack

Overdrive

Send us a PR if you'd like to be in this list!

Getting Started

$ npm install --save-dev playroom

Add the following scripts to your package.json:

{
  "scripts": {
    "playroom:start": "playroom start",
    "playroom:build": "playroom build"
  }
}

Add a playroom.config.js file to the root of your project:

module.exports = {
  components: './src/components',
  outputPath: './dist/playroom',

  // Optional:
  title: 'My Awesome Library',
  themes: './src/themes',
  snippets: './playroom/snippets.js',
  frameComponent: './playroom/FrameComponent.js',
  widths: [320, 375, 768, 1024],
  port: 9000,
  openBrowser: true,
  paramType: 'search', // default is 'hash'
  exampleCode: `
    <Button>
      Hello World!
    </Button>
  `,
  baseUrl: '/playroom/',
  webpackConfig: () => ({
    // Custom webpack config goes here...
  }),
  iframeSandbox: 'allow-scripts',
};

Note: port and openBrowser options will be set to 9000 and true (respectively) by default whenever they are omitted from the config above.

Your components file is expected to export a single object or a series of named exports. For example:

export { default as Text } from '../Text'; // Re-exporting a default export
export { Button } from '../Button'; // Re-exporting a named export
// etc...

The iframeSandbox option can be used to set the sandbox attribute on Playroom's iframe. A minimum of allow-scripts is required for Playroom to work.

Now that your project is configured, you can start a local development server:

$ npm run playroom:start

To build your assets for production:

$ npm run playroom:build

Snippets

Playroom allows you to quickly insert predefined snippets of code, providing live previews across themes and viewports as you navigate the list. These snippets can be configured via a snippets file that looks like this:

export default [
  {
    group: 'Button',
    name: 'Strong',
    code: `
      <Button weight="strong">
        Button
      </Button>
    `
  },
  ...
];

Custom Frame Component

If your components need to be nested within custom provider components, you can provide a custom React component file via the frameComponent option, which is a path to a file that exports a component. For example, if your component library has multiple themes:

import React from 'react';
import ThemeProvider from '../path/to/your/ThemeProvider';

export default ({ theme, children }) => (
  <ThemeProvider theme={theme}>{children}</ThemeProvider>
);

Theme Support

If your component library has multiple themes, you can customise Playroom to render every theme simultaneously via the themes configuration option.

Similar to your components file, your themes file is expected to export a single object or a series of named exports. For example:

export { themeA } from './themeA';
export { themeB } from './themeB';
// etc...

TypeScript Support

If a tsconfig.json file is present in your project, static prop types are parsed using react-docgen-typescript to provide better autocompletion in the Playroom editor.

By default, all .ts and .tsx files in the current working directory are included, excluding node_modules.

If you need to customise this behaviour, you can provide a typeScriptFiles option in playroom.config.js, which is an array of globs.

module.exports = {
  ...,
  typeScriptFiles: [
    'src/components/**/*.{ts,tsx}',
    '!**/node_modules'
  ]
};

Storybook Integration

If you are interested in integrating Playroom into Storybook, check out storybook-addon-playroom.

License

MIT.

Current Tags

  • 0.21.1                                ...           latest (3 days ago)

59 Versions

  • 0.21.1                                ...           3 days ago
  • 0.21.0                                ...           4 days ago
  • 0.20.0                                ...           4 days ago
  • 0.19.1                                ...           4 days ago
  • 0.19.0                                ...           4 days ago
  • 0.18.1                                ...           22 days ago
  • 0.18.0                                ...           22 days ago
  • 0.17.3                                ...           a month ago
  • 0.17.2                                ...           a month ago
  • 0.17.1                                ...           a month ago
  • 0.17.0                                ...           a month ago
  • 0.16.2                                ...           a month ago
  • 0.16.1                                ...           3 months ago
  • 0.16.0                                ...           3 months ago
  • 0.15.2                                ...           3 months ago
  • 0.15.1                                ...           4 months ago
  • 0.15.0                                ...           4 months ago
  • 0.14.5                                ...           5 months ago
  • 0.14.4                                ...           5 months ago
  • 0.14.3                                ...           5 months ago
  • 0.14.2                                ...           6 months ago
  • 0.14.1                                ...           6 months ago
  • 0.14.0                                ...           6 months ago
  • 0.13.1                                ...           6 months ago
  • 0.13.0                                ...           6 months ago
  • 0.12.0                                ...           6 months ago
  • 0.11.3                                ...           6 months ago
  • 0.11.2                                ...           6 months ago
  • 0.11.1                                ...           6 months ago
  • 0.11.0                                ...           6 months ago
  • 0.10.1                                ...           7 months ago
  • 0.10.0                                ...           7 months ago
  • 0.9.4                                ...           10 months ago
  • 0.9.3                                ...           10 months ago
  • 0.9.2                                ...           10 months ago
  • 0.9.1                                ...           a year ago
  • 0.9.0                                ...           a year ago
  • 0.8.2                                ...           a year ago
  • 0.8.1                                ...           a year ago
  • 0.8.0                                ...           a year ago
  • 0.7.2                                ...           a year ago
  • 0.7.1                                ...           a year ago
  • 0.7.0                                ...           a year ago
  • 0.6.0                                ...           a year ago
  • 0.5.3                                ...           2 years ago
  • 0.5.2                                ...           2 years ago
  • 0.5.1                                ...           2 years ago
  • 0.5.0                                ...           2 years ago
  • 0.4.3                                ...           2 years ago
  • 0.4.2                                ...           2 years ago
  • 0.4.1                                ...           2 years ago
  • 0.4.0                                ...           2 years ago
  • 0.3.1                                ...           2 years ago
  • 0.3.0                                ...           2 years ago
  • 0.2.0                                ...           2 years ago
  • 0.1.3                                ...           2 years ago
  • 0.1.2                                ...           2 years ago
  • 0.1.1                                ...           2 years ago
  • 0.1.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 183
This Month 183
Last Day 0
Last Week 121
Last Month 573
Dev Dependencies (19)

Copyright 2014 - 2016 © taobao.org |