Skip to content

Commit

Permalink
Merge pull request #9951 from jonspalmer/remove_deprecated_addon_deco…
Browse files Browse the repository at this point in the history
…rators

Remove deprecated decorators and loaders
  • Loading branch information
shilman authored Mar 12, 2020
2 parents 131f01d + d603f7f commit a209fc2
Show file tree
Hide file tree
Showing 18 changed files with 42 additions and 125 deletions.
34 changes: 34 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- [Imported types](#imported-types)
- [Rolling back](#rolling-back)
- [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-decoratorsparameters-after-stories)
Expand Down Expand Up @@ -50,6 +51,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 @@ -207,6 +209,18 @@ 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 @@ -869,6 +883,26 @@ 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

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];
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.25",
"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.

0 comments on commit a209fc2

Please sign in to comment.