mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[HXCS-1166] extend SnackBar to customize content appearance (#8379)
* [HXCS-1166] add templateRef to SnackBarData interface * [HXCS-1166] update SnackBarContentComponent to be able to manage data.templateRef * [HXCS-1166] add tests to NotificationService * [HXCS-1166] fix lint * [HXCS-1166] add documentation * [HXCS-1166] follow PR advices * [HXCS-1166] typos * [HXCS-1166] update testrail id --------- Co-authored-by: Adriano Costa <Adriano.Costa@hyland.comgit>
This commit is contained in:
@@ -120,6 +120,32 @@ export class MyComponent implements OnInit {
|
||||
}
|
||||
```
|
||||
|
||||
By providing a `decorativeIcon` property in the `SnackBarData`, it is possible to render a decorative
|
||||
[`MaterialIcon`](https://material.angular.io/components/icon/overview#interactive-icons) to the left of the message.
|
||||
|
||||
```ts
|
||||
import { NotificationService } from '@alfresco/adf-core';
|
||||
import { MatSnackBarConfig } from '@angular/material/snackbar';
|
||||
|
||||
export class MyComponent implements OnInit {
|
||||
|
||||
snackBarConfig: MatSnackBarConfig = new MatSnackBarConfig();
|
||||
|
||||
constructor(private notificationService: NotificationService) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.snackBarConfig.data = { decorativeIcon: 'folder' };
|
||||
this.notificationService
|
||||
.openSnackMessageAction('Do you want to report this issue?', 'send', snackBarConfig)
|
||||
.afterDismissed()
|
||||
.subscribe(() => {
|
||||
console.log('The snack-bar was dismissed');
|
||||
});
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The default message duration is 5000 ms that is used only if you don't pass a custom duration in the parameters of openSnackMessageAction/openSnackMessage methods.
|
||||
You can also change the default 5000 ms adding the following configuration in the app.config.json:
|
||||
|
||||
|
Reference in New Issue
Block a user