mirror of
https://github.com/garraflavatra/rolens.git
synced 2024-12-01 13:20:54 +00:00
Modal hierarchy
This commit is contained in:
parent
9cecad0c3a
commit
44d4fb843d
@ -1,3 +1,7 @@
|
||||
<script context="module">
|
||||
let numberOfModalsOpen = 0;
|
||||
</script>
|
||||
|
||||
<script>
|
||||
import { fade, fly } from 'svelte/transition';
|
||||
import Icon from './icon.svelte';
|
||||
@ -7,14 +11,27 @@
|
||||
export let contentPadding = true;
|
||||
export let width = '80vw';
|
||||
|
||||
const level = numberOfModalsOpen + 1;
|
||||
let isNew = true;
|
||||
|
||||
$: if (show) {
|
||||
numberOfModalsOpen++;
|
||||
}
|
||||
else if (!isNew) {
|
||||
numberOfModalsOpen--;
|
||||
}
|
||||
else {
|
||||
isNew = false;
|
||||
}
|
||||
|
||||
function keydown(event) {
|
||||
if (event.key === 'Escape') {
|
||||
if ((event.key === 'Escape') && (level === numberOfModalsOpen)) {
|
||||
show = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window on:keydown={keydown} />
|
||||
<svelte:window on:keydown|preventDefault={keydown} />
|
||||
|
||||
{#if show}
|
||||
<div class="modal outer" on:mousedown|self={() => show = false} transition:fade>
|
||||
|
Loading…
Reference in New Issue
Block a user