Skip to content

Commit

Permalink
Merge pull request #12566 from storybookjs/feat/add-view-mode-to-context
Browse files Browse the repository at this point in the history
Core: Add viewMode to StoryContext
  • Loading branch information
shilman committed Sep 24, 2020
2 parents 33301ff + 5a40708 commit 610d9a3
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/addons/src/types.ts
Expand Up @@ -59,6 +59,7 @@ export type StoryContext = StoryIdentifier & {
argTypes: ArgTypes;
globals: Args;
hooks?: HooksContext;
viewMode?: ViewMode;
};

export interface WrapperSettings {
Expand Down
1 change: 1 addition & 0 deletions lib/client-api/README.md
Expand Up @@ -12,6 +12,7 @@ Each story is loaded via the `.add()` API and contains the follow attributes, wh
- `parameters` - static data about the story, see below.
- `args` - dynamic inputs to the story, see below.
- `hooks` - listeners that will rerun when the story changes or is unmounted, see `@storybook/addons`.
- `viewMode` - property that tells if the story is being rendered in Canvas or Docs tab. Values are `story` for canvas and `docs` for docs.

## Parameters

Expand Down
3 changes: 2 additions & 1 deletion lib/client-api/src/decorators.test.ts
Expand Up @@ -7,9 +7,10 @@ function makeContext(input: Record<string, any>): StoryContext {
id: 'id',
kind: 'kind',
name: 'name',
viewMode: 'story',
parameters: {},
...input,
};
} as StoryContext;
}

describe('client-api.decorators', () => {
Expand Down
1 change: 1 addition & 0 deletions lib/client-api/src/story_store.ts
Expand Up @@ -406,6 +406,7 @@ export default class StoryStore {
args: _stories[id].args,
argTypes,
globals: this._globals,
viewMode: this._selection?.viewMode,
});

// Pull out parameters.args.$ || .argTypes.$.defaultValue into initialArgs
Expand Down

0 comments on commit 610d9a3

Please sign in to comment.