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

CSF: Add CSF3 typings #15558

Merged
merged 5 commits into from Jul 13, 2021
Merged
Changes from 1 commit
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
22 changes: 18 additions & 4 deletions lib/addons/src/types.ts
Expand Up @@ -197,6 +197,14 @@ export interface BaseAnnotations<Args, StoryFnReturnType> {
* @see [Decorators](https://storybook.js.org/docs/addons/introduction/#1-decorators)
*/
decorators?: BaseDecorators<StoryFnReturnType>;
/**
* Define a custom render function for the story(ies). If not passed, a default render function by the framework will be used.
*/
render?: (args: Args, context: StoryContext) => StoryFnReturnType;
/**
* Function that can be executed after the story is rendered.
shilman marked this conversation as resolved.
Show resolved Hide resolved
*/
play?: Function;
}

export interface Annotations<Args, StoryFnReturnType>
Expand Down Expand Up @@ -263,11 +271,17 @@ export interface BaseMeta<ComponentType> {
subcomponents?: Record<string, ComponentType>;
}

export interface BaseStory<Args, StoryFnReturnType> {
(args: Args, context: StoryContext): StoryFnReturnType;

type BaseStoryObject<Args, StoryFnReturnType> = {
/**
* Override the display name in the UI
*/
storyName?: string;
}
};

type BaseStoryFn<Args, StoryFnReturnType> = {
(args: Args, context: StoryContext): StoryFnReturnType;
};
yannbf marked this conversation as resolved.
Show resolved Hide resolved

export type BaseStory<Args, StoryFnReturnType> =
| BaseStoryFn<Args, StoryFnReturnType>
| BaseStoryObject<Args, StoryFnReturnType>;