Skip to content

Commit

Permalink
Fixed #1874 - Constants for Toast
Browse files Browse the repository at this point in the history
  • Loading branch information
tugcekucukoglu committed Dec 10, 2021
1 parent e002af4 commit 12a4e22
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/components/api/Api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,10 @@ export const PrimeIcons: {
WINDOW_MINIMIZE?: string,
YOUTUBE?: string
}

export const ToastSeverity: {
INFO?: string,
WARN?: string,
ERROR?: string,
SUCCESS?: string
}
3 changes: 2 additions & 1 deletion src/components/api/Api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ import FilterMatchMode from './FilterMatchMode';
import FilterOperator from './FilterOperator';
import FilterService from './FilterService';
import PrimeIcons from './PrimeIcons';
import ToastSeverity from './ToastSeverity';

export {FilterMatchMode,FilterOperator,FilterService,PrimeIcons};
export {FilterMatchMode,FilterOperator,FilterService,PrimeIcons,ToastSeverity};
8 changes: 8 additions & 0 deletions src/components/api/ToastSeverity.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const ToastSeverities = {
INFO: 'info',
WARN: 'warn',
ERROR: 'error',
SUCCESS: 'success'
};

export default ToastSeverities;
14 changes: 14 additions & 0 deletions src/views/toast/ToastDoc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,20 @@ this.$toast.removeAllGroups();
<p>Toast styling can be adjusted per screen size with the <i>breakpoints</i> option. The value of <i>breakpoints</i> should be an object literal whose keys are the maximum screen sizes and values are the styles per screen. In example below, width of the toast messages cover the whole page on screens whose widths is smaller than 921px.</p>
<CodeHighlight>
&lt;Toast :breakpoints="&#123;'920px': &#123;width: '100%', right: '0', left: '0'&#125;&#125;"&gt;&lt;/Toast&gt;
</CodeHighlight>

<h5>Constants</h5>
<p>ToastSeverity constants API is provided to easily choose a severity of the message with typescript.</p>
<CodeHighlight lang="javascript">
import {ToastSeverity} from 'primevue/api';

export default {
methods: {
showInfo() {
this.$toast.add({severity: ToastSeverity.INFO, summary: 'Info Message', detail:'Message Content', life: 3000});
}
}
}
</CodeHighlight>

<h5>Properties</h5>
Expand Down

0 comments on commit 12a4e22

Please sign in to comment.