- [From version 5.3.x to 6.0.x](#from-version-53x-to-60x)
+ - [DocsPage slots removed](#docspage-slots-removed)
- [React prop tables with Typescript](#react-prop-tables-with-typescript)
- [React.FC interfaces](#reactfc-interfaces)
- [Imported types](#imported-types)
@@ -11,12 +12,12 @@
- [Removed Legacy Story APIs](#removed-legacy-story-apis)
- [Can no longer add decorators/parameters after stories](#can-no-longer-add-decoratorsparameters-after-stories)
- [Changed Parameter Handling](#changed-parameter-handling)
- - [Actions Addon API changes](#actions-addon-api-changes)
- - [Actions Addon uses parameters](#actions-addon-uses-parameters)
- - [Removed action decorator APIs](#removed-action-decorator-apis)
- [Simplified Render Context](#simplified-render-context)
- [Story Store immutable outside of configuration](#story-store-immutable-outside-of-configuration)
- [Improved story source handling](#improved-story-source-handling)
+ - [Actions Addon API changes](#actions-addon-api-changes)
+ - [Actions Addon uses parameters](#actions-addon-uses-parameters)
+ - [Removed action decorator APIs](#removed-action-decorator-apis)
- [From version 5.2.x to 5.3.x](#from-version-52x-to-53x)
- [To main.js configuration](#to-mainjs-configuration)
- [Using main.js](#using-mainjs)
@@ -98,6 +99,25 @@
## From version 5.3.x to 6.0.x
+### DocsPage slots removed
+
+In SB5.2, we introduced the concept of [DocsPage slots](https://github.com/storybookjs/storybook/blob/0de8575eab73bfd5c5c7ba5fe33e53a49b92db3a/addons/docs/docs/docspage.md#docspage-slots) for customizing the DocsPage.
+
+In 5.3, we introduced `docs.x` story parameters like `docs.prepareForInline` which get filled in by frameworks and can also be overwritten by users, which is a more natural/convenient way to make global customizations.
+
+We also introduced introduced [Custom DocsPage](https://github.com/storybookjs/storybook/blob/next/addons/docs/docs/docspage.md#replacing-docspage), which makes it possible to add/remove/update DocBlocks on the page.
+
+These mechanisms are superior to slots, so we've removed slots in 6.0. For each slot, we provide a migration path here:
+
+| Slot | Slot function | Replacement |
+| ----------- | ----------------- | -------------------------------------------- |
+| Title | `titleSlot` | Custom DocsPage |
+| Subtitle | `subtitleSlot` | Custom DocsPage |
+| Description | `descriptionSlot` | `docs.extractComponentDescription` parameter |
+| Primary | `primarySlot` | Custom DocsPage |
+| Props | `propsSlot` | `docs.extractProps` parameter |
+| Stories | `storiesSlot` | Custom DocsPage |
+
### React prop tables with Typescript
Starting in 6.0 we are changing our recommended setup for extracting prop tables in `addon-docs` for React projects using TypeScript.
@@ -107,6 +127,7 @@ In earlier versions, we recommended `react-docgen-typescript-loader` (`RDTL`) an
As a consequence we've removed `RDTL` from the presets, which is a breaking change. We made this change because `react-docgen` now supports TypeScript natively, and fewer dependencies simplifies things for everybody.
The Babel-based `react-docgen` version is the default in:
+
- `@storybook/preset-create-react-app` @ `^2.1.0`
- `@storybook/preset-typescript` @ `^3.0.0`
@@ -322,6 +343,7 @@ The MDX analog:
```
+
### Actions Addon API changes
#### Actions Addon uses parameters
diff --git a/addons/docs/docs/docspage.md b/addons/docs/docs/docspage.md
index 1f85a019446e..0bd95bb4dd64 100644
--- a/addons/docs/docs/docspage.md
+++ b/addons/docs/docs/docspage.md
@@ -9,15 +9,6 @@ When you install [Storybook Docs](../README.md), `DocsPage` is the zero-config d
- [Motivation](#motivation)
- [Component parameter](#component-parameter)
- [Subcomponents parameter](#subcomponents-parameter)
-- [DocsPage slots](#docspage-slots)
-- [Slot values](#slot-values)
- - [Title](#title)
- - [Subtitle](#subtitle)
- - [Description](#description)
- - [Primary](#primary)
- - [Props](#props)
- - [Stories](#stories)
-- [Slot functions](#slot-functions)
- [Replacing DocsPage](#replacing-docspage)
- [Remixing DocsPage using doc blocks](#remixing-docspage-using-doc-blocks)
- [Story file names](#story-file-names)
@@ -85,146 +76,6 @@ Subcomponent prop tables will show up in a tabbed interface along with the prima
If you want organize your documentation differently for groups of components, we recommend trying [MDX](./mdx.md) which is completely flexible to support any configuration.
-## DocsPage slots
-
-`DocsPage` is organized into a series of "slots" including Title, Subtitle, Description, Props, and Story. Each of these slots pulls information from your project and formats it for the screen.
-
-
-
-
-
-## Slot values
-
-Each of the slots is computed by a built-in function, that can also be overridden using [Slot Function](#slot-functions).
-
-Here is a summary of the slots, where the data comes from by default, and the slot function that can be used to override it:
-
-| Slot | Default source | Slot function | Frameworks |
-| ----------- | ----------------------------------- | ----------------- | ---------- |
-| Title | component `title` | `titleSlot` | All |
-| Subtitle | `componentSubtitle` parameter | `subtitleSlot` | All |
-| Description | component `docgen` comment | `descriptionSlot` | React, Vue |
-| Primary | storybook stories | `primarySlot` | All |
-| Props | component docgen props or propTypes | `propsSlot` | React, Vue |
-| Stories | storybook stories | `storiesSlot` | All |
-
-The `storiesSlot` uses the `docs.storyDescription` parameter to show a description for each story, if available.
-
-For more information on frameworks, see ["Framework support"](../README.md#framework-support)
-
-### Title
-
-`Title` is computed from the component's `title`, and matches the component caption in Storybook's navigation.
-
-For example:
-
-```js
-export default {
- title: 'Path/to/Badge',
-};
-```
-
-### Subtitle
-
-The `Subtitle` slot is computed from the component's `componentSubtitle` parameter.
-
-For example in [Component Story Format (CSF)](https://medium.com/storybookjs/component-story-format-66f4c32366df):
-
-```js
-export default {
- ...
- parameters: {
- componentSubtitle: 'Handy status label',
- },
-};
-```
-
-### Description
-
-The `Description` slot is computed from the Component's docgen comments in the component's source.
-
-For example, here's the source for `Badge`:
-
-```js
-/**
- * Use `Badge` to highlight key info with a predefined status.
- */
-export const Badge = ({ status, children }) => { ... }
-```
-
-### Primary
-
-The `Primary` slot is computed from the first user-defined story for the component.
-
-For example here are `Badge`'s stories in CSF. The `allBadges` is selected as the primary story because it's first:
-
-```js
-// export default { ... }; /* Badge component metadata */
-export const allBadges = () => ...
-export const positive = () => ...
-export const negative = () => ...
-```
-
-### Props
-
-The `Props` slot is computed from the component's docgen props, which can be defined in typescript or using `react` PropTypes.
-
-For example, here are the `PropTypes` for the `Badge` component
-
-```js
-import PropTypes from 'prop-types';
-
-// ... Badge definition ...
-
-Badge.propTypes = {
- status: PropTypes.oneOf(['positive', 'negative', 'neutral', 'error', 'warning']),
-};
-Badge.defaultProps = {
- status: 'neutral',
-};
-```
-
-### Stories
-
-The `Stories` slot is computed from the user-defined stories for the component, excluding the first.
-
-For example here are `Badge`'s stories in CSF. The `positive` and `negative` stories are selected in that order:
-
-```js
-// export default { ... }; /* Badge component metadata */
-export const allBadges = () => ...
-export const positive = () => ...
-export const negative = () => ...
-```
-
-## Slot functions
-
-> ⚠️ Slot functions are an experimental feature in Storybook 5.2. The API may change in 5.3 outside of the normal semver rules. Be forewarned!
-
-The value for each slot is computed from a `SlotContext` context, and the function that's used to compute the value can be overridden if you need to customize the page. If you find yourself doing a lot of configuration, or wanting different configurations for different pages, you might be better off using `MDX`. Everything that `DocsPage` gives you can be reconstructed in a few lines of `MDX`.
-
-Here is the `SlotContext` type definition:
-
-```ts
-export interface SlotContext {
- id?: string;
- kind?: string;
- name?: string;
- parameters?: any;
- storyStore?: any;
-}
-```
-
-And here are the return type signatures for each of the slot functions
-
-| Slot | Function | Inputs | Output |
-| -------- | ------------ | ---------------------------- | ------------------ |
-| Title | titleSlot | `SlotContext` | `string?` |
-| Subtitle | subtitleSlot | `SlotContext` | `string?` |
-| Primary | primarySlot | `StoryData[]`, `SlotContext` | `StoryProps?` |
-| Props | propsSlot | `SlotContext` | `PropsTableProps?` |
-| Stories | storiesSlot | `StoryData[]`, `SlotContext` | `StoryProps[]?` |
-
## Replacing DocsPage
What if you don't want a `DocsPage` for your storybook, for a specific component, or even for a specific story?
diff --git a/addons/docs/src/blocks/Description.tsx b/addons/docs/src/blocks/Description.tsx
index 39ec492f6abc..0e3deb6ffe8c 100644
--- a/addons/docs/src/blocks/Description.tsx
+++ b/addons/docs/src/blocks/Description.tsx
@@ -1,7 +1,7 @@
import React, { FunctionComponent, useContext } from 'react';
import { Description, DescriptionProps as PureDescriptionProps } from '@storybook/components';
import { DocsContext, DocsContextProps } from './DocsContext';
-import { Component, CURRENT_SELECTION, DescriptionSlot } from './shared';
+import { Component, CURRENT_SELECTION } from './types';
import { str } from '../lib/docgen';
export enum DescriptionType {
@@ -16,7 +16,6 @@ type Notes = string | any;
type Info = string | any;
interface DescriptionProps {
- slot?: DescriptionSlot;
of?: '.' | Component;
type?: DescriptionType;
markdown?: string;
@@ -61,13 +60,9 @@ ${extractComponentDescription(target) || ''}
}
};
-const DescriptionContainer: FunctionComponent = (props) => {
+const DescriptionContainer: FunctionComponent = props => {
const context = useContext(DocsContext);
- const { slot } = props;
- let { markdown } = getDescriptionProps(props, context);
- if (slot) {
- markdown = slot(markdown, context);
- }
+ const { markdown } = getDescriptionProps(props, context);
return markdown ? : null;
};
diff --git a/addons/docs/src/blocks/DocsPage.test.ts b/addons/docs/src/blocks/DocsPage.test.ts
index 611438d35197..2562fb2b5151 100644
--- a/addons/docs/src/blocks/DocsPage.test.ts
+++ b/addons/docs/src/blocks/DocsPage.test.ts
@@ -1,24 +1,24 @@
-import { defaultTitleSlot } from './Title';
+import { extractTitle } from './Title';
describe('defaultTitleSlot', () => {
it('showRoots', () => {
const parameters = {
options: { showRoots: true },
};
- expect(defaultTitleSlot({ kind: 'a/b/c', parameters })).toBe('c');
- expect(defaultTitleSlot({ kind: 'a|b', parameters })).toBe('a|b');
- expect(defaultTitleSlot({ kind: 'a/b/c.d', parameters })).toBe('c.d');
+ expect(extractTitle({ kind: 'a/b/c', parameters })).toBe('c');
+ expect(extractTitle({ kind: 'a|b', parameters })).toBe('a|b');
+ expect(extractTitle({ kind: 'a/b/c.d', parameters })).toBe('c.d');
});
it('no showRoots', () => {
const parameters = {};
- expect(defaultTitleSlot({ kind: 'a/b/c', parameters })).toBe('c');
- expect(defaultTitleSlot({ kind: 'a|b', parameters })).toBe('b');
- expect(defaultTitleSlot({ kind: 'a/b/c.d', parameters })).toBe('d');
+ expect(extractTitle({ kind: 'a/b/c', parameters })).toBe('c');
+ expect(extractTitle({ kind: 'a|b', parameters })).toBe('b');
+ expect(extractTitle({ kind: 'a/b/c.d', parameters })).toBe('d');
});
it('empty options', () => {
const parameters = { options: {} };
- expect(defaultTitleSlot({ kind: 'a/b/c', parameters })).toBe('c');
- expect(defaultTitleSlot({ kind: 'a|b', parameters })).toBe('b');
- expect(defaultTitleSlot({ kind: 'a/b/c.d', parameters })).toBe('d');
+ expect(extractTitle({ kind: 'a/b/c', parameters })).toBe('c');
+ expect(extractTitle({ kind: 'a|b', parameters })).toBe('b');
+ expect(extractTitle({ kind: 'a/b/c.d', parameters })).toBe('d');
});
});
diff --git a/addons/docs/src/blocks/DocsPage.tsx b/addons/docs/src/blocks/DocsPage.tsx
index a19a7038867a..4eb903794f43 100644
--- a/addons/docs/src/blocks/DocsPage.tsx
+++ b/addons/docs/src/blocks/DocsPage.tsx
@@ -1,5 +1,4 @@
-import React, { FunctionComponent } from 'react';
-import { DocsPageProps } from './shared';
+import React, { FC } from 'react';
import { Title } from './Title';
import { Subtitle } from './Subtitle';
import { Description } from './Description';
@@ -7,20 +6,13 @@ import { Primary } from './Primary';
import { Props } from './Props';
import { Stories } from './Stories';
-export const DocsPage: FunctionComponent = ({
- titleSlot,
- subtitleSlot,
- descriptionSlot,
- primarySlot,
- propsSlot,
- storiesSlot,
-}) => (
+export const DocsPage: FC = () => (
<>
-
-
-
-
-
-
+
+
+
+
+
+
>
);
diff --git a/addons/docs/src/blocks/DocsStory.tsx b/addons/docs/src/blocks/DocsStory.tsx
index ca6640ad1832..f522175c5ea3 100644
--- a/addons/docs/src/blocks/DocsStory.tsx
+++ b/addons/docs/src/blocks/DocsStory.tsx
@@ -1,6 +1,6 @@
import React, { FunctionComponent } from 'react';
import { Subheading } from './Subheading';
-import { DocsStoryProps } from './shared';
+import { DocsStoryProps } from './types';
import { Anchor } from './Anchor';
import { Description } from './Description';
import { Story } from './Story';
diff --git a/addons/docs/src/blocks/Primary.tsx b/addons/docs/src/blocks/Primary.tsx
index fe2b764fcaa6..60718554a646 100644
--- a/addons/docs/src/blocks/Primary.tsx
+++ b/addons/docs/src/blocks/Primary.tsx
@@ -1,16 +1,18 @@
-import React, { useContext, FunctionComponent } from 'react';
+import React, { useContext, FC } from 'react';
import { DocsContext } from './DocsContext';
import { DocsStory } from './DocsStory';
import { getDocsStories } from './utils';
-import { StorySlot } from './shared';
interface PrimaryProps {
- slot?: StorySlot;
+ name?: string;
}
-export const Primary: FunctionComponent = ({ slot }) => {
+export const Primary: FC = ({ name }) => {
const context = useContext(DocsContext);
const componentStories = getDocsStories(context);
- const story = slot ? slot(componentStories, context) : componentStories && componentStories[0];
+ let story;
+ if (componentStories) {
+ story = name ? componentStories.find(s => s.name === name) : componentStories[0];
+ }
return story ? : null;
};
diff --git a/addons/docs/src/blocks/Props.tsx b/addons/docs/src/blocks/Props.tsx
index e1202caf1e26..23690db91403 100644
--- a/addons/docs/src/blocks/Props.tsx
+++ b/addons/docs/src/blocks/Props.tsx
@@ -10,7 +10,7 @@ import {
TabsState,
} from '@storybook/components';
import { DocsContext, DocsContextProps } from './DocsContext';
-import { Component, PropsSlot, CURRENT_SELECTION } from './shared';
+import { Component, CURRENT_SELECTION } from './types';
import { getComponentName } from './utils';
import { PropsExtractor } from '../lib/docgen/types';
@@ -23,7 +23,6 @@ interface PropsProps {
components?: {
[label: string]: Component;
};
- slot?: PropsSlot;
}
// FIXME: remove in SB6.0 & require config
@@ -65,7 +64,7 @@ export const getComponentProps = (
if (rows) {
props = { rows: filterRows(rows, exclude) };
} else if (sections) {
- Object.keys(sections).forEach((section) => {
+ Object.keys(sections).forEach(section => {
sections[section] = filterRows(sections[section], exclude);
});
}
@@ -92,9 +91,9 @@ export const getComponent = (props: PropsProps = {}, context: DocsContextProps):
return target;
};
-const PropsContainer: FunctionComponent = (props) => {
+const PropsContainer: FunctionComponent = props => {
const context = useContext(DocsContext);
- const { slot, components } = props;
+ const { components } = props;
const {
parameters: { subcomponents },
} = context;
@@ -103,7 +102,7 @@ const PropsContainer: FunctionComponent = (props) => {
if (!allComponents) {
const main = getComponent(props, context);
const mainLabel = getComponentName(main);
- const mainProps = slot ? slot(context, main) : getComponentProps(main, props, context);
+ const mainProps = getComponentProps(main, props, context);
if (!subcomponents || typeof subcomponents !== 'object') {
return mainProps && ;
@@ -116,7 +115,7 @@ const PropsContainer: FunctionComponent = (props) => {
Object.entries(allComponents).forEach(([label, component]) => {
tabs.push({
label,
- table: slot ? slot(context, component) : getComponentProps(component, props, context),
+ table: getComponentProps(component, props, context),
});
});
diff --git a/addons/docs/src/blocks/Source.tsx b/addons/docs/src/blocks/Source.tsx
index a3756422f91a..e6ccf9ca77f3 100644
--- a/addons/docs/src/blocks/Source.tsx
+++ b/addons/docs/src/blocks/Source.tsx
@@ -1,7 +1,7 @@
import React, { FunctionComponent } from 'react';
import { Source, SourceProps as PureSourceProps, SourceError } from '@storybook/components';
import { DocsContext, DocsContextProps } from './DocsContext';
-import { CURRENT_SELECTION } from './shared';
+import { CURRENT_SELECTION } from './types';
interface CommonProps {
language?: string;
@@ -37,7 +37,7 @@ export const getSourceProps = (
const targetId = singleProps.id === CURRENT_SELECTION ? currentId : singleProps.id;
const targetIds = multiProps.ids || [targetId];
source = targetIds
- .map((sourceId) => {
+ .map(sourceId => {
const data = storyStore.fromId(sourceId);
return data?.parameters?.docs?.source?.code || '';
})
@@ -53,9 +53,9 @@ export const getSourceProps = (
* or the source for a story if `storyId` is provided, or
* the source for the current story if nothing is provided.
*/
-const SourceContainer: FunctionComponent = (props) => (
+const SourceContainer: FunctionComponent = props => (
- {(context) => {
+ {context => {
const sourceProps = getSourceProps(props, context);
return ;
}}
diff --git a/addons/docs/src/blocks/Stories.tsx b/addons/docs/src/blocks/Stories.tsx
index 1e377b4e53c9..542cb7daab73 100644
--- a/addons/docs/src/blocks/Stories.tsx
+++ b/addons/docs/src/blocks/Stories.tsx
@@ -3,27 +3,27 @@ import { DocsContext } from './DocsContext';
import { DocsStory } from './DocsStory';
import { Heading } from './Heading';
import { getDocsStories } from './utils';
-import { StoriesSlot, DocsStoryProps } from './shared';
+import { DocsStoryProps } from './types';
interface StoriesProps {
- slot?: StoriesSlot;
title?: JSX.Element | string;
+ includePrimary?: boolean;
}
-export const Stories: FunctionComponent = ({ slot, title }) => {
+export const Stories: FunctionComponent = ({ title, includePrimary = false }) => {
const context = useContext(DocsContext);
const componentStories = getDocsStories(context);
- const stories: DocsStoryProps[] = slot
- ? slot(componentStories, context)
- : componentStories && componentStories.slice(1);
+ let stories: DocsStoryProps[] = componentStories;
+ if (!includePrimary) stories = stories.slice(1);
+
if (!stories || stories.length === 0) {
return null;
}
return (
<>
{title}
- {stories.map((story) => story && )}
+ {stories.map(story => story && )}
>
);
};
diff --git a/addons/docs/src/blocks/Story.tsx b/addons/docs/src/blocks/Story.tsx
index b6bc2e5030b9..e1c174c416d2 100644
--- a/addons/docs/src/blocks/Story.tsx
+++ b/addons/docs/src/blocks/Story.tsx
@@ -3,14 +3,14 @@ import { MDXProvider } from '@mdx-js/react';
import { components as docsComponents } from '@storybook/components/html';
import { Story, StoryProps as PureStoryProps } from '@storybook/components';
import { toId, storyNameFromExport } from '@storybook/csf';
-import { CURRENT_SELECTION } from './shared';
+import { CURRENT_SELECTION } from './types';
import { DocsContext, DocsContextProps } from './DocsContext';
export const storyBlockIdFromId = (storyId: string) => `story--${storyId}`;
const resetComponents: Record = {};
-Object.keys(docsComponents).forEach((key) => {
+Object.keys(docsComponents).forEach(key => {
resetComponents[key] = (props: any) => createElement(key, props);
});
@@ -87,9 +87,9 @@ export const getStoryProps = (
};
};
-const StoryContainer: FunctionComponent = (props) => (
+const StoryContainer: FunctionComponent = props => (
- {(context) => {
+ {context => {
const storyProps = getStoryProps(props, context);
if (!storyProps) {
return null;
diff --git a/addons/docs/src/blocks/Subtitle.tsx b/addons/docs/src/blocks/Subtitle.tsx
index 595bac6452f2..3fb44a8af5a6 100644
--- a/addons/docs/src/blocks/Subtitle.tsx
+++ b/addons/docs/src/blocks/Subtitle.tsx
@@ -1,19 +1,17 @@
import React, { useContext, FunctionComponent } from 'react';
import { Subtitle as PureSubtitle } from '@storybook/components';
import { DocsContext } from './DocsContext';
-import { StringSlot } from './shared';
interface SubtitleProps {
- slot?: StringSlot;
children?: JSX.Element | string;
}
-export const Subtitle: FunctionComponent = ({ slot, children }) => {
+export const Subtitle: FunctionComponent = ({ children }) => {
const context = useContext(DocsContext);
const { parameters } = context;
let text: JSX.Element | string = children;
if (!text) {
- text = slot ? slot(context) : parameters && parameters.componentSubtitle;
+ text = parameters?.componentSubtitle;
}
return text ? {text} : null;
};
diff --git a/addons/docs/src/blocks/Title.tsx b/addons/docs/src/blocks/Title.tsx
index 6c93bfee4853..fd9bf9acbc22 100644
--- a/addons/docs/src/blocks/Title.tsx
+++ b/addons/docs/src/blocks/Title.tsx
@@ -1,14 +1,12 @@
import React, { useContext, FunctionComponent } from 'react';
import { parseKind } from '@storybook/csf';
import { Title as PureTitle } from '@storybook/components';
-import { DocsContext } from './DocsContext';
-import { StringSlot } from './shared';
+import { DocsContext, DocsContextProps } from './DocsContext';
interface TitleProps {
- slot?: StringSlot;
children?: JSX.Element | string;
}
-export const defaultTitleSlot: StringSlot = ({ kind, parameters }) => {
+export const extractTitle = ({ kind, parameters }: DocsContextProps) => {
const {
showRoots,
hierarchyRootSeparator: rootSeparator = '|',
@@ -29,16 +27,11 @@ export const defaultTitleSlot: StringSlot = ({ kind, parameters }) => {
return (groups && groups[groups.length - 1]) || kind;
};
-export const Title: FunctionComponent = ({ slot, children }) => {
+export const Title: FunctionComponent = ({ children }) => {
const context = useContext(DocsContext);
- const { kind, parameters } = context;
let text: JSX.Element | string = children;
if (!text) {
- if (slot) {
- text = slot(context);
- } else {
- text = defaultTitleSlot({ kind, parameters });
- }
+ text = extractTitle(context);
}
return text ? {text} : null;
};
diff --git a/addons/docs/src/blocks/index.ts b/addons/docs/src/blocks/index.ts
index f4f5def5d237..00569b5874f7 100644
--- a/addons/docs/src/blocks/index.ts
+++ b/addons/docs/src/blocks/index.ts
@@ -19,5 +19,5 @@ export * from './Subtitle';
export * from './Title';
export * from './Wrapper';
-export * from './shared';
+export * from './types';
export * from './mdx';
diff --git a/addons/docs/src/blocks/shared.ts b/addons/docs/src/blocks/shared.ts
deleted file mode 100644
index 51c36319f1c1..000000000000
--- a/addons/docs/src/blocks/shared.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-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;
- kind?: string;
- name?: 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;
-}
diff --git a/addons/docs/src/blocks/types.ts b/addons/docs/src/blocks/types.ts
new file mode 100644
index 000000000000..d7536f1a9f78
--- /dev/null
+++ b/addons/docs/src/blocks/types.ts
@@ -0,0 +1,15 @@
+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;
+};
diff --git a/addons/docs/src/blocks/utils.ts b/addons/docs/src/blocks/utils.ts
index 2c17070cdee1..1b67e0de7984 100644
--- a/addons/docs/src/blocks/utils.ts
+++ b/addons/docs/src/blocks/utils.ts
@@ -1,6 +1,6 @@
/* eslint-disable no-underscore-dangle */
import { DocsContextProps } from './DocsContext';
-import { StoryData, Component } from './shared';
+import { StoryData, Component } from './types';
export const getDocsStories = (context: DocsContextProps): StoryData[] => {
const { storyStore, kind } = context;
@@ -17,7 +17,7 @@ export const getDocsStories = (context: DocsContextProps): StoryData[] => {
const titleCase = (str: string): string =>
str
.split('-')
- .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
+ .map(part => part.charAt(0).toUpperCase() + part.slice(1))
.join('');
export const getComponentName = (component: Component): string => {
diff --git a/addons/docs/src/frameworks/react/extractProps.ts b/addons/docs/src/frameworks/react/extractProps.ts
index 3b8b659f6495..5fcbbf3a154d 100644
--- a/addons/docs/src/frameworks/react/extractProps.ts
+++ b/addons/docs/src/frameworks/react/extractProps.ts
@@ -2,7 +2,7 @@ import PropTypes from 'prop-types';
import { isForwardRef, isMemo } from 'react-is';
import { PropDef } from '@storybook/components';
import { hasDocgen, extractComponentProps, PropsExtractor, TypeSystem } from '../../lib/docgen';
-import { Component } from '../../blocks/shared';
+import { Component } from '../../blocks/types';
import { enhancePropTypesProps } from './propTypes/handleProp';
import { enhanceTypeScriptProps } from './typeScript/handleProp';
diff --git a/addons/docs/src/frameworks/react/propTypes/handleProp.test.tsx b/addons/docs/src/frameworks/react/propTypes/handleProp.test.tsx
index 2aaa8d547b71..cd0f24000ac5 100644
--- a/addons/docs/src/frameworks/react/propTypes/handleProp.test.tsx
+++ b/addons/docs/src/frameworks/react/propTypes/handleProp.test.tsx
@@ -3,7 +3,7 @@
import { PropDef } from '@storybook/components';
import PropTypes from 'prop-types';
import React from 'react';
-import { Component } from '../../../blocks/shared';
+import { Component } from '../../../blocks/types';
import { extractComponentProps, DocgenInfo, DocgenPropDefaultValue } from '../../../lib/docgen';
import { enhancePropTypesProp, enhancePropTypesProps } from './handleProp';
diff --git a/addons/docs/src/frameworks/react/propTypes/handleProp.ts b/addons/docs/src/frameworks/react/propTypes/handleProp.ts
index 08b3c2262c92..f85b1ccb5605 100644
--- a/addons/docs/src/frameworks/react/propTypes/handleProp.ts
+++ b/addons/docs/src/frameworks/react/propTypes/handleProp.ts
@@ -2,7 +2,7 @@ import { PropDef } from '@storybook/components';
import { ExtractedProp } from '../../../lib/docgen';
import { createType } from './createType';
import { createDefaultValue, createDefaultValueFromRawDefaultProp } from '../lib/defaultValues';
-import { Component } from '../../../blocks/shared';
+import { Component } from '../../../blocks/types';
import { keepOriginalDefinitionOrder } from './sortProps';
import { rawDefaultPropTypeResolvers } from './rawDefaultPropResolvers';
diff --git a/addons/docs/src/frameworks/react/propTypes/sortProps.ts b/addons/docs/src/frameworks/react/propTypes/sortProps.ts
index 36aa0e72b951..b676481edd18 100644
--- a/addons/docs/src/frameworks/react/propTypes/sortProps.ts
+++ b/addons/docs/src/frameworks/react/propTypes/sortProps.ts
@@ -1,5 +1,5 @@
import { PropDef } from '@storybook/components';
-import { Component } from '../../../blocks/shared';
+import { Component } from '../../../blocks/types';
// react-docgen doesn't returned the props in the order they were defined in the "propTypes" object of the component.
// This function re-order them by their original definition order.
diff --git a/addons/docs/src/frameworks/react/typeScript/handleProp.test.tsx b/addons/docs/src/frameworks/react/typeScript/handleProp.test.tsx
index 47f6cec027fb..4cbfe60f5345 100644
--- a/addons/docs/src/frameworks/react/typeScript/handleProp.test.tsx
+++ b/addons/docs/src/frameworks/react/typeScript/handleProp.test.tsx
@@ -2,7 +2,7 @@
import { PropDef } from '@storybook/components';
import React from 'react';
-import { Component } from '../../../blocks/shared';
+import { Component } from '../../../blocks/types';
import { extractComponentProps, DocgenInfo, DocgenPropDefaultValue } from '../../../lib/docgen';
import { enhanceTypeScriptProp } from './handleProp';
diff --git a/addons/docs/src/lib/docgen/extractDocgenProps.test.ts b/addons/docs/src/lib/docgen/extractDocgenProps.test.ts
index a81bafe2fea2..921d329893f8 100644
--- a/addons/docs/src/lib/docgen/extractDocgenProps.test.ts
+++ b/addons/docs/src/lib/docgen/extractDocgenProps.test.ts
@@ -1,6 +1,6 @@
/* eslint-disable no-underscore-dangle */
-import { Component } from '../../blocks/shared';
+import { Component } from '../../blocks/types';
import { extractComponentProps } from './extractDocgenProps';
const DOCGEN_SECTION = 'props';
diff --git a/addons/docs/src/lib/docgen/extractDocgenProps.ts b/addons/docs/src/lib/docgen/extractDocgenProps.ts
index deabdb53f498..e66468b02b90 100644
--- a/addons/docs/src/lib/docgen/extractDocgenProps.ts
+++ b/addons/docs/src/lib/docgen/extractDocgenProps.ts
@@ -1,5 +1,5 @@
import { PropDef } from '@storybook/components';
-import { Component } from '../../blocks/shared';
+import { Component } from '../../blocks/types';
import { ExtractedJsDoc, parseJsDoc } from '../jsdocParser';
import { DocgenInfo, TypeSystem } from './types';
import { getDocgenSection, isValidDocgenSection, getDocgenDescription } from './utils';
diff --git a/addons/docs/src/lib/docgen/types.ts b/addons/docs/src/lib/docgen/types.ts
index b59af2b3ec99..cac1ccf3437a 100644
--- a/addons/docs/src/lib/docgen/types.ts
+++ b/addons/docs/src/lib/docgen/types.ts
@@ -1,5 +1,5 @@
import { PropsTableProps } from '@storybook/components';
-import { Component } from '../../blocks/shared';
+import { Component } from '../../blocks/types';
export type PropsExtractor = (component: Component) => PropsTableProps | null;
diff --git a/addons/docs/src/lib/docgen/utils/docgenInfo.ts b/addons/docs/src/lib/docgen/utils/docgenInfo.ts
index b3d2a664ca56..da7f21f7a06d 100644
--- a/addons/docs/src/lib/docgen/utils/docgenInfo.ts
+++ b/addons/docs/src/lib/docgen/utils/docgenInfo.ts
@@ -1,6 +1,6 @@
/* eslint-disable no-underscore-dangle */
-import { Component } from '../../../blocks/shared';
+import { Component } from '../../../blocks/types';
import { str } from './string';
export function hasDocgen(component: Component): boolean {
diff --git a/addons/docs/src/mdx/__testfixtures__/component-args.output.snapshot b/addons/docs/src/mdx/__testfixtures__/component-args.output.snapshot
index 075a9938659f..9085d6b42843 100644
--- a/addons/docs/src/mdx/__testfixtures__/component-args.output.snapshot
+++ b/addons/docs/src/mdx/__testfixtures__/component-args.output.snapshot
@@ -7,7 +7,7 @@ import { assertIsFn, AddContext } from '@storybook/addon-docs/blocks';
import { Button } from '@storybook/react/demo';
import { Story, Meta } from '@storybook/addon-docs/blocks';
-const makeShortcode = name =>
+const makeShortcode = (name) =>
function MDXDefaultShortcode(props) {
console.warn(
'Component ' +
diff --git a/addons/docs/src/mdx/__testfixtures__/story-args.output.snapshot b/addons/docs/src/mdx/__testfixtures__/story-args.output.snapshot
index 6775a5edf441..93181c4aaccc 100644
--- a/addons/docs/src/mdx/__testfixtures__/story-args.output.snapshot
+++ b/addons/docs/src/mdx/__testfixtures__/story-args.output.snapshot
@@ -7,7 +7,7 @@ import { assertIsFn, AddContext } from '@storybook/addon-docs/blocks';
import { Button } from '@storybook/react/demo';
import { Story, Meta } from '@storybook/addon-docs/blocks';
-const makeShortcode = name =>
+const makeShortcode = (name) =>
function MDXDefaultShortcode(props) {
console.warn(
'Component ' +
diff --git a/examples/official-storybook/stories/addon-docs/addon-docs-blocks.stories.js b/examples/official-storybook/stories/addon-docs/addon-docs-blocks.stories.js
index 16f257612d5a..2d493c35544c 100644
--- a/examples/official-storybook/stories/addon-docs/addon-docs-blocks.stories.js
+++ b/examples/official-storybook/stories/addon-docs/addon-docs-blocks.stories.js
@@ -96,24 +96,7 @@ export const customStoriesFilter = () =>