Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use @axe-core/react in dev #4358

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.