Skip to content

Commit f6d2077

Browse files
cal-smithGitHub Enterprise
authored andcommitted
Merge pull request #10 from callums/master
Refactor banner.component to carbon styles
2 parents 190b57c + 9365d14 commit f6d2077

File tree

2 files changed

+112
-11
lines changed

2 files changed

+112
-11
lines changed

src/banner/banner.component.ts

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,36 @@ import { BannerService } from "./banner.service";
1818
@Component({
1919
selector: "ibm-banner",
2020
template: `
21-
<div class="banner--{{bannerObj.type}}" *ngIf="bannerObj" role="alert" #banner>
22-
<span class="icon" aria-hidden="true">
23-
<ibm-static-icon icon="info_fill" *ngIf="bannerObj.type === 'info'"></ibm-static-icon>
24-
<ibm-static-icon icon="warning_fill" *ngIf="bannerObj.type === 'warning'"></ibm-static-icon>
25-
<ibm-static-icon icon="failure_fill" *ngIf="bannerObj.type === 'danger'"></ibm-static-icon>
26-
<ibm-static-icon icon="success_fill" *ngIf="bannerObj.type === 'success'"></ibm-static-icon>
27-
</span>
28-
<p [innerHTML]="bannerObj.message"></p>
29-
<button type="button" class="close--dark-sm" (click)="onClose()" attr.aria-label="{{'BANNER.CLOSE_BUTTON' | translate}}">
30-
<ibm-static-icon icon="x" size="sm" classList="close_icon"></ibm-static-icon>
21+
<div
22+
#banner
23+
class="bx--inline-notification bx--inline-notification--{{bannerObj.type}}"
24+
role="alert">
25+
<div class="bx--inline-notification__details">
26+
<svg class="bx--inline-notification__icon" width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
27+
<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"/>
28+
</svg>
29+
<div class="bx--inline-notification__text-wrapper">
30+
<p [innerHTML]="bannerObj.title" class="bx--inline-notification__title"></p>
31+
<p [innerHTML]="bannerObj.message" class="bx--inline-notification__subtitle"></p>
32+
</div>
33+
</div>
34+
<button
35+
(click)="onClose()"
36+
class="bx--inline-notification__close-button"
37+
type="button">
38+
<svg
39+
class="bx--inline-notification__close-icon"
40+
aria-label="close"
41+
width="10"
42+
height="10"
43+
viewBox="0 0 10 10"
44+
xmlns="http://www.w3.org/2000/svg">
45+
<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"/>
46+
</svg>
3147
</button>
3248
</div>
33-
`
49+
`,
50+
providers: [BannerService]
3451
})
3552
export class Banner {
3653
/**

src/banner/banner.stories.ts

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import { storiesOf, moduleMetadata } from "@storybook/angular";
2+
import { withNotes } from "@storybook/addon-notes";
3+
import { action } from "@storybook/addon-actions";
4+
import { withKnobs, boolean, object } from "@storybook/addon-knobs/angular";
5+
6+
import { Component } from "@angular/core";
7+
8+
import { TranslateModule } from "@ngx-translate/core";
9+
10+
import { BannerModule, BannerService } from "../";
11+
12+
13+
@Component({
14+
selector: "app-banner-story",
15+
template: `
16+
<button class="bx--btn bx--btn--primary" (click)="showBanner()">Show info banner</button>
17+
<div class="banner-container"></div>
18+
`,
19+
providers: [BannerService]
20+
})
21+
class BannnerStory {
22+
23+
constructor(private bannerService: BannerService) { }
24+
25+
showBanner() {
26+
this.bannerService.showBanner({
27+
type: "info",
28+
title: "Sample banner",
29+
message: "Sample info message",
30+
target: ".banner-container"
31+
});
32+
}
33+
}
34+
35+
storiesOf("Banner", module)
36+
.addDecorator(
37+
moduleMetadata({
38+
declarations: [
39+
BannnerStory
40+
],
41+
imports: [
42+
BannerModule,
43+
TranslateModule.forRoot()
44+
]
45+
})
46+
)
47+
.addDecorator(withKnobs)
48+
.add("Basic", () => ({
49+
template: `
50+
<ibm-banner [bannerObj]="{type: 'error', title: 'Sample banner', message: 'Sample error message'}"></ibm-banner>
51+
<ibm-banner [bannerObj]="{type: 'info', title: 'Sample banner', message: 'Sample info message'}"></ibm-banner>
52+
<ibm-banner [bannerObj]="{type: 'success', title: 'Sample banner', message: 'Sample success message'}"></ibm-banner>
53+
<ibm-banner [bannerObj]="{type: 'warning', title: 'Sample banner', message: 'Sample warning message'}"></ibm-banner>
54+
`
55+
}))
56+
.add("Dynamic", () => ({
57+
template: `
58+
<app-banner-story></app-banner-story>
59+
`
60+
}))
61+
.add("Toast", () => ({
62+
template: `
63+
<h4>Coming soon</h4>
64+
<em>Teaser ...</em>
65+
<div class="bx--toast-notification bx--toast-notification--info" role="alert">
66+
<div class="bx--toast-notification__details">
67+
<h3 class="bx--toast-notification__title">Notification title</h3>
68+
<p class="bx--toast-notification__subtitle">Subtitle text goes here.</p>
69+
<p class="bx--toast-notification__caption">Time stamp [00:00:00]</p>
70+
</div>
71+
<button class="bx--toast-notification__close-button" type="button">
72+
<svg
73+
class="bx--toast-notification-icon"
74+
aria-label="close"
75+
width="10"
76+
height="10"
77+
viewBox="0 0 10 10"
78+
xmlns="http://www.w3.org/2000/svg">
79+
<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"/>
80+
</svg>
81+
</button>
82+
</div>
83+
`
84+
}));

0 commit comments

Comments
 (0)