Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add useKeyPress hooks and shortcut in ImportModal #62

Merged
merged 14 commits into from
Jul 21, 2022

Conversation

cihat
Copy link
Contributor

@cihat cihat commented Jun 16, 2022

No description provided.

@@ -7,6 +7,7 @@ import { ConfigActionType } from "src/reducer/reducer";
import { Modal, ModalProps } from "src/components/Modal";
import { Button } from "src/components/Button";
import { AiOutlineUpload } from "react-icons/ai";
import useKeyPress from "../../hooks/useKeyPress";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change import to absolute path

const handleEspacePress = useKeyPress("Escape");
const handleEnterKeyPress = useKeyPress("Enter");
React.useEffect(() => {
if (handleEspacePress) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reduce condition to single line if (...) doSomething()

src/hooks/useKeyPress.tsx Outdated Show resolved Hide resolved
const [keyPressed, setKeyPressed] = React.useState(false);

function downHandler({ key }) {
if (key === targetKey) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reduce conditions to one line

}
}
const upHandler = ({ key }) => {
if (key === targetKey) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reduce conditions to one line

@AykutSarac
Copy link
Owner

Please add key shortcuts to Modal component globally instead of single one, better than saving the day only :)

@AykutSarac AykutSarac merged commit fc5f75c into AykutSarac:main Jul 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants