tor-browser

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

CommandBarButton.js (1378B)


      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 React from "devtools/client/shared/vendor/react";
      6 import { button } from "devtools/client/shared/vendor/react-dom-factories";
      7 import PropTypes from "devtools/client/shared/vendor/react-prop-types";
      8 
      9 import DebuggerImage from "../DebuggerImage";
     10 
     11 const classnames = require("resource://devtools/client/shared/classnames.js");
     12 
     13 export function debugBtn(
     14  onClick,
     15  type,
     16  className,
     17  tooltip,
     18  disabled = false,
     19  ariaPressed = false
     20 ) {
     21  return React.createElement(
     22    CommandBarButton,
     23    {
     24      className: classnames(type, className),
     25      disabled,
     26      key: type,
     27      onClick,
     28      pressed: ariaPressed,
     29      title: tooltip,
     30    },
     31    React.createElement(DebuggerImage, {
     32      name: type,
     33    })
     34  );
     35 }
     36 const CommandBarButton = props => {
     37  const { children, className, pressed = false, ...rest } = props;
     38 
     39  return button(
     40    {
     41      "aria-pressed": pressed,
     42      className: classnames("command-bar-button", className),
     43      ...rest,
     44    },
     45    children
     46  );
     47 };
     48 
     49 CommandBarButton.propTypes = {
     50  children: PropTypes.node.isRequired,
     51  className: PropTypes.string.isRequired,
     52  pressed: PropTypes.bool,
     53 };
     54 
     55 export default CommandBarButton;