Skip to content

Commit

Permalink
Addon docs: Remove deprecated parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbf committed Jan 4, 2024
1 parent 7802938 commit 4aea569
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 78 deletions.
15 changes: 15 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
- [StorybookViteConfig type from @storybook/builder-vite](#storybookviteconfig-type-from-storybookbuilder-vite)
- [props from WithTooltipComponent from @storybook/components](#props-from-withtooltipcomponent-from-storybookcomponents)
- [LinkTo direct import from addon-links](#linkto-direct-import-from-addon-links)
- [Deprecated docs parameters](#deprecated-docs-parameters)
- [From version 7.5.0 to 7.6.0](#from-version-750-to-760)
- [CommonJS with Vite is deprecated](#commonjs-with-vite-is-deprecated)
- [Using implicit actions during rendering is deprecated](#using-implicit-actions-during-rendering-is-deprecated)
Expand Down Expand Up @@ -619,6 +620,20 @@ import LinkTo from '@storybook/addon-links';
import LinkTo from '@storybook/addon-links/react';
```

#### Deprecated docs parameters

The following story and meta parameters are now removed:

```ts
parameters.docs.iframeHeight // becomes docs.story.iframeHeight
parameters.docs.inlineStories // becomes docs.story.inline
parameters.jsx.transformSource // becomes parameters.docs.source.transform
parameters.docs.transformSource // becomes parameters.docs.source.transform
parameters.docs.source.transformSource // becomes parameters.docs.source.transformSource
```

More info [here](#autodocs-changes) and [here](#source-block).

## From version 7.5.0 to 7.6.0

#### CommonJS with Vite is deprecated
Expand Down
2 changes: 1 addition & 1 deletion code/addons/docs/docs/docspage.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ addParameters({
});
```

With that function, anyone using the docs addon for `@storybook/vue` can make their stories render inline, either globally with the `inlineStories` docs parameter, or on a per-story-basis using the `inline` prop on the `<Story>` doc block. If you come up with an elegant and flexible implementation for the `prepareForInline` function for your own framework, let us know! We'd love to make it the default configuration, to make inline stories more accessible for a larger variety of frameworks!
With that function, anyone using the docs addon for `@storybook/vue` can make their stories render inline, either globally with the `docs.story.inline` parameter, or on a per-story-basis using the `inline` prop on the `<Story>` doc block. If you come up with an elegant and flexible implementation for the `prepareForInline` function for your own framework, let us know! We'd love to make it the default configuration, to make inline stories more accessible for a larger variety of frameworks!

## Show/Hide code

Expand Down
8 changes: 5 additions & 3 deletions code/lib/csf-tools/src/enrichCsf.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ describe('enrichCsf', () => {
title: 'Button',
parameters: {
foo: 'bar',
docs: { inlineStories: true }
docs: { story: { inline: true } }
}
}
export const Basic = () => React.createElement(Button);
Expand All @@ -652,7 +652,7 @@ describe('enrichCsf', () => {
title: 'Button',
parameters: {
foo: 'bar',
docs: { inlineStories: true }
docs: { story: { inline: true } }
}
}
export const Basic = () => <Button />
Expand All @@ -665,7 +665,9 @@ describe('enrichCsf', () => {
parameters: {
foo: 'bar',
docs: {
inlineStories: true,
story: {
inline: true
},
description: {
component: "The most basic button"
}
Expand Down
32 changes: 1 addition & 31 deletions code/ui/blocks/src/blocks/Source.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ type SourceParameters = SourceCodeProps & {
* Where to read the source code from, see `SourceType`
*/
type?: SourceType;
/**
* Transform the detected source for display
*
* @deprecated use `transform` prop instead
*/
transformSource?: (code: string, storyContext: StoryContextForLoaders) => string;
/**
* Transform the detected source for display
*/
Expand Down Expand Up @@ -126,31 +120,7 @@ const getSnippet = ({

const code = useSnippet ? snippet : sourceParameters.originalSource || '';

if (sourceParameters.transformSource) {
deprecate(dedent`The \`transformSource\` parameter at \`parameters.docs.source.transformSource\` is deprecated, please use \`parameters.docs.source.transform\` instead.
Please refer to the migration guide: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#source-block
`);
}
if (storyContext.parameters.docs?.transformSource) {
deprecate(dedent`The \`transformSource\` parameter at \`parameters.docs.transformSource\` is deprecated, please use \`parameters.docs.source.transform\` instead.
Please refer to the migration guide: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#source-block
`);
}
if (storyContext.parameters.jsx?.transformSource) {
deprecate(dedent`The \`transformSource\` parameter at \`parameters.jsx.transformSource\` is deprecated, please use \`parameters.docs.source.transform\` instead.
Please refer to the migration guide: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#source-block
`);
}

const transformer =
transformFromProps ??
sourceParameters.transform ??
sourceParameters.transformSource ?? // deprecated
storyContext.parameters.docs?.transformSource ?? // deprecated
storyContext.parameters.jsx?.transformSource; // deprecated - used to be implemented in the React renderer's jsxDecorator
const transformer = transformFromProps ?? sourceParameters.transform;

return transformer?.(code, storyContext) || code;
};
Expand Down
29 changes: 2 additions & 27 deletions code/ui/blocks/src/blocks/Story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import type {
StoryAnnotations,
StoryId,
} from '@storybook/types';
import { deprecate } from '@storybook/client-logger';

import dedent from 'ts-dedent';
import { Story as PureStory, StorySkeleton } from '../components';
import type { DocsContextProps } from './DocsContext';
import { DocsContext } from './DocsContext';
Expand Down Expand Up @@ -114,25 +112,7 @@ export const getStoryProps = <TFramework extends Renderer>(
// prefer block props, then story parameters defined by the framework-specific settings
// and optionally overridden by users

// Deprecated parameters
const { inlineStories, iframeHeight } = docs as {
inlineStories?: boolean;
iframeHeight?: string;
autoplay?: boolean;
};
if (typeof inlineStories !== 'undefined')
deprecate(dedent`The \`docs.inlineStories\` parameter is deprecated, use \`docs.story.inline\` instead.
Please refer to the migration guide: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#autodocs-changes'
`);
const inline = props.inline ?? storyParameters.inline ?? inlineStories ?? false;

if (typeof iframeHeight !== 'undefined') {
deprecate(dedent`The \`docs.iframeHeight\` parameter is deprecated, use \`docs.story.iframeHeight\` instead.
Please refer to the migration guide: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#autodocs-changes'
`);
}
const inline = props.inline ?? storyParameters.inline ?? false;

if (inline) {
const height = props.height ?? storyParameters.height;
Expand All @@ -150,12 +130,7 @@ export const getStoryProps = <TFramework extends Renderer>(
};
}

const height =
props.height ??
storyParameters.height ??
storyParameters.iframeHeight ??
iframeHeight ??
'100px';
const height = props.height ?? storyParameters.height ?? '100px';
return {
story,
inline: false,
Expand Down
16 changes: 0 additions & 16 deletions code/ui/blocks/src/examples/SourceParameters.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,6 @@ export const DocsTransformSource = {
},
};

// deprecated
export const JsxTransformSource = {
args: { something: 'else' },
parameters: {
jsx: {
transformSource: (
src: string,
storyContext: StoryContext
) => dedent`// this comment has been added via parameters.jsx.transformSource!
// this is the story id: ${storyContext.id}
// these are the current args: ${JSON.stringify(storyContext.args)}
${src}`,
},
},
};

export const Code = {
parameters: { docs: { source: { code } } },
};
Expand Down

0 comments on commit 4aea569

Please sign in to comment.