tor-browser

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

Modal.js (1182B)


      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 import PropTypes from "devtools/client/shared/vendor/react-prop-types";
      6 import React from "devtools/client/shared/vendor/react";
      7 import { div } from "devtools/client/shared/vendor/react-dom-factories";
      8 const classnames = require("resource://devtools/client/shared/classnames.js");
      9 
     10 class Modal extends React.Component {
     11  static get propTypes() {
     12    return {
     13      additionalClass: PropTypes.string,
     14      children: PropTypes.node.isRequired,
     15      handleClose: PropTypes.func.isRequired,
     16    };
     17  }
     18 
     19  onClick = e => {
     20    e.stopPropagation();
     21  };
     22 
     23  render() {
     24    const { additionalClass, children, handleClose } = this.props;
     25    return div(
     26      {
     27        className: "modal-wrapper",
     28        onClick: handleClose,
     29      },
     30      div(
     31        {
     32          className: classnames("modal", additionalClass),
     33          onClick: this.onClick,
     34        },
     35        children
     36      )
     37    );
     38  }
     39 }
     40 
     41 Modal.contextTypes = {
     42  shortcuts: PropTypes.object,
     43 };
     44 
     45 export default Modal;