Skip to content

Commit

Permalink
Merge pull request #101 from ComponentDriven/next
Browse files Browse the repository at this point in the history
Release 0.1.10
  • Loading branch information
kasperpeulen authored Jul 2, 2024
2 parents edba426 + ed816ed commit 22c3d22
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 25 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"@storybook/eslint-config-storybook"
],
"rules": {
"@typescript-eslint/no-empty-interface": "off",
"import/no-unresolved": "error",
"jest/expect-expect": [
"warn",
Expand Down
51 changes: 26 additions & 25 deletions src/story.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export interface StrictGlobalTypes {
[name: string]: StrictInputType;
}

export type Renderer = {
export interface Renderer {
/** What is the type of the `component` annotation in this renderer? */
component: unknown;

Expand All @@ -215,7 +215,7 @@ export type Renderer = {
// This generic type will eventually be filled in with TArgs
// Credits to Michael Arnaldi.
T?: unknown;
};
}

/** @deprecated - use `Renderer` */
export type AnyFramework = Renderer;
Expand Down Expand Up @@ -247,13 +247,6 @@ export interface StoryContextUpdate<TArgs = Args> {
}

export type ViewMode = 'story' | 'docs';
export interface StoryContextForLoaders<TRenderer extends Renderer = Renderer, TArgs = Args>
extends StoryContextForEnhancers<TRenderer, TArgs>,
Required<StoryContextUpdate<TArgs>> {
hooks: unknown;
viewMode: ViewMode;
originalStoryFn: StoryFn<TRenderer>;
}

export type LoaderFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (
context: StoryContextForLoaders<TRenderer, TArgs>
Expand All @@ -268,27 +261,37 @@ export type BeforeEach<TRenderer extends Renderer = Renderer, TArgs = Args> = (
context: StoryContext<TRenderer, TArgs>
) => Awaitable<CleanupCallback | void>;

export interface Canvas {}

export interface StoryContext<TRenderer extends Renderer = Renderer, TArgs = Args>
extends StoryContextForLoaders<TRenderer, TArgs> {
extends StoryContextForEnhancers<TRenderer, TArgs>,
Required<StoryContextUpdate<TArgs>> {
loaded: Record<string, any>;
abortSignal: AbortSignal;
canvasElement: TRenderer['canvasElement'];
hooks: unknown;
originalStoryFn: StoryFn<TRenderer>;
viewMode: ViewMode;
step: StepFunction<TRenderer, TArgs>;
context: this;
canvas: Canvas;
}

/** @deprecated Use {@link StoryContext} instead. */
export interface StoryContextForLoaders<TRenderer extends Renderer = Renderer, TArgs = Args>
extends StoryContext<TRenderer, TArgs> {}

/** @deprecated Use {@link StoryContext} instead. */
export interface PlayFunctionContext<TRenderer extends Renderer = Renderer, TArgs = Args>
extends StoryContext<TRenderer, TArgs> {}

export type StepLabel = string;

export type StepFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (
label: StepLabel,
play: PlayFunction<TRenderer, TArgs>
) => Promise<void> | void;

export type PlayFunctionContext<TRenderer extends Renderer = Renderer, TArgs = Args> = StoryContext<
TRenderer,
TArgs
> & {
step: StepFunction<TRenderer, TArgs>;
};

export type PlayFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (
context: PlayFunctionContext<TRenderer, TArgs>
) => Promise<void> | void;
Expand Down Expand Up @@ -327,10 +330,10 @@ export type DecoratorApplicator<TRenderer extends Renderer = Renderer, TArgs = A
export type StepRunner<TRenderer extends Renderer = Renderer, TArgs = Args> = (
label: StepLabel,
play: PlayFunction<TRenderer, TArgs>,
context: PlayFunctionContext<TRenderer, TArgs>
context: StoryContext<TRenderer, TArgs>
) => Promise<void>;

export type BaseAnnotations<TRenderer extends Renderer = Renderer, TArgs = Args> = {
export interface BaseAnnotations<TRenderer extends Renderer = Renderer, TArgs = Args> {
/**
* Wrapper components or Storybook decorators that wrap a story.
*
Expand Down Expand Up @@ -384,12 +387,10 @@ export type BaseAnnotations<TRenderer extends Renderer = Renderer, TArgs = Args>
* Named tags for a story, used to filter stories in different contexts.
*/
tags?: Tag[];
};
}

export type ProjectAnnotations<
TRenderer extends Renderer = Renderer,
TArgs = Args
> = BaseAnnotations<TRenderer, TArgs> & {
export interface ProjectAnnotations<TRenderer extends Renderer = Renderer, TArgs = Args>
extends BaseAnnotations<TRenderer, TArgs> {
argsEnhancers?: ArgsEnhancer<TRenderer, Args>[];
argTypesEnhancers?: ArgTypesEnhancer<TRenderer, Args>[];

Expand All @@ -414,7 +415,7 @@ export type ProjectAnnotations<
globalTypes?: GlobalTypes;
applyDecorators?: DecoratorApplicator<TRenderer, Args>;
runStep?: StepRunner<TRenderer, TArgs>;
};
}

type StoryDescriptor = string[] | RegExp;
export interface ComponentAnnotations<TRenderer extends Renderer = Renderer, TArgs = Args>
Expand Down

0 comments on commit 22c3d22

Please sign in to comment.