mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-12-20 23:22:10 +03:00
34 lines
816 B
JavaScript
34 lines
816 B
JavaScript
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() {
|
|
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;
|
|
}
|
|
}
|
|
|
|
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>
|
|
);
|
|
}
|