-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3555 from storybooks/generic-addon-decorators
Generic addon decorators
- Loading branch information
Showing
106 changed files
with
576 additions
and
2,070 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,37 @@ | ||
import { document } from 'global'; | ||
import axe from 'axe-core'; | ||
import addons from '@storybook/addons'; | ||
import Events from '@storybook/core-events'; | ||
import { logger } from '@storybook/client-logger'; | ||
|
||
import A11yManager from './A11yManager'; | ||
import * as shared from './shared'; | ||
import { CHECK_EVENT_ID, RERUN_EVENT_ID } from './shared'; | ||
|
||
const manager = new A11yManager(); | ||
let axeOptions = {}; | ||
|
||
function checkA11y(storyFn, context) { | ||
export const configureA11y = (options = {}) => { | ||
axeOptions = options; | ||
}; | ||
|
||
const runA11yCheck = () => { | ||
const channel = addons.getChannel(); | ||
return manager.wrapStory(channel, storyFn, context, axeOptions); | ||
} | ||
const wrapper = document.getElementById('root'); | ||
|
||
function configureA11y(options = {}) { | ||
axeOptions = options; | ||
} | ||
axe.reset(); | ||
axe.configure(axeOptions); | ||
axe.run(wrapper).then(results => channel.emit(CHECK_EVENT_ID, results), logger.error); | ||
}; | ||
|
||
const a11ySubscription = () => { | ||
const channel = addons.getChannel(); | ||
channel.on(Events.STORY_RENDERED, runA11yCheck); | ||
channel.on(RERUN_EVENT_ID, runA11yCheck); | ||
return () => { | ||
channel.removeListener(Events.STORY_RENDERED, runA11yCheck); | ||
channel.removeListener(RERUN_EVENT_ID, runA11yCheck); | ||
}; | ||
}; | ||
|
||
export { checkA11y, shared, configureA11y }; | ||
export const checkA11y = story => { | ||
addons.getChannel().emit(Events.REGISTER_SUBSCRIPTION, a11ySubscription); | ||
return story(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
module.exports = require('./dist/mithril'); | ||
module.exports = require('./dist/deprecated'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import deprecate from 'util-deprecate'; | ||
|
||
import backgrounds from '.'; | ||
|
||
export default deprecate( | ||
backgrounds, | ||
"addon-backgrounds: framework-specific imports are deprecated, just use `import backgrounds from '@storybook/addon-backgrounds`" | ||
); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.