quick export with snackbar info, allows canceling process

This commit is contained in:
Jan Prochazka
2021-06-06 13:13:38 +02:00
parent 4d529e7e3f
commit 26ff3f45f8
6 changed files with 107 additions and 62 deletions

View File

@@ -1,63 +1,8 @@
<script lang="ts" context="module">
import { openedSnackbars } from '../stores';
export interface SnackbarButton {
label: string;
onClick: Function;
}
export interface SnackbarInfo {
message: string;
icon?: string;
autoClose?: boolean;
allowClose?: boolean;
buttons?: SnackbarButton[];
}
let lastSnackbarId = 0;
export function showSnackbar(snackbar: SnackbarInfo) {
lastSnackbarId += 1;
openedSnackbars.update(x => [
...x,
{
...snackbar,
id: lastSnackbarId,
},
]);
}
export function showSnackbarSuccess(message: string) {
showSnackbar({
message,
icon: 'img ok',
allowClose: true,
autoClose: true,
});
}
// showSnackbar({
// icon: 'img ok',
// message: 'Test snackbar',
// allowClose: true,
// });
// showSnackbar({
// icon: 'img ok',
// message: 'Auto close',
// autoClose: true,
// });
// showSnackbar({
// icon: 'img warn',
// message: 'Buttons',
// buttons: [{ label: 'OK', onClick: () => console.log('OK') }],
// });
</script>
<script lang="ts">
import FontIcon from '../icons/FontIcon.svelte';
import { onMount } from 'svelte';
import FormStyledButton from '../elements/FormStyledButton.svelte';
import { openedSnackbars } from '../stores';
export let message;
export let id;