Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated decorators and loaders #9951

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- [Migration](#migration)
- [From version 5.3.x to 6.0.x](#from-version-53x-to-60x)
- [New addon presets](#new-addon-presets)
- [Removed Deprecated APIs](#Removed-deprecated-apis)
- [Client API changes](#client-api-changes)
- [Removed legacy story APIs](#removed-legacy-story-apis)
- [Can no longer add decorators/parameters after stories](#can-no-longer-add-decorators-parameters-after-stories)
Expand Down Expand Up @@ -41,6 +42,7 @@
- [Addon cssresources name attribute renamed](#addon-cssresources-name-attribute-renamed)
- [Addon viewport uses parameters](#addon-viewport-uses-parameters)
- [Addon a11y uses parameters, decorator renamed](#addon-a11y-uses-parameters-decorator-renamed)
- [Addon centered decorator deprecated](#addon-centered-decorator-deprecated)
- [New keyboard shortcuts defaults](#new-keyboard-shortcuts-defaults)
- [New URL structure](#new-url-structure)
- [Rename of the `--secure` cli parameter to `--https`](#rename-of-the---secure-cli-parameter-to---https)
Expand Down Expand Up @@ -129,6 +131,17 @@ MyNonCheckedStory.story = {
};
```

### Removed Deprecated APIs

In 6.0 we removed a number of APIs that were previously deprecated.

See the migration guides for further details:
* [Addon a11y uses parameters, decorator renamed](#addon-a11y-uses-parameters-decorator-renamed)
* [Addon backgrounds uses parameters](#addon-backgrounds-uses-parameters)
* [Source-loader](#source-loader)
* [Unified docs preset](#unified-docs-preset)
* [Addon centered decorator deprecated](#addon-centered-decorator-deprecated)

### Client API changes

#### Removed Legacy Story APIs
Expand Down Expand Up @@ -750,6 +763,25 @@ Furthermore, the decorator `checkA11y` has been deprecated and renamed to `withA

See the [a11y addon README](https://github.com/storybookjs/storybook/blob/master/addons/a11y/README.md) for more information.

### Addon centered decorator deprecated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a parameter called layout and it and 1 of it's possible values is center.

This automatically centers the component.

It also supports fullscreen and padded.

I think we could drop addon-centered entirely in 6.0.0.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, let's please move it to the deprecated addons repo, pretty please 🙏

We can merge this first and follow up separately: #10118


If you previously had:
```js
import centered from '@storybook/addon-centered'
```

You should replace it with the React or Vue version as appropriate

```js
import centered from '@storybook/addon-centered/react'
```

or

```js
import centered from '@storybook/addon-centered/vue'
```

### New keyboard shortcuts defaults

Storybook's keyboard shortcuts are updated in 5.0, but they are configurable via the menu so if you want to set them back you can:
Expand Down
4 changes: 1 addition & 3 deletions addons/a11y/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@
"react-redux": "^7.0.2",
"react-sizeme": "^2.5.2",
"redux": "^4.0.1",
"regenerator-runtime": "^0.13.3",
"ts-dedent": "^1.1.1",
"util-deprecate": "^1.0.2"
"regenerator-runtime": "^0.13.3"
},
"devDependencies": {
"@types/react-redux": "^7.0.6",
Expand Down
35 changes: 1 addition & 34 deletions addons/a11y/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { document } from 'global';
import axe, { AxeResults, ElementContext, RunOptions, Spec } from 'axe-core';
import deprecate from 'util-deprecate';
import dedent from 'ts-dedent';

import addons, { makeDecorator } from '@storybook/addons';
import { EVENTS, PARAM_KEY } from './constants';
Expand All @@ -14,7 +12,7 @@ interface Setup {
manual: boolean;
}

let setup: Setup = { element: undefined, config: {}, options: {}, manual: false };
const setup: Setup = { element: undefined, config: {}, options: {}, manual: false };

const getElement = () => {
const storyRoot = document.getElementById('story-root');
Expand Down Expand Up @@ -74,34 +72,3 @@ export const withA11y = makeDecorator({
return getStory(context);
},
});

// TODO: REMOVE at v6.0.0
export const withA11Y = deprecate(
// @ts-ignore
(...args: any[]) => withA11y(...args),
'withA11Y has been renamed withA11y'
);

// TODO: REMOVE at v6.0.0
export const checkA11y = deprecate(
// @ts-ignore
(...args: any[]) => withA11y(...args),
'checkA11y has been renamed withA11y'
);

// TODO: REMOVE at v6.0.0
export const configureA11y = deprecate(
(config: any) => {
setup = config;
},
dedent`
configureA11y is deprecated, please configure addon-a11y using the addParameter api:

addParameters({
a11y: {
// ... axe options
element: '#root', // optional selector which element to inspect
},
});
`
);
4 changes: 2 additions & 2 deletions addons/a11y/src/preset/addDecorator.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { withA11Y } from '../index';
import { withA11y } from '../index';

export const decorators = [withA11Y];
export const decorators = [withA11y];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made me giggle that the preset was using the deprecated version...

4 changes: 1 addition & 3 deletions addons/backgrounds/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,9 @@
"core-js": "^3.0.1",
"memoizerific": "^1.11.3",
"react": "^16.8.3",
"regenerator-runtime": "^0.13.3",
"util-deprecate": "^1.0.2"
"regenerator-runtime": "^0.13.3"
},
"devDependencies": {
"@types/util-deprecate": "^1.0.0",
"@types/webpack-env": "^1.15.1"
},
"peerDependencies": {
Expand Down
17 changes: 0 additions & 17 deletions addons/backgrounds/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
import { makeDecorator, StoryContext, StoryGetter } from '@storybook/addons';
import deprecate from 'util-deprecate';

// This decorator is kept purely so we produce a decorator that is compatible with both
// `addDecorator(withBackgrounds(...))` and `addDecorator(withBackgrounds)`
export const withBackgrounds = deprecate(
makeDecorator({
name: 'withBackgrounds',
parameterName: 'backgrounds',
wrapper: (getStory: StoryGetter, context: StoryContext) => {
return getStory(context);
},
}),
`Note that withBackgrounds(options) has been replaced by addParameters({ backgrounds: options})
Read more about it in the migration guide: https://github.com/storybookjs/storybook/blob/master/MIGRATION.md`
);

if (module && module.hot && module.hot.decline) {
module.hot.decline();
}
3 changes: 1 addition & 2 deletions addons/centered/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
"@storybook/addons": "6.0.0-alpha.19",
"core-js": "^3.0.1",
"global": "^4.3.2",
"regenerator-runtime": "^0.13.3",
"util-deprecate": "^1.0.2"
"regenerator-runtime": "^0.13.3"
},
"devDependencies": {
"@types/mithril": "^1.1.16",
Expand Down
21 changes: 0 additions & 21 deletions addons/centered/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,3 @@
import { window } from 'global';
import deprecate from 'util-deprecate';

import ReactCentered from './react';
import VueCentered from './vue';

// TODO: REMOVE this entire file in V6.0.0

const Centered = deprecate(
() => (window.STORYBOOK_ENV === 'vue' ? VueCentered : ReactCentered),
`
Using "import centered from '@storybook/addon-centered'" is deprecated.
Please use either:
"import centered from '@storybook/addon-centered/react'"
or
"import centered from '@storybook/addon-centered/vue'"
`
)();

export default Centered;

if (module && module.hot && module.hot.decline) {
module.hot.decline();
}
1 change: 0 additions & 1 deletion addons/docs/angular/preset.js

This file was deleted.

1 change: 0 additions & 1 deletion addons/docs/html/preset.js

This file was deleted.

1 change: 0 additions & 1 deletion addons/docs/react/preset.js

This file was deleted.

17 changes: 0 additions & 17 deletions addons/docs/src/frameworks/common/makePreset.ts

This file was deleted.

1 change: 0 additions & 1 deletion addons/docs/vue/preset.js

This file was deleted.

1 change: 0 additions & 1 deletion addons/docs/web-components/preset.js

This file was deleted.

6 changes: 0 additions & 6 deletions addons/storysource/loader.js

This file was deleted.

3 changes: 1 addition & 2 deletions addons/storysource/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
"prop-types": "^15.7.2",
"react": "^16.9.17",
"react-syntax-highlighter": "^11.0.2",
"regenerator-runtime": "^0.13.3",
"util-deprecate": "^1.0.2"
"regenerator-runtime": "^0.13.3"
},
"devDependencies": {
"@types/react": "^16.9.19",
Expand Down
3 changes: 1 addition & 2 deletions addons/storysource/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ADDON_ID, PANEL_ID } from './events';
import { withStorySource } from './preview';

export { ADDON_ID, PANEL_ID, withStorySource };
export { ADDON_ID, PANEL_ID };

if (module && module.hot && module.hot.decline) {
module.hot.decline();
Expand Down
11 changes: 0 additions & 11 deletions addons/storysource/src/preview.ts

This file was deleted.