tor-browser

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

TextLabelBadge.js (1484B)


      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 text alternative accessibliity check
     32 * failures association with a given accessibility object in the accessibility
     33 * tree.
     34 */
     35 class TextLabelBadge extends PureComponent {
     36  static get propTypes() {
     37    return {
     38      error: PropTypes.string,
     39      score: PropTypes.string,
     40    };
     41  }
     42 
     43  render() {
     44    const { error, score } = this.props;
     45    if (error || ![BEST_PRACTICES, FAIL, WARNING].includes(score)) {
     46      return null;
     47    }
     48 
     49    return Badge({
     50      score,
     51      label: L10N.getStr("accessibility.badge.textLabel"),
     52      tooltip: L10N.getStr("accessibility.badge.textLabel.tooltip"),
     53    });
     54  }
     55 }
     56 
     57 module.exports = TextLabelBadge;