@techsio/storybook-better-a11y 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AccessibilityRuleMaps.js +532 -0
- package/dist/a11yRunner.js +105 -0
- package/dist/a11yRunner.test.js +21 -0
- package/dist/a11yRunnerUtils.js +30 -0
- package/dist/a11yRunnerUtils.test.js +61 -0
- package/dist/{699.js → apcaChecker.js} +1 -255
- package/dist/apcaChecker.test.js +124 -0
- package/dist/axeRuleMappingHelper.js +4 -0
- package/dist/components/A11YPanel.js +140 -0
- package/dist/components/A11YPanel.stories.js +198 -0
- package/dist/components/A11YPanel.test.js +110 -0
- package/dist/components/A11yContext.js +438 -0
- package/dist/components/A11yContext.test.js +277 -0
- package/dist/components/Report/Details.js +169 -0
- package/dist/components/Report/Report.js +106 -0
- package/dist/components/Report/Report.stories.js +86 -0
- package/dist/components/Tabs.js +54 -0
- package/dist/components/TestDiscrepancyMessage.js +55 -0
- package/dist/components/TestDiscrepancyMessage.stories.js +40 -0
- package/dist/components/VisionSimulator.js +83 -0
- package/dist/components/VisionSimulator.stories.js +56 -0
- package/dist/constants.js +25 -0
- package/dist/index.js +5 -6
- package/dist/manager.js +11 -1540
- package/dist/manager.test.js +86 -0
- package/dist/params.js +0 -0
- package/dist/postinstall.js +1 -1
- package/dist/preview.js +68 -1
- package/dist/preview.test.js +215 -0
- package/dist/results.mock.js +874 -0
- package/dist/types.js +6 -0
- package/dist/utils.js +21 -0
- package/dist/{100.js → visionSimulatorFilters.js} +1 -23
- package/dist/withVisionSimulator.js +41 -0
- package/package.json +1 -1
- package/dist/212.js +0 -1965
- package/dist/212.js.LICENSE.txt +0 -19
- package/dist/rslib-runtime.js +0 -37
package/dist/types.js
ADDED
package/dist/utils.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
function getIsVitestStandaloneRun() {
|
|
2
|
+
try {
|
|
3
|
+
return 'false' === ({
|
|
4
|
+
MODE: "production",
|
|
5
|
+
DEV: false,
|
|
6
|
+
PROD: true,
|
|
7
|
+
BASE_URL: "/",
|
|
8
|
+
ASSET_PREFIX: "auto"
|
|
9
|
+
}).VITEST_STORYBOOK;
|
|
10
|
+
} catch (e) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function getIsVitestRunning() {
|
|
15
|
+
try {
|
|
16
|
+
return false;
|
|
17
|
+
} catch (e) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export { getIsVitestRunning, getIsVitestStandaloneRun };
|
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
const ADDON_ID = 'storybook/a11y';
|
|
2
|
-
const PANEL_ID = `${ADDON_ID}/panel`;
|
|
3
|
-
"a11y";
|
|
4
|
-
"vision";
|
|
5
|
-
const RESULT = `${ADDON_ID}/result`;
|
|
6
|
-
const REQUEST = `${ADDON_ID}/request`;
|
|
7
|
-
const RUNNING = `${ADDON_ID}/running`;
|
|
8
|
-
const ERROR = `${ADDON_ID}/error`;
|
|
9
|
-
const MANUAL = `${ADDON_ID}/manual`;
|
|
10
|
-
const SELECT = `${ADDON_ID}/select`;
|
|
11
|
-
const DOCUMENTATION_LINK = 'writing-tests/accessibility-testing';
|
|
12
|
-
const DOCUMENTATION_DISCREPANCY_LINK = `${DOCUMENTATION_LINK}#why-are-my-tests-failing-in-different-environments`;
|
|
13
|
-
const EVENTS = {
|
|
14
|
-
RESULT: RESULT,
|
|
15
|
-
REQUEST: REQUEST,
|
|
16
|
-
RUNNING: RUNNING,
|
|
17
|
-
ERROR: ERROR,
|
|
18
|
-
MANUAL: MANUAL,
|
|
19
|
-
SELECT: SELECT
|
|
20
|
-
};
|
|
21
|
-
const STATUS_TYPE_ID_COMPONENT_TEST = 'storybook/component-test';
|
|
22
|
-
const STATUS_TYPE_ID_A11Y = 'storybook/a11y';
|
|
23
1
|
const filters = {
|
|
24
2
|
blurred: {
|
|
25
3
|
label: 'Blurred vision',
|
|
@@ -119,4 +97,4 @@ const filterDefs = `<svg id="storybook-a11y-vision-filters" style="display: none
|
|
|
119
97
|
</filter>
|
|
120
98
|
</defs>
|
|
121
99
|
</svg>`;
|
|
122
|
-
export {
|
|
100
|
+
export { filterDefs, filters };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useCallback, useEffect } from "storybook/preview-api";
|
|
2
|
+
import { filterDefs, filters } from "./visionSimulatorFilters.js";
|
|
3
|
+
const knownFilters = Object.values(filters).map((f)=>f.filter);
|
|
4
|
+
const knownFiltersRegExp = new RegExp(`\\b(${knownFilters.join('|')})\\b`, 'g');
|
|
5
|
+
const withVisionSimulator = (StoryFn, { globals })=>{
|
|
6
|
+
const { vision } = globals;
|
|
7
|
+
const applyVisionFilter = useCallback(()=>{
|
|
8
|
+
const existingFilters = document.body.style.filter.replaceAll(knownFiltersRegExp, '').trim();
|
|
9
|
+
const visionFilter = filters[vision]?.filter;
|
|
10
|
+
if (visionFilter && document.body.classList.contains('sb-show-main')) if (existingFilters && 'none' !== existingFilters) document.body.style.filter = `${existingFilters} ${visionFilter}`;
|
|
11
|
+
else document.body.style.filter = visionFilter;
|
|
12
|
+
else document.body.style.filter = existingFilters || 'none';
|
|
13
|
+
return ()=>document.body.style.filter = existingFilters || 'none';
|
|
14
|
+
}, [
|
|
15
|
+
vision
|
|
16
|
+
]);
|
|
17
|
+
useEffect(()=>{
|
|
18
|
+
const cleanup = applyVisionFilter();
|
|
19
|
+
const observer = new MutationObserver(()=>applyVisionFilter());
|
|
20
|
+
observer.observe(document.body, {
|
|
21
|
+
attributeFilter: [
|
|
22
|
+
'class'
|
|
23
|
+
]
|
|
24
|
+
});
|
|
25
|
+
return ()=>{
|
|
26
|
+
cleanup();
|
|
27
|
+
observer.disconnect();
|
|
28
|
+
};
|
|
29
|
+
}, [
|
|
30
|
+
applyVisionFilter
|
|
31
|
+
]);
|
|
32
|
+
useEffect(()=>{
|
|
33
|
+
document.body.insertAdjacentHTML('beforeend', filterDefs);
|
|
34
|
+
return ()=>{
|
|
35
|
+
const filterDefsElement = document.getElementById('storybook-a11y-vision-filters');
|
|
36
|
+
filterDefsElement?.parentElement?.removeChild(filterDefsElement);
|
|
37
|
+
};
|
|
38
|
+
}, []);
|
|
39
|
+
return StoryFn();
|
|
40
|
+
};
|
|
41
|
+
export { withVisionSimulator };
|