UNPKG

1.85 kBJavaScriptView Raw
1import React from 'react';
2import { addons, types } from '@storybook/addons';
3import { ADDON_ID, PANEL_ID, PARAM_KEY } from './constants';
4import { VisionSimulator } from './components/VisionSimulator';
5import { A11YPanel } from './components/A11YPanel';
6import { A11yContextProvider } from './components/A11yContext';
7addons.register(ADDON_ID, function (api) {
8 addons.add(PANEL_ID, {
9 title: '',
10 type: types.TOOL,
11 match: function match(_ref) {
12 var viewMode = _ref.viewMode;
13 return viewMode === 'story';
14 },
15 render: function render() {
16 return /*#__PURE__*/React.createElement(VisionSimulator, null);
17 }
18 });
19 addons.add(PANEL_ID, {
20 title: function title() {
21 var _addonState$violation, _addonState$incomplet;
22
23 var addonState = api === null || api === void 0 ? void 0 : api.getAddonState(ADDON_ID);
24 var violationsNb = (addonState === null || addonState === void 0 ? void 0 : (_addonState$violation = addonState.violations) === null || _addonState$violation === void 0 ? void 0 : _addonState$violation.length) || 0;
25 var incompleteNb = (addonState === null || addonState === void 0 ? void 0 : (_addonState$incomplet = addonState.incomplete) === null || _addonState$incomplet === void 0 ? void 0 : _addonState$incomplet.length) || 0;
26 var totalNb = violationsNb + incompleteNb;
27 return totalNb !== 0 ? "Accessibility (".concat(totalNb, ")") : 'Accessibility';
28 },
29 type: types.PANEL,
30 render: function render(_ref2) {
31 var _ref2$active = _ref2.active,
32 active = _ref2$active === void 0 ? true : _ref2$active,
33 key = _ref2.key;
34 return /*#__PURE__*/React.createElement(A11yContextProvider, {
35 key: key,
36 active: active
37 }, /*#__PURE__*/React.createElement(A11YPanel, null));
38 },
39 paramKey: PARAM_KEY
40 });
41});
\No newline at end of file