Add keyboard shortcut to open settings drawer

Fixes: #65
This commit is contained in:
Akshit Kr Nagpal 2018-06-24 12:56:52 +05:30 committed by Saúl Ibarra Corretgé
parent 2dcf7b32e9
commit f886f033f2
3 changed files with 32 additions and 0 deletions

View File

@ -2,6 +2,9 @@
import SettingsIcon from '@atlaskit/icon/glyph/settings';
import * as Mousetrap from 'mousetrap';
import 'mousetrap/plugins/global-bind/mousetrap-global-bind';
import React, { Component } from 'react';
import { connect } from 'react-redux';
import type { Dispatch } from 'redux';
@ -18,6 +21,11 @@ type Props = {
dispatch: Dispatch<*>;
};
/**
* Shortcut keys by which the drawer will open.
*/
const drawerShortcut = [ 'command+,', 'ctrl+shift+s' ];
/**
* Setttings button for Navigation Bar.
*/
@ -33,6 +41,24 @@ class SettingButton extends Component<Props, *> {
this._onIconClick = this._onIconClick.bind(this);
}
/**
* Bind shortcut when the component did mount.
*
* @returns {void}
*/
componentDidMount() {
Mousetrap.bindGlobal(drawerShortcut, this._onIconClick);
}
/**
* Bind shortcut when the component before unmount.
*
* @returns {void}
*/
componentWillUnmount() {
Mousetrap.unbind(drawerShortcut);
}
/**
* Render function of component.
*

5
package-lock.json generated
View File

@ -8461,6 +8461,11 @@
}
}
},
"mousetrap": {
"version": "1.6.2",
"resolved": "https://registry.npmjs.org/mousetrap/-/mousetrap-1.6.2.tgz",
"integrity": "sha512-jDjhi7wlHwdO6q6DS7YRmSHcuI+RVxadBkLt3KHrhd3C2b+w5pKefg3oj5beTcHZyVFA9Aksf+yEE1y5jxUjVA=="
},
"move-concurrently": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz",

View File

@ -45,6 +45,7 @@
"history": "4.7.2",
"jitsi-meet-electron-utils": "github:jitsi/jitsi-meet-electron-utils#1972c3bf0884ace68eb496894dabae593d6dbf49",
"js-md5": "0.7.3",
"mousetrap": "1.6.2",
"react": "16.3.2",
"react-dom": "16.3.2",
"react-redux": "5.0.7",