A centralized API for dispatching notifications through Snackbars and Banners.
Triggers a Snackbar that is displayed to the user.
Snackbars inform users of a process that Workfront has performed or will perform. They appear temporarily, should not interrupt the user experience, and don't require user input to disappear.
function triggerSnackbar({
message: string,
action?: Function,
actionText?: string
timeout?: number
}) : Function
- Only one snackbar will be displayed at a time
- Additional snackbars will be queued and displayed after the previous has cleared
- Snackbars don't need any buttons but can contain a single action
- The timeout for the snackbar is calculated as .1 second per character of the message and action text, with a minimum of 4 seconds and a maximum of 10 seconds
- The timeout stops when the user hovers over the snackbar area
- The timeout restarts from zero when the user hovers away from the snackbar
- The Snackbar is removed immediately once the action has been triggered
import { triggerSnackbar } from '@company/notification-service'
export function MyComponent() {
const executeSomeAction = () => {
doTheThing.then((result) => {
triggerSnackbar({
message: 'The thing was done'
})
})
}
return (/* ... */)
}