mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-09 00:19:13 +08:00
refactor(addons): extract base annotations interface
This commit is contained in:
parent
80dcaa1737
commit
3aff225263
@ -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);
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user