mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-07 09:25:27 +00:00
chore(refactor): rename context/modals to controllers/modals
This commit is contained in:
22
src/controllers/modals/ModalRenderer.tsx
Normal file
22
src/controllers/modals/ModalRenderer.tsx
Normal file
@@ -0,0 +1,22 @@
|
||||
import { observer } from "mobx-react-lite";
|
||||
|
||||
import { useEffect } from "preact/hooks";
|
||||
|
||||
import { modalController } from "./ModalController";
|
||||
|
||||
export default observer(() => {
|
||||
useEffect(() => {
|
||||
function keyUp(event: KeyboardEvent) {
|
||||
if (event.key === "Escape") {
|
||||
modalController.pop("close");
|
||||
} else if (event.key === "Enter") {
|
||||
modalController.pop("confirm");
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener("keyup", keyUp);
|
||||
return () => document.removeEventListener("keyup", keyUp);
|
||||
}, []);
|
||||
|
||||
return modalController.rendered;
|
||||
});
|
||||
Reference in New Issue
Block a user