mirror of
https://github.com/priyanshujain/margin.git
synced 2026-10-02 19:17:03 +00:00
feat(nav): peel overlays with esc, close the book on a second esc
This commit is contained in:
1 parent
2e15dc2dc9
commit
fe39274ed7
12 files changed
+130
-59
No files matched your search
@@ -13,6 +13,7 @@ import {
|
||||
fontStack,
|
||||
pairingFor,
|
||||
} from "../model/fonts";
|
||||
import { useEscapeLayer } from "../escape";
|
||||
import { Icon } from "./Icon";
|
||||
|
||||
const LANGUAGES = [
|
||||
@@ -94,16 +95,7 @@ export function Settings({ onClose, onSave }: { onClose: () => void; onSave: ()
|
||||
});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => {
|
||||
if (e.key === "Escape") {
|
||||
e.preventDefault();
|
||||
onClose();
|
||||
}
|
||||
};
|
||||
window.addEventListener("keydown", onKey);
|
||||
return () => window.removeEventListener("keydown", onKey);
|
||||
}, [onClose]);
|
||||
useEscapeLayer(true, onClose);
|
||||
|
||||
if (!book) return null;
|
||||
|
||||
|
||||
Reference in new issue
Block a user