feat(nav): peel overlays with esc, close the book on a second esc

This commit is contained in:
pj committed 2026-08-10 18:37:23 +05:30
1 parent 2e15dc2dc9
commit fe39274ed7
12 files changed
+130 -59

No files matched your search

+2 -10
View File
@@ -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;