Skip to content

Commit

Permalink
close when hitting escape
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberhorsey authored and dave | d1onys1us committed Dec 21, 2022
1 parent 533e854 commit 7ac6bba
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions packages/bridge-ui/src/components/modals/Modal.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script lang="ts">
import { onDestroy } from "svelte";
export let title: string = null;
export let isOpen: boolean = false;
export let onClose: () => void = null;
Expand All @@ -12,11 +14,15 @@
};
</script>

<div
class="modal bg-black/60"
class:modal-open={isOpen}
on:click|self={onCloseClicked}
>
<svelte:window
on:keydown={function (e) {
if (e.key === "Escape") {
onCloseClicked();
}
}}
/>

<div class="modal bg-black/60" class:modal-open={isOpen}>
<div class="modal-box bg-dark-3">
<h3 class="font-bold text-lg text-center mt-4">{title}</h3>
{#if showXButton}
Expand Down

0 comments on commit 7ac6bba

Please sign in to comment.