-
Notifications
You must be signed in to change notification settings - Fork 474
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(notification-alert): allow configuration of default options
- Loading branch information
Dima Karimov
committed
Aug 21, 2021
1 parent
b5af611
commit c28f3fe
Showing
8 changed files
with
210 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
projects/core/modules/notifications/notification-alert/notification-alert-options.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {InjectionToken} from '@angular/core'; | ||
import {TuiContextWithImplicit} from '@taiga-ui/cdk'; | ||
import {PolymorpheusContent} from '@tinkoff/ng-polymorpheus'; | ||
import {TuiNotification} from '../../../enums/notification'; | ||
|
||
export interface NotificationAlertOptions { | ||
readonly autoClose: boolean | number; | ||
readonly label: PolymorpheusContent<TuiContextWithImplicit<TuiNotification>>; | ||
} | ||
|
||
/** Default values for the toggle options. */ | ||
export const TUI_NOTIFICATION_ALERT_DEFAULT_OPTIONS: NotificationAlertOptions = { | ||
autoClose: 3000, | ||
label: '', | ||
}; | ||
|
||
export const TUI_NOTIFICATION_ALERT_OPTIONS = new InjectionToken<NotificationAlertOptions>( | ||
'Default parameters for notification alert component', | ||
{ | ||
factory: () => TUI_NOTIFICATION_ALERT_DEFAULT_OPTIONS, | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
projects/demo/src/modules/services/notifications/examples/import/define-options.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { | ||
TuiNotification, | ||
TUI_NOTIFICATION_ALERT_DEFAULT_OPTIONS, | ||
TUI_NOTIFICATION_ALERT_OPTIONS, | ||
} from '@taiga-ui/core'; | ||
|
||
... | ||
|
||
@NgModule({ | ||
providers: [{ | ||
provide: TUI_NOTIFICATION_ALERT_OPTIONS, | ||
useValue: { | ||
...TUI_NOTIFICATION_ALERT_DEFAULT_OPTIONS, | ||
autocloseTimeout: 7000, | ||
label: ({$implicit}: any) => ($implicit === TuiNotification.Error ? 'Error' : 'Info') | ||
}, | ||
}], | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters