Skip to content

feat: add storyFrame reusable#20

Open
Guria wants to merge 1 commit into
mainfrom
feat/story-frame
Open

feat: add storyFrame reusable#20
Guria wants to merge 1 commit into
mainfrom
feat/story-frame

Conversation

@Guria

@Guria Guria commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Adds storyFrame — a module-level holder for the active Storybook Reatom frame.

  • setActiveStoryFrame(frame | null) / getActiveStoryFrame() (throws ReatomError when none is active).
  • Bridges Storybook's beforeEach (where the frame + per-story mock() overrides are created) and the decorator (which provides it via reatomContext.Provider), since they run in different scopes.
  • Complements the existing setupStorybookUrl item: use that when the decorator creates the frame; use this when beforeEach does.
  • Extracted from a production app (tolik-ux/my-replicad-app src/scene/story-frame.ts + .storybook/preview.tsx).

Runtime dependency-free (types from @reatom/core only); React/Storybook appear only in the .example.tsx. Tests cover throw-when-unset, set/return, clear, and reading state through frame.run.

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings July 13, 2026 23:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Module-level holder that bridges a Storybook beforeEach hook and the
render decorator, which run in different scopes. setActiveStoryFrame
stores the per-story RootFrame; getActiveStoryFrame reads it (throwing
a ReatomError when none is set) so the decorator can feed it to
reatomContext.Provider. Reset to null on cleanup to avoid leaking a
stale frame across stories.
@Guria
Guria force-pushed the feat/story-frame branch from 69c863f to 7a375f1 Compare July 13, 2026 23:48
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.

2 participants