mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-18 05:02:24 +08:00
feat(client-api): add viewmode to context
This commit is contained in:
parent
33301ff771
commit
5a40708317
@ -59,6 +59,7 @@ export type StoryContext = StoryIdentifier & {
|
||||
argTypes: ArgTypes;
|
||||
globals: Args;
|
||||
hooks?: HooksContext;
|
||||
viewMode?: ViewMode;
|
||||
};
|
||||
|
||||
export interface WrapperSettings {
|
||||
|
@ -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
|
||||
|
||||
|
@ -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', () => {
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user