Norbert de Langen f1d76a81fd
Merge branch 'next' into tech/overhaul-ui
# Conflicts:
#	addons/a11y/package.json
#	addons/actions/package.json
#	addons/backgrounds/package.json
#	addons/cssresources/package.json
#	addons/events/package.json
#	addons/google-analytics/package.json
#	addons/info/package.json
#	addons/jest/package.json
#	addons/knobs/package.json
#	addons/links/package.json
#	addons/notes/package.json
#	addons/storyshots/storyshots-core/package.json
#	addons/viewport/package.json
#	app/react/package.json
#	docs/package.json
#	docs/src/pages/configurations/theming/index.md
#	examples/cra-kitchen-sink/package.json
#	examples/official-storybook/package.json
#	examples/preact-kitchen-sink/package.json
#	lib/addons/package.json
#	lib/channel-websocket/package.json
#	lib/components/package.json
#	lib/core/package.json
#	lib/ui/package.json
#	yarn.lock
2018-12-19 22:37:36 +01:00
..
2017-11-11 22:00:21 +01:00

storybook-addon-a11y

This storybook addon can be helpful to make your UI components more accessible.

Framework Support

Getting started

First, install the addon.

$ yarn add @storybook/addon-a11y --dev

Add this line to your addons.js file (create this file inside your storybook config directory if needed).

import '@storybook/addon-a11y/register';

import the withA11Y decorator to check your stories for violations within your components.

import React from 'react';
import { storiesOf } from '@storybook/react';
import { withA11Y } from '@storybook/addon-a11y';

// should only be added once
// best place is in config.js
addDecorator(withA11Y)

storiesOf('button', module)
  .add('Accessible', () => (
    <button>
      Accessible button
    </button>
  ))
  .add('Inaccessible', () => (
    <button style={{ backgroundColor: 'red', color: 'darkRed', }}>
      Inaccessible button
    </button>
  ));

For more customizability. Use the addParameters function to configure aXe options. You can override these options at story level too.

import React from 'react';
import { storiesOf, addDecorator, addParameters } from '@storybook/react';

import { withA11Y } from '@storybook/addon-a11y';

addDecorator(withA11Y)
addParameters({ a11y: {} });

storiesOf('button', module)
  .add('Accessible', () => (
    <button style={{ backgroundColor: 'black', color: 'white', }}>
      Accessible button
    </button>
  ))
  .add('Inaccessible', () => (
    <button style={{ backgroundColor: 'black', color: 'black', }}>
      Inaccessible button
    </button>
  ));

Roadmap

  • Make UI accessibile
  • Show in story where violations are.
  • Add more example tests
  • Add tests
  • Make CI integration possible