feat(client-api): add viewmode to context

This commit is contained in:
Yann Braga 2020-09-24 13:03:28 +02:00
parent 33301ff771
commit 5a40708317
4 changed files with 5 additions and 1 deletions

View File

@ -59,6 +59,7 @@ export type StoryContext = StoryIdentifier & {
argTypes: ArgTypes;
globals: Args;
hooks?: HooksContext;
viewMode?: ViewMode;
};
export interface WrapperSettings {

View File

@ -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

View File

@ -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', () => {

View File

@ -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