Addon-A11y: add deprecated withA11y

This commit is contained in:
tooppaaa 2020-05-17 22:12:20 +02:00
parent d6878e6c7b
commit 94fbca1121
6 changed files with 48 additions and 9 deletions

View File

@ -46,7 +46,9 @@
"global": "^4.3.2",
"lodash": "^4.17.15",
"react-sizeme": "^2.5.2",
"regenerator-runtime": "^0.13.3"
"regenerator-runtime": "^0.13.3",
"ts-dedent": "^1.1.1",
"util-deprecate": "^1.0.2"
},
"devDependencies": {
"@testing-library/react": "^10.0.4",

View File

@ -1,5 +1,24 @@
import { DecoratorFunction } from '@storybook/addons';
import deprecate from 'util-deprecate';
import dedent from 'ts-dedent';
export * from './highlight';
if (module && module.hot && module.hot.decline) {
module.hot.decline();
}
export const withA11y: DecoratorFunction = deprecate(
(storyFn, storyContext) => {
return storyFn(storyContext);
},
dedent`
withA11y(options) is deprecated, please configure addon-a11y using the addParameter api:
addParameters({
a11y: options,
});
More at: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#removed-witha11y-decorator
`
);

View File

@ -1,7 +0,0 @@
export function managerEntries(entry: any[] = []) {
return [...entry, require.resolve('./register')];
}
export function config(entry: any[] = []) {
return [...entry, require.resolve('./a11yRunner'), require.resolve('./a11yHighlight')];
}

View File

@ -0,0 +1,3 @@
import { withA11y } from '../index';
export const decorators = [withA11y];

View File

@ -0,0 +1,12 @@
export function managerEntries(entry: any[] = []) {
return [...entry, require.resolve('./register')];
}
export function config(entry: any[] = [], { addDecorator = true } = {}) {
return [
...entry,
require.resolve('./a11yRunner'),
require.resolve('./a11yHighlight'),
addDecorator && require.resolve('./addDecorator'),
].filter(Boolean);
}

View File

@ -28115,7 +28115,17 @@ send@^0.16.2:
range-parser "~1.2.0"
statuses "~1.4.0"
serialize-javascript@^1.4.0, serialize-javascript@^2.1.2, serialize-javascript@^3.0.0:
serialize-javascript@^1.4.0:
version "1.9.1"
resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-1.9.1.tgz#cfc200aef77b600c47da9bb8149c943e798c2fdb"
integrity sha512-0Vb/54WJ6k5v8sSWN09S0ora+Hnr+cX40r9F170nT+mSkaxltoE/7R3OrIdBSUv1OoiobH1QoWQbCnAO+e8J1A==
serialize-javascript@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-2.1.2.tgz#ecec53b0e0317bdc95ef76ab7074b7384785fa61"
integrity sha512-rs9OggEUF0V4jUSecXazOYsLfu7OGK2qIn3c7IPBiffz32XniEp/TX9Xmc9LQfK2nQ2QKHvZ2oygKUGU0lG4jQ==
serialize-javascript@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-3.0.0.tgz#492e489a2d77b7b804ad391a5f5d97870952548e"
integrity sha512-skZcHYw2vEX4bw90nAr2iTTsz6x2SrHEnfxgKYmZlvJYBEZrvbKtobJWlQ20zczKb3bsHHXXTYt48zBA7ni9cw==