Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: Add viewMode to StoryContext #12566

Merged
merged 1 commit into from Sep 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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