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

Constants for Toast severities #1187

Closed
glebgolov-ziosem opened this issue Apr 16, 2021 · 1 comment
Closed

Constants for Toast severities #1187

glebgolov-ziosem opened this issue Apr 16, 2021 · 1 comment
Assignees
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Milestone

Comments

@glebgolov-ziosem
Copy link

glebgolov-ziosem commented Apr 16, 2021

As per title, just to have quick references in text editors or IDEs as there are for filter operators and match modes.

Example of the result:

/* Inside a component script */
import { useToast } from 'primevue/usetoast'
import { ToastSeverity } from 'primevue/api'

useToast().add({severity: ToastSeverity.INFO, summary: 'Message', detail: 'Message content'})

Or just Severity if those constants may be used for something else (that is already implemented or planned).

@voquanghoa
Copy link

Life hack. For me, I created a file useNotification.ts with content

import { useToast } from "primevue/usetoast";

export default function useNotification() {
    const toast = useToast();
    const showToast = (severity: string, message) => {
        toast.add({
            severity: severity,
            summary: 'Thông báo',
            detail: message,
            life: 2000
        });
    }

    return {
        showMessage: (message) => {
            showToast('success', message);
        },
        showError: (message) => {
            showToast('error', message);
        }
    }
}

And then, when I want to show a toast message

const notification = useNotification();
....

notification.showMessage('Hello world!');

It's much simpler

@cagataycivici cagataycivici changed the title [Feature request] Constants for Toast severities Constants for Toast severities May 10, 2021
@cagataycivici cagataycivici added Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add priority - low labels May 10, 2021
@cagataycivici cagataycivici self-assigned this Aug 19, 2021
@cagataycivici cagataycivici added this to the 3.7.0 milestone Aug 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Projects
None yet
Development

No branches or pull requests

4 participants