auto close snackbar

This commit is contained in:
SPRINX0\prochazka 2024-09-09 15:51:41 +02:00
parent 703a4bdb57
commit 1fcaf08644
3 changed files with 12 additions and 3 deletions

View File

@ -18,6 +18,7 @@ export function initializeAppUpdates() {
onClick: () => {
electron.send('downloadUpdate');
},
autoClose: true,
},
],
});
@ -37,6 +38,7 @@ export function initializeAppUpdates() {
onClick: () => {
electron.send('applyUpdate');
},
autoClose: true,
},
],
});

View File

@ -3,6 +3,7 @@ import { openedSnackbars } from '../stores';
export interface SnackbarButton {
label: string;
onClick: Function;
autoClose?: boolean;
}
export interface SnackbarInfo {

View File

@ -18,7 +18,6 @@
onMount(() => {
if (autoClose) setTimeout(handleClose, 3000);
});
</script>
<div class="wrapper">
@ -37,7 +36,15 @@
<div class="buttons">
{#each buttons as button}
<div class="button">
<FormStyledButton value={button.label} on:click={button.onClick} />
<FormStyledButton
value={button.label}
on:click={() => {
if (button.autoClose) {
handleClose();
}
button.onClick?.();
}}
/>
</div>
{/each}
</div>
@ -76,5 +83,4 @@
.button {
margin: 5px;
}
</style>