mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-06 15:31:16 +08:00
consolidate shared.ts with types.ts
This commit is contained in:
parent
6dfcb4cf6b
commit
0e9629b106
@ -1,9 +1,8 @@
|
||||
import React, { FunctionComponent, useContext } from 'react';
|
||||
import { Description, DescriptionProps as PureDescriptionProps } from '@storybook/components';
|
||||
import { DocsContext, DocsContextProps } from './DocsContext';
|
||||
import { Component, CURRENT_SELECTION } from './shared';
|
||||
import { Component, CURRENT_SELECTION, DescriptionSlot } from './shared';
|
||||
import { str } from '../lib/docgen/utils';
|
||||
import { DescriptionSlot } from './types';
|
||||
|
||||
export enum DescriptionType {
|
||||
INFO = 'info',
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, { FunctionComponent } from 'react';
|
||||
import { DocsPageProps } from './types';
|
||||
import { DocsPageProps } from './shared';
|
||||
import { Title } from './Title';
|
||||
import { Subtitle } from './Subtitle';
|
||||
import { Description } from './Description';
|
||||
|
@ -1,6 +1,6 @@
|
||||
import React, { FunctionComponent } from 'react';
|
||||
import { Subheading } from './Subheading';
|
||||
import { DocsStoryProps } from './types';
|
||||
import { DocsStoryProps } from './shared';
|
||||
import { Anchor } from './Anchor';
|
||||
import { Description } from './Description';
|
||||
import { Story } from './Story';
|
||||
|
@ -2,7 +2,7 @@ import React, { useContext, FunctionComponent } from 'react';
|
||||
import { DocsContext } from './DocsContext';
|
||||
import { DocsStory } from './DocsStory';
|
||||
import { getDocsStories } from './utils';
|
||||
import { StorySlot } from './types';
|
||||
import { StorySlot } from './shared';
|
||||
|
||||
interface PrimaryProps {
|
||||
slot?: StorySlot;
|
||||
|
@ -1,6 +1,6 @@
|
||||
import React, { FunctionComponent } from 'react';
|
||||
import { Props } from './Props';
|
||||
import { PropsSlot } from './types';
|
||||
import { PropsSlot } from './shared';
|
||||
|
||||
interface PrimaryPropsProps {
|
||||
slot?: PropsSlot;
|
||||
|
@ -1,13 +1,11 @@
|
||||
import React, { FunctionComponent, useContext } from 'react';
|
||||
import { PropsTable, PropsTableError, PropsTableProps, TabsState } from '@storybook/components';
|
||||
import { DocsContext, DocsContextProps } from './DocsContext';
|
||||
import { Component, CURRENT_SELECTION } from './shared';
|
||||
import { getComponentName } from './utils';
|
||||
import { Component, PropsSlot, CURRENT_SELECTION } from './shared';
|
||||
|
||||
import { PropsExtractor } from '../lib/docgen/types';
|
||||
import { extractProps as reactExtractProps } from '../frameworks/react/extractProps';
|
||||
import { extractProps as vueExtractProps } from '../frameworks/vue/extractProps';
|
||||
import { PropsSlot } from './types';
|
||||
|
||||
interface PropsProps {
|
||||
exclude?: string[];
|
||||
|
@ -3,7 +3,7 @@ import { DocsContext } from './DocsContext';
|
||||
import { DocsStory } from './DocsStory';
|
||||
import { Heading } from './Heading';
|
||||
import { getDocsStories } from './utils';
|
||||
import { StoriesSlot, DocsStoryProps } from './types';
|
||||
import { StoriesSlot, DocsStoryProps } from './shared';
|
||||
|
||||
interface StoriesProps {
|
||||
slot?: StoriesSlot;
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React, { useContext, FunctionComponent } from 'react';
|
||||
import { Subtitle as PureSubtitle } from '@storybook/components';
|
||||
import { DocsContext } from './DocsContext';
|
||||
import { StringSlot } from './types';
|
||||
import { StringSlot } from './shared';
|
||||
|
||||
interface SubtitleProps {
|
||||
slot?: StringSlot;
|
||||
|
@ -2,7 +2,7 @@ import React, { useContext, FunctionComponent } from 'react';
|
||||
import { parseKind } from '@storybook/router';
|
||||
import { Title as PureTitle } from '@storybook/components';
|
||||
import { DocsContext } from './DocsContext';
|
||||
import { StringSlot } from './types';
|
||||
import { StringSlot } from './shared';
|
||||
|
||||
interface TitleProps {
|
||||
slot?: StringSlot;
|
||||
|
@ -19,7 +19,7 @@ export * from './Subtitle';
|
||||
export * from './Title';
|
||||
export * from './Wrapper';
|
||||
|
||||
export * from './types';
|
||||
export * from './shared';
|
||||
|
||||
// helper function for MDX
|
||||
export const makeStoryFn = (val: any) => (typeof val === 'function' ? val : () => val);
|
||||
|
@ -1,2 +1,41 @@
|
||||
import { PropsTableProps } from '@storybook/components';
|
||||
|
||||
export const CURRENT_SELECTION = '.';
|
||||
|
||||
export type Component = any;
|
||||
|
||||
export interface StoryData {
|
||||
id?: string;
|
||||
kind?: string;
|
||||
name?: string;
|
||||
parameters?: any;
|
||||
}
|
||||
|
||||
export type DocsStoryProps = StoryData & {
|
||||
expanded?: boolean;
|
||||
withToolbar?: boolean;
|
||||
};
|
||||
|
||||
export interface SlotContext {
|
||||
id?: string;
|
||||
selectedKind?: string;
|
||||
selectedStory?: string;
|
||||
parameters?: any;
|
||||
storyStore?: any;
|
||||
}
|
||||
|
||||
export type StringSlot = (context: SlotContext) => string;
|
||||
export type DescriptionSlot = (description: string, context: SlotContext) => string;
|
||||
export type PropsSlot = (context: SlotContext, component: Component) => PropsTableProps;
|
||||
export type StorySlot = (stories: StoryData[], context: SlotContext) => DocsStoryProps;
|
||||
|
||||
export type StoriesSlot = (stories: StoryData[], context: SlotContext) => DocsStoryProps[];
|
||||
|
||||
export interface DocsPageProps {
|
||||
titleSlot?: StringSlot;
|
||||
subtitleSlot?: StringSlot;
|
||||
descriptionSlot?: DescriptionSlot;
|
||||
primarySlot?: StorySlot;
|
||||
propsSlot?: PropsSlot;
|
||||
storiesSlot?: StoriesSlot;
|
||||
}
|
||||
|
@ -1,38 +0,0 @@
|
||||
import { PropsTableProps } from '@storybook/components';
|
||||
import { Component } from './shared';
|
||||
|
||||
export interface StoryData {
|
||||
id?: string;
|
||||
kind?: string;
|
||||
name?: string;
|
||||
parameters?: any;
|
||||
}
|
||||
|
||||
export type DocsStoryProps = StoryData & {
|
||||
expanded?: boolean;
|
||||
withToolbar?: boolean;
|
||||
};
|
||||
|
||||
export interface SlotContext {
|
||||
id?: string;
|
||||
selectedKind?: string;
|
||||
selectedStory?: string;
|
||||
parameters?: any;
|
||||
storyStore?: any;
|
||||
}
|
||||
|
||||
export type StringSlot = (context: SlotContext) => string;
|
||||
export type DescriptionSlot = (description: string, context: SlotContext) => string;
|
||||
export type PropsSlot = (context: SlotContext, component: Component) => PropsTableProps;
|
||||
export type StorySlot = (stories: StoryData[], context: SlotContext) => DocsStoryProps;
|
||||
|
||||
export type StoriesSlot = (stories: StoryData[], context: SlotContext) => DocsStoryProps[];
|
||||
|
||||
export interface DocsPageProps {
|
||||
titleSlot?: StringSlot;
|
||||
subtitleSlot?: StringSlot;
|
||||
descriptionSlot?: DescriptionSlot;
|
||||
primarySlot?: StorySlot;
|
||||
propsSlot?: PropsSlot;
|
||||
storiesSlot?: StoriesSlot;
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
/* eslint-disable no-underscore-dangle */
|
||||
import { DocsContextProps } from './DocsContext';
|
||||
import { StoryData } from './types';
|
||||
import { Component } from './shared';
|
||||
import { StoryData, Component } from './shared';
|
||||
|
||||
export const getDocsStories = (context: DocsContextProps): StoryData[] => {
|
||||
const { storyStore, selectedKind } = context;
|
||||
|
Loading…
x
Reference in New Issue
Block a user