Skip to content

Commit

Permalink
chore: use @axe-core/react in dev
Browse files Browse the repository at this point in the history
  • Loading branch information
barmac authored and nikku committed Jun 11, 2024
1 parent d22eec6 commit 6a3b9fd
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 0 deletions.
1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
},
"homepage": ".",
"devDependencies": {
"@axe-core/react": "^4.9.1",
"@babel/core": "^7.23.9",
"@babel/preset-env": "^7.23.9",
"@babel/preset-react": "^7.23.3",
Expand Down
5 changes: 5 additions & 0 deletions client/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ const globals = {

async function render() {

if (process.env.NODE_ENV !== 'production') {
const { loadA11yHelper } = await import('./util/a11y');
await loadA11yHelper();
}

// load plugins
plugins.bindHelpers(window);

Expand Down
23 changes: 23 additions & 0 deletions client/src/util/a11y.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
* under one or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information regarding copyright
* ownership.
*
* Camunda licenses this file to you under the MIT; you may not use this file
* except in compliance with the MIT License.
*/

import React from 'react';
import ReactDOM from 'react-dom';

const DEFAULT_TAGS = [ 'wcag2a', 'wcag21a' ];

export async function loadA11yHelper() {

// TODO(@barmac): remove or replace when upgraded to React 18
const axe = await import('@axe-core/react');
axe.default(React, ReactDOM, 1000, {
runOnly: DEFAULT_TAGS
});
}
52 changes: 52 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6a3b9fd

Please sign in to comment.