diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /devtools/client/accessibility/components/KeyboardCheck.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/accessibility/components/KeyboardCheck.js')
-rw-r--r-- | devtools/client/accessibility/components/KeyboardCheck.js | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/devtools/client/accessibility/components/KeyboardCheck.js b/devtools/client/accessibility/components/KeyboardCheck.js new file mode 100644 index 0000000000..0109dd22b0 --- /dev/null +++ b/devtools/client/accessibility/components/KeyboardCheck.js @@ -0,0 +1,94 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +"use strict"; + +// React +const { + createFactory, + PureComponent, +} = require("resource://devtools/client/shared/vendor/react.js"); +const PropTypes = require("resource://devtools/client/shared/vendor/react-prop-types.js"); +const ReactDOM = require("resource://devtools/client/shared/vendor/react-dom-factories.js"); + +const Check = createFactory( + require("resource://devtools/client/accessibility/components/Check.js") +); + +const { + A11Y_KEYBOARD_LINKS, +} = require("resource://devtools/client/accessibility/constants.js"); +const { + accessibility: { + AUDIT_TYPE: { KEYBOARD }, + ISSUE_TYPE: { + [KEYBOARD]: { + FOCUSABLE_NO_SEMANTICS, + FOCUSABLE_POSITIVE_TABINDEX, + INTERACTIVE_NO_ACTION, + INTERACTIVE_NOT_FOCUSABLE, + MOUSE_INTERACTIVE_ONLY, + NO_FOCUS_VISIBLE, + }, + }, + }, +} = require("resource://devtools/shared/constants.js"); + +/** + * A map from text label issues to annotation component properties. + */ +const ISSUE_TO_ANNOTATION_MAP = { + [FOCUSABLE_NO_SEMANTICS]: { + href: A11Y_KEYBOARD_LINKS.FOCUSABLE_NO_SEMANTICS, + l10nId: "accessibility-keyboard-issue-semantics", + }, + [FOCUSABLE_POSITIVE_TABINDEX]: { + href: A11Y_KEYBOARD_LINKS.FOCUSABLE_POSITIVE_TABINDEX, + l10nId: "accessibility-keyboard-issue-tabindex", + args: { + get code() { + return ReactDOM.code({}, "tabindex"); + }, + }, + }, + [INTERACTIVE_NO_ACTION]: { + href: A11Y_KEYBOARD_LINKS.INTERACTIVE_NO_ACTION, + l10nId: "accessibility-keyboard-issue-action", + }, + [INTERACTIVE_NOT_FOCUSABLE]: { + href: A11Y_KEYBOARD_LINKS.INTERACTIVE_NOT_FOCUSABLE, + l10nId: "accessibility-keyboard-issue-focusable", + }, + [MOUSE_INTERACTIVE_ONLY]: { + href: A11Y_KEYBOARD_LINKS.MOUSE_INTERACTIVE_ONLY, + l10nId: "accessibility-keyboard-issue-mouse-only", + }, + [NO_FOCUS_VISIBLE]: { + href: A11Y_KEYBOARD_LINKS.NO_FOCUS_VISIBLE, + l10nId: "accessibility-keyboard-issue-focus-visible", + }, +}; + +/** + * Component for rendering a check for text label accessibliity check failures, + * warnings and best practices suggestions association with a given + * accessibility object in the accessibility tree. + */ +class KeyboardCheck extends PureComponent { + static get propTypes() { + return { + issue: PropTypes.string.isRequired, + score: PropTypes.string.isRequired, + }; + } + + render() { + return Check({ + ...this.props, + getAnnotation: issue => ISSUE_TO_ANNOTATION_MAP[issue], + id: "accessibility-keyboard-header", + }); + } +} + +module.exports = KeyboardCheck; |