Skip to content

Commit

Permalink
Merge pull request #74 from emulsify-ds/a11y-rules-check
Browse files Browse the repository at this point in the history
A11y rules check
  • Loading branch information
callinmullaney authored Oct 17, 2024
2 parents 47d7e5e + 764227b commit df2dd6a
Show file tree
Hide file tree
Showing 4 changed files with 1,307 additions and 1,446 deletions.
26 changes: 26 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
import { useEffect } from '@storybook/preview-api';
import Twig from 'twig';
import { setupTwig, fetchCSSFiles } from './utils.js';
import { getRules } from "axe-core";

// If in a Drupal project, it's recommended to import a symlinked version of drupal.js.
import './_drupal.js';

function enableRulesByTag(tags = []) {
const allRules = getRules();
return allRules.map(rule =>
tags.some(t => rule.tags.includes(t)) ? { id: rule.ruleId, enabled: true } : { id: rule.ruleId, enabled: false }
);
}

const AxeRules = enableRulesByTag([
"wcag2a",
"wcag2aa",
"wcag21a",
"wcag21aa",
"wcag22aa",
"best-practice",
]);

export const decorators = [
(Story, { args }) => {
const { renderAs } = args || {};
Expand All @@ -22,4 +39,13 @@ fetchCSSFiles();

export const parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
a11y: {
config: {
detailedReport: true,
detailedReportOptions: {
html: true,
},
rules: AxeRules,
},
},
};
1 change: 1 addition & 0 deletions config/webpack/resolves.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ function getAliases(aliasMatcher) {
[`@${name}`]: `${projectDir}/${path.basename(srcDir)}/${dir}`,
});
});

return aliases;
}

Expand Down
Loading

0 comments on commit df2dd6a

Please sign in to comment.