tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

KeyboardBadge.js (1469B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 "use strict";
      6 
      7 // React
      8 const {
      9  createFactory,
     10  PureComponent,
     11 } = require("resource://devtools/client/shared/vendor/react.mjs");
     12 const PropTypes = require("resource://devtools/client/shared/vendor/react-prop-types.mjs");
     13 
     14 const {
     15  L10N,
     16 } = require("resource://devtools/client/accessibility/utils/l10n.js");
     17 
     18 const {
     19  accessibility: {
     20    SCORES: { BEST_PRACTICES, FAIL, WARNING },
     21  },
     22 } = require("resource://devtools/shared/constants.js");
     23 
     24 loader.lazyGetter(this, "Badge", () =>
     25  createFactory(
     26    require("resource://devtools/client/accessibility/components/Badge.js")
     27  )
     28 );
     29 
     30 /**
     31 * Component for rendering a badge for keyboard accessibliity check failures
     32 * association with a given accessibility object in the accessibility tree.
     33 */
     34 class KeyboardBadge extends PureComponent {
     35  static get propTypes() {
     36    return {
     37      error: PropTypes.string,
     38      score: PropTypes.string,
     39    };
     40  }
     41 
     42  render() {
     43    const { error, score } = this.props;
     44    if (error || ![BEST_PRACTICES, FAIL, WARNING].includes(score)) {
     45      return null;
     46    }
     47 
     48    return Badge({
     49      score,
     50      label: L10N.getStr("accessibility.badge.keyboard"),
     51      tooltip: L10N.getStr("accessibility.badge.keyboard.tooltip"),
     52    });
     53  }
     54 }
     55 
     56 module.exports = KeyboardBadge;