refactor(addons): extract base annotations interface

This commit is contained in:
wKich 2021-01-07 11:33:20 +01:00
parent 80dcaa1737
commit 3aff225263
No known key found for this signature in database
GPG Key ID: 78DA80A02E82FB89
3 changed files with 8 additions and 6 deletions

View File

@ -1,13 +1,12 @@
import React, { FC, useContext } from 'react';
import { document } from 'global';
import { Annotations, Args, BaseMeta } from '@storybook/addons';
import { Args, BaseAnnotations, BaseMeta } from '@storybook/addons';
import { Anchor } from './Anchor';
import { DocsContext, DocsContextProps } from './DocsContext';
import { getDocsStories } from './utils';
import { Component } from './types';
type MetaProps = BaseMeta<Component> &
Omit<Annotations<Args, any>, 'includeStories' | 'excludeStories'>;
type MetaProps = BaseMeta<Component> & BaseAnnotations<Args, any>;
function getFirstStoryId(docsContext: DocsContextProps): string {
const stories = getDocsStories(docsContext);

View File

@ -2,7 +2,7 @@ import React, { FunctionComponent, ReactNode, ElementType, ComponentProps } from
import { MDXProvider } from '@mdx-js/react';
import { resetComponents, Story as PureStory } from '@storybook/components';
import { toId, storyNameFromExport } from '@storybook/csf';
import { Annotations, Args } from '@storybook/addons';
import { Args, BaseAnnotations } from '@storybook/addons';
import { CURRENT_SELECTION } from './types';
import { DocsContext, DocsContextProps } from './DocsContext';
@ -11,7 +11,7 @@ export const storyBlockIdFromId = (storyId: string) => `story--${storyId}`;
type PureStoryProps = ComponentProps<typeof PureStory>;
type CommonProps = Omit<Annotations<Args, any>, 'includeStories' | 'excludeStories'> & {
type CommonProps = BaseAnnotations<Args, any> & {
height?: string;
inline?: boolean;
};

View File

@ -163,7 +163,7 @@ export type BaseDecorators<StoryFnReturnType> = Array<
(story: () => StoryFnReturnType, context: StoryContext) => StoryFnReturnType
>;
export interface Annotations<Args, StoryFnReturnType> {
export interface BaseAnnotations<Args, StoryFnReturnType> {
/**
* Dynamic data that are provided (and possibly updated by) Storybook and its addons.
* @see [Arg story inputs](https://github.com/storybookjs/storybook/blob/next/docs/src/pages/formats/component-story-format/index.md#args-story-inputs)
@ -189,7 +189,10 @@ export interface Annotations<Args, StoryFnReturnType> {
* @see [Decorators](https://storybook.js.org/docs/addons/introduction/#1-decorators)
*/
decorators?: BaseDecorators<StoryFnReturnType>;
}
export interface Annotations<Args, StoryFnReturnType>
extends BaseAnnotations<Args, StoryFnReturnType> {
/**
* Used to only include certain named exports as stories. Useful when you want to have non-story exports such as mock data or ignore a few stories.
* @example