static: close modal on escape key

This commit is contained in:
Jens Langhammer 2020-11-21 15:24:45 +01:00
parent 12f211d07d
commit b555c151dc
4 changed files with 92 additions and 82 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -25,6 +25,15 @@ export class ModalButton extends LitElement {
return [ModalBoxStyle, BullseyeStyle, BackdropStyle]
}
constructor() {
super();
window.addEventListener("keyup", e => {
if (e.code === "Escape") {
this.open = false;
}
});
}
setContent(content: string) {
this.querySelector("[slot=modal]")!.innerHTML = content;
// Ensure links close the modal

View File

@ -1,12 +1,12 @@
import "./legacy.js";
import "./AdminLoginsChart";
import './AdminSidebar';
import './ActionButton';
import './AdminSidebar';
import './AdminSiteShell';
import "./AdminLoginsChart";
import './Dropdown';
import './FetchFillSlot';
import './FlowShellCard';
import './Messages';
import './Tabs';
import './ModalButton';
import './AdminSiteShell';
import './Tabs';