Skip to content

Commit 1e3419b

Browse files
committed
Fix review comments
1 parent ff7e021 commit 1e3419b

10 files changed

+97
-186
lines changed

src/banner/banner.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { I18nModule } from "./../i18n/i18n.module";
1010

1111
export { BannerService } from "./banner.service";
1212
export { Banner } from "./banner.component";
13-
export { Toast } from "./toast.component";
13+
// export { Toast } from "./toast.component";
1414

1515
/**
1616
* Deprecated in favour of `NotificationModule` (to be removed in v3.0).

src/banner/banner.service.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import {
1010
} from "@angular/core";
1111

1212
import { BannerContent, NotificationContent, ToastContent } from "./banner-content.interface";
13-
import { Banner, Toast } from "./banner.module";
13+
import { Banner } from "./banner.module";
14+
import { Toast } from "./toast.component";
1415

1516
/**
1617
* Deprecated in favour of `NotificationService` (to be removed in v3.0).
@@ -45,6 +46,8 @@ export class BannerService implements OnDestroy {
4546
private injector: Injector,
4647
private componentFactoryResolver: ComponentFactoryResolver,
4748
private applicationRef: ApplicationRef) {
49+
50+
console.warn("`BannerService` has been deprecated in favour of `NotificationService`");
4851
}
4952

5053
/**

src/banner/banner.stories.ts

Lines changed: 0 additions & 107 deletions
This file was deleted.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export interface InlineNotificationContent {
1+
export interface NotificationContent {
22
type: string;
33
title: string;
44
target?: string;
@@ -8,7 +8,7 @@ export interface InlineNotificationContent {
88
message: string;
99
}
1010

11-
export interface ToastNotificationContent extends InlineNotificationContent {
11+
export interface ToastContent extends NotificationContent {
1212
subtitle: string;
1313
caption: string;
1414
}

src/notification/notification.component.spec.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import { TestBed } from "@angular/core/testing";
22

33
import { StaticIconModule } from "./../icon/static-icon.module";
44

5-
import { InlineNotification, NotificationService } from "./notification.module";
5+
import { Notification, NotificationService } from "./notification.module";
66
import { I18nModule } from "../i18n/i18n.module";
77

88

99
describe("Notification", () => {
1010
beforeEach(() => {
1111
TestBed.configureTestingModule({
12-
declarations: [InlineNotification],
12+
declarations: [Notification],
1313
providers: [NotificationService],
1414
imports: [
1515
StaticIconModule,
@@ -19,12 +19,12 @@ describe("Notification", () => {
1919
});
2020

2121
it("should work", () => {
22-
const fixture = TestBed.createComponent(InlineNotification);
23-
expect(fixture.componentInstance instanceof InlineNotification).toBe(true);
22+
const fixture = TestBed.createComponent(Notification);
23+
expect(fixture.componentInstance instanceof Notification).toBe(true);
2424
});
2525

2626
it("should render info notification", () => {
27-
const fixture = TestBed.createComponent(InlineNotification);
27+
const fixture = TestBed.createComponent(Notification);
2828
fixture.componentInstance.notificationObj = {
2929
type: "info",
3030
title: "sample",
@@ -37,7 +37,7 @@ describe("Notification", () => {
3737
});
3838

3939
it("should render danger notification", () => {
40-
const fixture = TestBed.createComponent(InlineNotification);
40+
const fixture = TestBed.createComponent(Notification);
4141
fixture.componentInstance.notificationObj = {
4242
type: "danger",
4343
title: "sample",
@@ -50,7 +50,7 @@ describe("Notification", () => {
5050
});
5151

5252
it("should render info warning", () => {
53-
const fixture = TestBed.createComponent(InlineNotification);
53+
const fixture = TestBed.createComponent(Notification);
5454
fixture.componentInstance.notificationObj = {
5555
type: "warning",
5656
title: "sample",
@@ -63,7 +63,7 @@ describe("Notification", () => {
6363
});
6464

6565
it("should render info success", () => {
66-
const fixture = TestBed.createComponent(InlineNotification);
66+
const fixture = TestBed.createComponent(Notification);
6767
fixture.componentInstance.notificationObj = {
6868
type: "success",
6969
title: "sample",
@@ -76,7 +76,7 @@ describe("Notification", () => {
7676
});
7777

7878
it("should display correct message", () => {
79-
const fixture = TestBed.createComponent(InlineNotification);
79+
const fixture = TestBed.createComponent(Notification);
8080
fixture.componentInstance.notificationObj = {
8181
type: "success",
8282
title: "sample",
@@ -90,7 +90,7 @@ describe("Notification", () => {
9090
});
9191

9292
it("should emit change when close button is clicked", () => {
93-
const fixture = TestBed.createComponent(InlineNotification);
93+
const fixture = TestBed.createComponent(Notification);
9494
fixture.componentInstance.notificationObj = {
9595
type: "success",
9696
title: "sample",
@@ -107,7 +107,7 @@ describe("Notification", () => {
107107
});
108108

109109
it("should emit change when notification is closed programmatically", () => {
110-
const fixture = TestBed.createComponent(InlineNotification);
110+
const fixture = TestBed.createComponent(Notification);
111111
fixture.componentInstance.notificationObj = {
112112
type: "info",
113113
title: "sample",

src/notification/inline-notification.component.ts renamed to src/notification/notification.component.ts

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,23 @@ import {
55
EventEmitter,
66
ComponentRef,
77
ViewChild,
8-
OnInit
8+
OnInit,
9+
HostBinding
910
} from "@angular/core";
1011

1112
import { NotificationService } from "./notification.service";
12-
import { InlineNotificationContent } from "./notification-content.interface";
13+
import { NotificationContent } from "./notification-content.interface";
1314
import { I18n } from "./../i18n/i18n.module";
1415

1516
/**
16-
* InlineNotification messages are displayed toward the top of the UI and do not interrupt user’s work.
17+
* Notification messages are displayed toward the top of the UI and do not interrupt user’s work.
1718
*
1819
* @export
19-
* @class InlineNotification
20+
* @class Notification
2021
*/
2122
@Component({
22-
selector: "ibm-inline-notification",
23+
selector: "ibm-notification",
2324
template: `
24-
<div
25-
#notification
26-
class="bx--inline-notification bx--inline-notification--{{notificationObj.type}}"
27-
role="alert">
2825
<div class="bx--inline-notification__details">
2926
<svg class="bx--inline-notification__icon" width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
3027
<path d="M8 16A8 8 0 1 1 8 0a8 8 0 0 1 0 16zM3.293 4.707l8 8 1.414-1.414-8-8-1.414 1.414z" fill-rule="evenodd"/>
@@ -48,11 +45,11 @@ import { I18n } from "./../i18n/i18n.module";
4845
<path d="M6.32 5L10 8.68 8.68 10 5 6.32 1.32 10 0 8.68 3.68 5 0 1.32 1.32 0 5 3.68 8.68 0 10 1.32 6.32 5z" fill-rule="nonzero"/>
4946
</svg>
5047
</button>
51-
</div>
48+
5249
`,
5350
providers: [NotificationService]
5451
})
55-
export class InlineNotification implements OnInit {
52+
export class Notification implements OnInit {
5653
/**
5754
* Can have `type`, `title`, and `message` members.
5855
*
@@ -61,20 +58,29 @@ export class InlineNotification implements OnInit {
6158
* `message` is message for notification to display
6259
*
6360
*/
64-
@Input() notificationObj: InlineNotificationContent;
61+
@Input() notificationObj: NotificationContent;
6562

6663
/**
6764
* Emits on close.
6865
*
6966
* @type {EventEmitter<any>}
70-
* @memberof InlineNotification
67+
* @memberof Notification
7168
*/
7269
@Output() close: EventEmitter<any> = new EventEmitter();
7370

74-
componentRef: ComponentRef<InlineNotification>;
71+
componentRef: ComponentRef<Notification>;
7572

7673
@ViewChild("notification") notification;
7774

75+
@HostBinding("attr.id") notificationID = "notification";
76+
@HostBinding("class.bx--inline-notification") notificationClass = true;
77+
@HostBinding("attr.role") role = "alert";
78+
79+
@HostBinding("class.bx--inline-notification--error") get isError() { return this.notificationObj.type === "error"; }
80+
@HostBinding("class.bx--inline-notification--info") get isInfo() { return this.notificationObj.type === "info"; }
81+
@HostBinding("class.bx--inline-notification--success") get isSuccess() { return this.notificationObj.type === "success"; }
82+
@HostBinding("class.bx--inline-notification--warning") get isWarning() { return this.notificationObj.type === "warning"; }
83+
7884
constructor(protected notificationService: NotificationService, protected i18n: I18n) {}
7985

8086
ngOnInit() {
@@ -86,7 +92,7 @@ export class InlineNotification implements OnInit {
8692
/**
8793
* Emits close event.
8894
*
89-
* @memberof InlineNotification
95+
* @memberof Notification
9096
*/
9197
onClose() {
9298
this.close.emit();

src/notification/notification.module.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@ import { CommonModule } from "@angular/common";
33

44
import { StaticIconModule } from "./../icon/static-icon.module";
55

6-
import { ToastNotification } from "./toast-notification.component";
7-
import { InlineNotification } from "./inline-notification.component";
6+
import { Toast } from "./toast.component";
7+
import { Notification } from "./notification.component";
88
import { NotificationService } from "./notification.service";
99
import { I18nModule } from "./../i18n/i18n.module";
1010

1111
export { NotificationService } from "./notification.service";
12-
export { InlineNotification } from "./inline-notification.component";
13-
export { ToastNotification } from "./toast-notification.component";
12+
export { Notification } from "./notification.component";
13+
export { Toast } from "./toast.component";
1414

1515
@NgModule({
1616
declarations: [
17-
InlineNotification,
18-
ToastNotification
17+
Notification,
18+
Toast
1919
],
2020
exports: [
21-
InlineNotification,
22-
ToastNotification
21+
Notification,
22+
Toast
2323
],
24-
entryComponents: [InlineNotification, ToastNotification],
24+
entryComponents: [Notification, Toast],
2525
imports: [CommonModule, StaticIconModule, I18nModule],
2626
providers: [NotificationService]
2727
})

0 commit comments

Comments
 (0)