mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-10-08 14:51:32 +00:00
[ADF-4484] Quick notifications (#4688)
* quick notifications (info, error, warning) * update code docs
This commit is contained in:
@@ -85,4 +85,40 @@ export class NotificationService {
|
||||
dismissSnackMessageAction() {
|
||||
return this.snackBar.dismiss();
|
||||
}
|
||||
|
||||
protected showMessage(message: string, panelClass: string, action?: string): MatSnackBarRef<any> {
|
||||
message = this.translationService.instant(message);
|
||||
|
||||
return this.snackBar.open(message, action, {
|
||||
duration: this.DEFAULT_DURATION_MESSAGE,
|
||||
panelClass
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Rase error message
|
||||
* @param message Text message or translation key for the message.
|
||||
* @param action (optional) Action name
|
||||
*/
|
||||
showError(message: string, action?: string): MatSnackBarRef<any> {
|
||||
return this.showMessage(message, 'adf-error-snackbar', action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rase info message
|
||||
* @param message Text message or translation key for the message.
|
||||
* @param action (optional) Action name
|
||||
*/
|
||||
showInfo(message: string, action?: string): MatSnackBarRef<any> {
|
||||
return this.showMessage(message, 'adf-info-snackbar', action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rase warning message
|
||||
* @param message Text message or translation key for the message.
|
||||
* @param action (optional) Action name
|
||||
*/
|
||||
showWarning(message: string, action?: string): MatSnackBarRef<any> {
|
||||
return this.showMessage(message, 'adf-warning-snackbar', action);
|
||||
}
|
||||
}
|
||||
|
@@ -33,6 +33,7 @@
|
||||
@import '../login/components/login-dialog.component';
|
||||
@import '../login/components/login-dialog-panel.component';
|
||||
@import '../../core/clipboard/clipboard.component';
|
||||
@import './snackbar';
|
||||
|
||||
@mixin adf-core-theme($theme) {
|
||||
@include adf-colors-theme($theme);
|
||||
@@ -68,4 +69,5 @@
|
||||
@include adf-login-dialog-panel-theme($theme);
|
||||
@include adf-sidenav-layout-theme($theme);
|
||||
@include adf-clipboard-theme($theme);
|
||||
@include adf-snackbar-theme($theme);
|
||||
}
|
||||
|
29
lib/core/styles/snackbar.scss
Normal file
29
lib/core/styles/snackbar.scss
Normal file
@@ -0,0 +1,29 @@
|
||||
@mixin adf-snackbar-theme($theme) {
|
||||
$warn: map-get($theme, warn);
|
||||
$accent: map-get($theme, accent);
|
||||
$primary: map-get($theme, primary);
|
||||
|
||||
.adf-error-snackbar {
|
||||
background-color: mat-color($warn);
|
||||
|
||||
.mat-simple-snackbar-action {
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
|
||||
.adf-warning-snackbar {
|
||||
background-color: mat-color($accent);
|
||||
|
||||
.mat-simple-snackbar-action {
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
|
||||
.adf-info-snackbar {
|
||||
background-color: mat-color($primary);
|
||||
|
||||
.mat-simple-snackbar-action {
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user