Projekt

Obecné

Profil

Stáhnout (743 Bajtů) Statistiky
| Větev: | Tag: | Revize:
1
import Swal, { SweetAlertIcon, SweetAlertPosition } from 'sweetalert2';
2
import withReactContent from 'sweetalert2-react-content';
3

    
4
const MySwal = withReactContent(Swal);
5

    
6
export function ShowToast(
7
    text: string,
8
    icon: SweetAlertIcon = 'success',
9
    timer = 3000,
10
    position: SweetAlertPosition = 'top-right'
11
) {
12
    const Toast = Swal.mixin({
13
        toast: true,
14
        position: position,
15
        showConfirmButton: false,
16
        timer: timer,
17
        timerProgressBar: true,
18
        didOpen: (toast) => {
19
            toast.addEventListener('mouseenter', Swal.stopTimer);
20
            toast.addEventListener('mouseleave', Swal.resumeTimer);
21
        },
22
    });
23

    
24
    Toast.fire({
25
        icon: icon,
26
        title: text,
27
    });
28
}
(1-1/3)