sweetify-django icon indicating copy to clipboard operation
sweetify-django copied to clipboard

Sweetify customClass

Open residentcode opened this issue 2 years ago • 1 comments

Hi,

Is there a way to add one time option for customClass{} ? better not repeating this for every single message. Thanks in advance.

sweetify.error(
            request, title='Error.', text='Text',
            persistent="Close", customClass={
                'icon': 'dark:color-pink-600',
                'popup': 'dark:bg-slate-900 dark:text-slate-200',

            })

residentcode avatar Feb 10 '23 19:02 residentcode

I did it like this, if there is a better way plz share.

def sweeify_alert(request, tag, title, text, **kwargs):
    sweetify_functions = {
        'success': sweetify.success,
        'warning': sweetify.warning,
        'error': sweetify.error,
        'toast': sweetify.toast,
        'info': sweetify.info
    }
    kwargs['text'] = text
    kwargs['title'] = title
    kwargs['showConfirmButton'] = True
    kwargs['timerProgressBar'] = False
    kwargs['allowOutsideClick'] = True
    kwargs['width'] = 500
    kwargs['padding'] = '3em'
    kwargs['timer'] = None
    kwargs['backdrop'] = True

    sweetify_func = sweetify_functions.get(tag, sweetify.info)

    if tag == 'success' or tag == 'toast':
        kwargs['timer'] = 4000
        kwargs['showConfirmButton'] = False

    return sweetify_func(request, customClass={
        'icon': 'mt-0',
        'popup': 'dark:bg-slate-900 dark:text-slate-200 px-2 py-12',
        'confirmButton': 'px-12',
    }, **kwargs)

residentcode avatar Feb 17 '23 12:02 residentcode