Merge pull request #32561 from amacleay/storybook__addon-info-decorator

@storybook/addon-info: Allow withInfo to be used as top-level story decorator
This commit is contained in:
Pranav Senthilnathan
2019-01-29 11:33:08 -08:00
committed by GitHub
2 changed files with 8 additions and 2 deletions

View File

@@ -6,7 +6,7 @@
// TypeScript Version: 2.8
import * as React from 'react';
import { RenderFunction } from '@storybook/react';
import { RenderFunction, StoryDecorator } from '@storybook/react';
export interface WrapStoryProps {
storyFn?: RenderFunction;
@@ -29,6 +29,10 @@ export interface Options {
maxPropStringLength?: number;
}
// TODO: it would be better to use type inference for the parameters
// type DecoratorParams = StoryDecorator extends (...a: infer A) => any ? A: never;
export function withInfo(story: RenderFunction, context: { kind: string, story: string }): ReturnType<StoryDecorator>;
// Legacy, but supported
export function withInfo(textOrOptions?: string | Options): (storyFn: RenderFunction) => (context?: object) => React.ReactElement<WrapStoryProps>;
export function setDefaults(newDefaults: Options): Options;

View File

@@ -1,11 +1,13 @@
/// <reference types="storybook__react" />
import * as React from 'react';
import { storiesOf } from '@storybook/react';
import { addDecorator, storiesOf } from '@storybook/react';
import { setDefaults, withInfo } from '@storybook/addon-info';
const { Component } = React;
addDecorator(withInfo);
setDefaults({
inline: false,
propTables: false