Installations
npm install playroom
Score
60.8
Supply Chain
69.3
Quality
90.1
Maintenance
100
Vulnerability
92.6
License
Developer
seek-oss
Developer Guide
Module System
CommonJS
Min. Node Version
>=18.12.0
Typescript Support
Yes
Node Version
18.19.1
NPM Version
10.2.4
Statistics
4,495 Stars
216 Commits
185 Forks
44 Watching
21 Branches
49 Contributors
Updated on 19 Nov 2024
Bundle Size
5.46 kB
Minified
1.66 kB
Minified + Gzipped
Languages
TypeScript (90.03%)
JavaScript (9.95%)
Shell (0.02%)
Total Downloads
Cumulative downloads
Total Downloads
8,569,646
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
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
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.
- 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
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!
Getting Started
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
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:
1export default [ 2 { 3 group: 'Button', 4 name: 'Strong', 5 code: ` 6 <Button weight="strong"> 7 Button 8 </Button> 9 `, 10 }, 11 // etc... 12];
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:
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}
Custom Scope
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 };
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:
1export { themeA } from './themeA'; 2export { themeB } from './themeB'; 3// 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.
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};
ESM Support
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.
Storybook Integration
If you are interested in integrating Playroom into Storybook, check out storybook-addon-playroom.
Browser Support
Playroom is built to work on the latest stable versions of all major browsers. Some features may not work as expected in older browsers.
License
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
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/preview-site.yml:1
- Warn: no topLevel permission defined: .github/workflows/release.yml:1
- Warn: no topLevel permission defined: .github/workflows/snapshot.yml:1
- Warn: no topLevel permission defined: .github/workflows/validate.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/preview-site.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/seek-oss/playroom/preview-site.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/preview-site.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/seek-oss/playroom/preview-site.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/preview-site.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/seek-oss/playroom/preview-site.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/seek-oss/playroom/release.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/seek-oss/playroom/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/seek-oss/playroom/release.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/seek-oss/playroom/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/snapshot.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/seek-oss/playroom/snapshot.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/snapshot.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/seek-oss/playroom/snapshot.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/snapshot.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/seek-oss/playroom/snapshot.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/snapshot.yml:32: update your workflow using https://app.stepsecurity.io/secureworkflow/seek-oss/playroom/snapshot.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/validate.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/seek-oss/playroom/validate.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/validate.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/seek-oss/playroom/validate.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/validate.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/seek-oss/playroom/validate.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/validate.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/seek-oss/playroom/validate.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/validate.yml:42: update your workflow using https://app.stepsecurity.io/secureworkflow/seek-oss/playroom/validate.yml/master?enable=pin
- Info: 0 out of 10 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 6 third-party GitHubAction dependencies pinned
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 30 are checked with a SAST tool
Reason
23 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-c2jc-4fpr-4vhg
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-3q56-9cc2-46j4
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-8jhw-289h-jh2g
- Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986 / GHSA-64vr-g452-qvp3
- Warn: Project is vulnerable to: GHSA-9cwx-2883-4wfx
- Warn: Project is vulnerable to: GHSA-hc6q-2mpp-qw7j
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
Score
4.8
/10
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