tor-browser

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

FontName.js (1417B)


      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 const {
      8  PureComponent,
      9 } = require("resource://devtools/client/shared/vendor/react.mjs");
     10 const dom = require("resource://devtools/client/shared/vendor/react-dom-factories.js");
     11 const PropTypes = require("resource://devtools/client/shared/vendor/react-prop-types.mjs");
     12 
     13 const Types = require("resource://devtools/client/inspector/fonts/types.js");
     14 
     15 class FontName extends PureComponent {
     16  static get propTypes() {
     17    return {
     18      font: PropTypes.shape(Types.font).isRequired,
     19      onToggleFontHighlight: PropTypes.func.isRequired,
     20    };
     21  }
     22 
     23  constructor(props) {
     24    super(props);
     25    this.onNameMouseOver = this.onNameMouseOver.bind(this);
     26    this.onNameMouseOut = this.onNameMouseOut.bind(this);
     27  }
     28 
     29  onNameMouseOver() {
     30    const { font, onToggleFontHighlight } = this.props;
     31 
     32    onToggleFontHighlight(font, true);
     33  }
     34 
     35  onNameMouseOut() {
     36    const { font, onToggleFontHighlight } = this.props;
     37 
     38    onToggleFontHighlight(font, false);
     39  }
     40 
     41  render() {
     42    return dom.span(
     43      {
     44        className: "font-name",
     45        onMouseOver: this.onNameMouseOver,
     46        onMouseOut: this.onNameMouseOut,
     47      },
     48      this.props.font.name
     49    );
     50  }
     51 }
     52 
     53 module.exports = FontName;