Skip to content

Commit

Permalink
Add modal transitions
Browse files Browse the repository at this point in the history
  • Loading branch information
garraflavatra committed Dec 23, 2023
1 parent 4e68bf3 commit b04d0b3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
8 changes: 5 additions & 3 deletions frontend/src/components/modal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
</script>

<script>
import { Beep } from '$wails/go/ui/UI.js';
import { createEventDispatcher } from 'svelte';
import { fade, fly } from 'svelte/transition';
import { Beep } from '$wails/go/ui/UI.js';
import Icon from './icon.svelte';
export let show = true;
Expand Down Expand Up @@ -35,15 +36,16 @@
}
function close() {
show = false;
dispatch('close');
}
</script>

<svelte:window on:keydown={keydown} />

{#if show}
<div class="modal outer" on:pointerdown|self={Beep}>
<div class="inner" style:max-width={width || '80vw'}>
<div class="modal outer" on:pointerdown|self={Beep} transition:fade={{ duration: 200 }}>
<div class="inner" style:max-width={width || '80vw'} transition:fly={{ y: 20, duration: 200 }}>
{#if title}
<header>
<div class="title">{title}</div>
Expand Down
12 changes: 9 additions & 3 deletions frontend/src/lib/dialogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ function newDialog(dialogComponent, data = {}) {
outlet.className = 'dialogoutlet';
document.getElementById('dialogoutlets').appendChild(outlet);

const instance = new dialogComponent({ target: outlet, props: data });
const instance = new dialogComponent({
target: outlet,
intro: true,
props: data,
});

instance.$close = function() {
instance.$destroy();
outlet.remove();
setTimeout(() => {
instance.$destroy();
outlet.remove();
}, 200);
};

instance.$on('close', instance.$close);
Expand Down

0 comments on commit b04d0b3

Please sign in to comment.