diff options
| author | Andrei Mihailov <and.mikhaylov@gmail.com> | 2017-02-16 12:18:52 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-02-16 12:18:52 +0000 |
| commit | 4aaf7e0ddbbdf9a5e03fdbb20ecabe4866de96c3 (patch) | |
| tree | 8f7dfc5545c484472d3dc5138cddf6a810fa0558 /app/lib | |
| parent | 5ba4a72e546747167e7ae815724ee2dd4b2ef8fb (diff) | |
| download | mullvadvpn-4aaf7e0ddbbdf9a5e03fdbb20ecabe4866de96c3.tar.xz mullvadvpn-4aaf7e0ddbbdf9a5e03fdbb20ecabe4866de96c3.zip | |
Feature/menubar popup window (#1)
Add menubar and tests
Diffstat (limited to 'app/lib')
| -rw-r--r-- | app/lib/components/TrayMenu.js | 120 |
1 files changed, 0 insertions, 120 deletions
diff --git a/app/lib/components/TrayMenu.js b/app/lib/components/TrayMenu.js deleted file mode 100644 index 5f14ca71f9..0000000000 --- a/app/lib/components/TrayMenu.js +++ /dev/null @@ -1,120 +0,0 @@ -/** - * Declarative Tray implementation for React + Electron - */ - -import React, { Component, PropTypes } from 'react'; -import { remote } from 'electron'; - -const { Menu, MenuItem } = remote; - -/** - * Tray menu component - * - * Example: - * - * const tray = new remote.Tray('/path/to/icon'); - * - * return ( - * <TrayMenu tray={tray}> - * <TrayItem label="Visit homepage" /> - * </TrayMenu> - * ) - */ -export class TrayMenu extends Component { - - static childContextTypes = { - menu: PropTypes.object.isRequired - }; - - static propTypes = { - tray: PropTypes.object.isRequired, - children: PropTypes.arrayOf(PropTypes.node).isRequired - }; - - _contextMenu = null; - - getChildContext() { - return { menu: this._contextMenu }; - } - - componentDidMount() { - this.props.tray.setContextMenu(this._contextMenu); - } - - componentDidUpdate() { - this.props.tray.setContextMenu(this._contextMenu); - } - - render() { - // create new menu during each rendering - // see: https://github.com/electron/electron/issues/8598 - this._contextMenu = new Menu(); - - return ( - <div>{this.props.children}</div> - ); - } - -} - -/** - * Submenu component - * - * Example: - * - * <TrayMenu tray={this.props.handle}> - * <TraySubmenu label="Resources"> - * <TrayItem label="Homepage" /> - * </TraySubmenu> - * </TrayMenu> - * - */ -export class TraySubmenu extends Component { - - static contextTypes = { - menu: PropTypes.object.isRequired - }; - - static childContextTypes = { - menu: PropTypes.object.isRequired - }; - - static propTypes = { - children: PropTypes.arrayOf(PropTypes.node).isRequired - }; - - _contextMenu = null; - - getChildContext() { - return { menu: this._contextMenu }; - } - - render() { - // create new menu during each rendering - // see: https://github.com/electron/electron/issues/8598 - this._contextMenu = new Menu(); - - this.context.menu.append(new MenuItem({ ...this.props, submenu: this._contextMenu })); - - return ( - <div>{this.props.children}</div> - ); - } - -} - -/** - * Item component - */ -export class TrayItem extends Component { - - static contextTypes = { - menu: PropTypes.object.isRequired - }; - - render() { - this.context.menu.append(new MenuItem(this.props)); - return null; - } - -} |
