mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-09 01:26:24 +01: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,14 +1,12 @@
|
||||||
|
import { useHotkeys } from 'react-hotkeys-hook';
|
||||||
|
|
||||||
import openCompose from '../utils/open-compose';
|
import openCompose from '../utils/open-compose';
|
||||||
import states from '../utils/states';
|
import states from '../utils/states';
|
||||||
|
|
||||||
import Icon from './icon';
|
import Icon from './icon';
|
||||||
|
|
||||||
export default function ComposeButton() {
|
export default function ComposeButton() {
|
||||||
return (
|
function handleButton(e) {
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
id="compose-button"
|
|
||||||
onClick={(e) => {
|
|
||||||
if (e.shiftKey) {
|
if (e.shiftKey) {
|
||||||
const newWin = openCompose();
|
const newWin = openCompose();
|
||||||
|
|
||||||
|
@ -19,8 +17,17 @@ export default function ComposeButton() {
|
||||||
} else {
|
} else {
|
||||||
states.showCompose = true;
|
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" />
|
<Icon icon="quill" size="xl" alt="Compose" />
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue