Skip to content

feat: link Playground and makeLiveEditStory through a shared id - #96

Merged
JeremyRH merged 1 commit into
mainfrom
feat/shared-code-editor-id
Jul 28, 2026
Merged

JeremyRH merged 1 commit into
mainfrom
feat/shared-code-editor-id

Conversation

@JeremyRH

@JeremyRH JeremyRH commented Jul 26, 2026 •

Copy link
Copy Markdown
Owner

Refs #95

Problem

Playground renders its preview itself, outside Storybook's story-rendering pipeline, so no decorators apply to it.

What this changes

Makes the store key something the user chooses, so the two halves can be linked by name.

  • makeLiveEditStory accepts an optional id, used as the store key instead of a generated one. Falls back to the previous generated id when omitted.
  • Playground's existing id prop now keys that same store.

Passing the same id to both wires them together:

// Button.stories.tsx
export const Editable: Story = {};

makeLiveEditStory(Editable, {
  id: 'button-demo',
  code: buttonSource,
  availableImports: { 'my-library': MyLibrary },
});
{/* Button.mdx */}
<Playground id="button-demo" Container={({ editor }) => editor} />

<Story of={ButtonStories.Editable} />

`makeLiveEditStory` accepts an optional `id`, and `Playground`'s existing `id`
prop now keys the shared store instead of a module-local map. Passing the same
id to both lets an editor rendered in MDX drive a story rendered by Storybook's
own pipeline, so decorators, args, and globals apply to the preview.

Refs #95

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@JeremyRH
JeremyRH merged commit bb84ca6 into main Jul 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant