Skip to content

refactor(storybook): prototype configurable playground runtime - #36732

Draft
Martin Hochel (Hotell) wants to merge 21 commits into
microsoft:experimental/storybook-playgroundfrom
Hotell:prototype/pr-36728-playground-split
Draft

Martin Hochel (Hotell) wants to merge 21 commits into
microsoft:experimental/storybook-playgroundfrom
Hotell:prototype/pr-36728-playground-split

Conversation

@Hotell

Copy link
Copy Markdown
Contributor

Prototype alternative built on #36728.

Plan

  1. Ship the editor UI as a prebuilt @fluentui/react-playground shell.
  2. Keep @fluentui/react-storybook-addon-playground thin: serve the shell, add the Docs button, and extend the consumer's existing webpackFinal.
  3. Generate a consumer runtime from options.modules; bundle React, private/workspace packages, and an optional TSX setup module through Storybook Webpack.
  4. Derive Monaco declarations from the same module map and emit runtime chunks, typings, and a manifest with the Storybook build.
  5. Load the runtime only inside the playground preview iframe (sandbox="allow-scripts", without allow-same-origin) and exchange code/results through postMessage.

No CDN or esm.sh is required: private registry and workspace packages use the consumer's normal Webpack resolution.

Difference from #36728

Area #36728 This prototype
Package shape Addon, editor app, runtime dependencies, and typings in one package Prebuilt shell package plus thin Storybook addon
Runtime modules Hardcoded in modules.ts Configured with options.modules
Consumer setup Fluent provider, themes, and defaults hardcoded in the app Optional consumer-owned TSX setup module
Private packages Must be known and bundled by the playground package build Resolved by the consumer's Storybook Webpack configuration
React Bundled with the standalone app Bundled with the consumer runtime in the Storybook graph
Typings Separate hardcoded TYPINGS_ENTRIES list Derived from modules, plus optional declaration-only entries
User-code execution new Function runs in the main playground document Runs inside an opaque-origin sandboxed iframe
Runtime assets Statically coupled to the standalone app build Storybook emits chunks, typings, and manifest.json
Storybook Docs Playground code is part of the standalone bundle Runtime-only chunks are excluded from iframe.html to avoid loading another ReactDOM renderer

Dmytro Kirpa (dmytrokirpa) and others added 21 commits April 4, 2026 20:41
…or allowlisted dependencies and Prettier formatting
- branded header with primary Run action, compact icon-only toolbar on narrow screens
- pane headers with file name, IntelliSense and run status badges
- resizable editor/preview split (pointer + keyboard), stacked layout on narrow viewports
- Monaco editor theme derived from the active Fluent theme
- preview loading / error placeholders, error bar hint about the last successful render
- Ctrl/Cmd+Enter runs the code from the editor
…playground

- gradient canvas with floating card panes, glass header, gradient brand mark and Run button
- custom status pills (pulsing while compiling), file tab, dotted design-canvas preview with fade-in per run
- custom error panel and empty state
- curated GitHub-inspired syntax palettes for the light and dark editor themes, editor typography tweaks
…sign

- flat neutral canvas, bordered surfaces with a single 8px radius, no gradients / glass / shadows / animations
- standard Fluent primary button for Run, plain toolbar and dividers
- dot + label status indicators (color only for ready / error / warning), spinner while busy
- plain preview surface, flat error panel with a top border
Split the prebuilt playground shell from the Storybook addon and generate a consumer-owned Webpack runtime for private packages, typings, themes, and render setup.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 48843c58-937a-4d99-be29-9e0bb93d10bb
Keep playground-only Webpack chunks out of iframe.html while retaining shared chunks needed by Storybook. This prevents the runtime's ReactDOM renderer from corrupting Docs controls.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 48843c58-937a-4d99-be29-9e0bb93d10bb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants