mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-29 04:38:55 +03:00
c for opening composer, shift+c for opening it in new window
This commit is contained in:
parent
2540135962
commit
e4174b49d5
1 changed files with 23 additions and 16 deletions
|
@ -1,26 +1,33 @@
|
|||
import { useHotkeys } from 'react-hotkeys-hook';
|
||||
|
||||
import openCompose from '../utils/open-compose';
|
||||
import states from '../utils/states';
|
||||
|
||||
import Icon from './icon';
|
||||
|
||||
export default function ComposeButton() {
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
id="compose-button"
|
||||
onClick={(e) => {
|
||||
if (e.shiftKey) {
|
||||
const newWin = openCompose();
|
||||
function handleButton(e) {
|
||||
if (e.shiftKey) {
|
||||
const newWin = openCompose();
|
||||
|
||||
if (!newWin) {
|
||||
alert('Looks like your browser is blocking popups.');
|
||||
states.showCompose = true;
|
||||
}
|
||||
} else {
|
||||
states.showCompose = true;
|
||||
}
|
||||
}}
|
||||
>
|
||||
if (!newWin) {
|
||||
alert('Looks like your browser is blocking popups.');
|
||||
states.showCompose = true;
|
||||
}
|
||||
} else {
|
||||
states.showCompose = true;
|
||||
}
|
||||
}
|
||||
|
||||
useHotkeys('c, shift+c', handleButton, {
|
||||
ignoreEventWhen: (e) => {
|
||||
const hasModal = !!document.querySelector('#modal-container > *');
|
||||
return hasModal;
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<button type="button" id="compose-button" onClick={handleButton}>
|
||||
<Icon icon="quill" size="xl" alt="Compose" />
|
||||
</button>
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue