mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 21:16:00 +00:00
quick export with snackbar info, allows canceling process
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user