Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sweetify customClass #35

Open
residentcode opened this issue Feb 10, 2023 · 1 comment
Open

Sweetify customClass #35

residentcode opened this issue Feb 10, 2023 · 1 comment

Comments

@residentcode
Copy link

residentcode commented Feb 10, 2023

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
Copy link
Author

residentcode commented Feb 17, 2023

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant