Gathering detailed insights and metrics for playroom
Gathering detailed insights and metrics for playroom
Gathering detailed insights and metrics for playroom
Gathering detailed insights and metrics for playroom
npm install playroom
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
4,495 Stars
216 Commits
185 Forks
44 Watching
21 Branches
49 Contributors
Updated on 19 Nov 2024
Minified
Minified + Gzipped
TypeScript (90.03%)
JavaScript (9.95%)
Shell (0.02%)
Cumulative downloads
Total Downloads
Last day
-13.4%
13,450
Compared to previous day
Last week
14.5%
70,595
Compared to previous week
Last month
73.7%
290,813
Compared to previous month
Last year
11%
2,456,150
Compared to previous year
55
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.
Braid Design System (Themed)
Cubes (Themed)
Mesh Design System (Themed)
MÃstica Design System (Themed)
Send us a PR if you'd like to be in this list!
1$ npm install --save-dev playroom
Add the following scripts to your package.json
:
1{ 2 "scripts": { 3 "playroom:start": "playroom start", 4 "playroom:build": "playroom build" 5 } 6}
Add a playroom.config.js
file to the root of your project:
1module.exports = { 2 components: './src/components', 3 outputPath: './dist/playroom', 4 5 // Optional: 6 title: 'My Awesome Library', 7 themes: './src/themes', 8 snippets: './playroom/snippets.js', 9 frameComponent: './playroom/FrameComponent.js', 10 scope: './playroom/useScope.js', 11 widths: [320, 768, 1024], 12 port: 9000, 13 openBrowser: true, 14 paramType: 'search', // default is 'hash' 15 exampleCode: ` 16 <Button> 17 Hello World! 18 </Button> 19 `, 20 baseUrl: '/playroom/', 21 webpackConfig: () => ({ 22 // Custom webpack config goes here... 23 }), 24 iframeSandbox: 'allow-scripts', 25 defaultVisibleWidths: [ 26 // subset of widths to display on first load 27 ], 28 defaultVisibleThemes: [ 29 // subset of themes to display on first load 30 ], 31};
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:
1export { default as Text } from '../Text'; // Re-exporting a default export 2export { Button } from '../Button'; // Re-exporting a named export 3// 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:
1$ npm run playroom:start
To build your assets for production:
1$ npm run playroom:build
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:
1export default [ 2 { 3 group: 'Button', 4 name: 'Strong', 5 code: ` 6 <Button weight="strong"> 7 Button 8 </Button> 9 `, 10 }, 11 // etc... 12];
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:
1import React from 'react'; 2import { ThemeProvider } from '../path/to/your/theming-system'; 3 4export default function FrameComponent({ theme, children }) { 5 return <ThemeProvider theme={theme}>{children}</ThemeProvider>; 6}
You can provide extra variables within the scope of your JSX via the scope
option, which is a path to a file that exports a useScope
Hook that returns a scope object. For example, if you wanted to expose a context-based theme
variable to consumers of your Playroom:
1import { useTheme } from '../path/to/your/theming-system'; 2 3export default function useScope() { 4 return { 5 theme: useTheme(), 6 };
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:
1export { themeA } from './themeA'; 2export { themeB } from './themeB'; 3// etc...
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.
1module.exports = { 2 // ... 3 typeScriptFiles: ['src/components/**/*.{ts,tsx}', '!**/node_modules'], 4};
If you need to customise the parser options, you can provide a reactDocgenTypescriptConfig
option in playroom.config.js
.
For example:
1module.exports = { 2 // ... 3 reactDocgenTypescriptConfig: { 4 propFilter: (prop, component) => { 5 // ... 6 }, 7 }, 8};
Playroom supports loading ESM configuration files. By default, Playroom will look for a playroom config file with either a .js
, .mjs
or .cjs
file extension.
If you are interested in integrating Playroom into Storybook, check out storybook-addon-playroom.
Playroom is built to work on the latest stable versions of all major browsers. Some features may not work as expected in older browsers.
MIT.
No vulnerabilities found.
Reason
17 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
all changesets reviewed
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
23 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More