tor-browser

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

ContrastBadge.js (1472B)


      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 "use strict";
      5 
      6 // React
      7 const {
      8  createFactory,
      9  PureComponent,
     10 } = require("resource://devtools/client/shared/vendor/react.mjs");
     11 const PropTypes = require("resource://devtools/client/shared/vendor/react-prop-types.mjs");
     12 
     13 const {
     14  L10N,
     15 } = require("resource://devtools/client/accessibility/utils/l10n.js");
     16 
     17 const {
     18  accessibility: { SCORES },
     19 } = require("resource://devtools/shared/constants.js");
     20 
     21 loader.lazyGetter(this, "Badge", () =>
     22  createFactory(
     23    require("resource://devtools/client/accessibility/components/Badge.js")
     24  )
     25 );
     26 
     27 /**
     28 * Component for rendering a badge for contrast accessibliity check
     29 * failures association with a given accessibility object in the accessibility
     30 * tree.
     31 */
     32 class ContrastBadge extends PureComponent {
     33  static get propTypes() {
     34    return {
     35      error: PropTypes.string,
     36      score: PropTypes.string,
     37    };
     38  }
     39 
     40  render() {
     41    const { error, score } = this.props;
     42    if (error || score !== SCORES.FAIL) {
     43      return null;
     44    }
     45 
     46    return Badge({
     47      score,
     48      label: L10N.getStr("accessibility.badge.contrast"),
     49      ariaLabel: L10N.getStr("accessibility.badge.contrast.warning"),
     50      tooltip: L10N.getStr("accessibility.badge.contrast.tooltip"),
     51    });
     52  }
     53 }
     54 
     55 module.exports = ContrastBadge;