Skip to content

Commit defb61a

Browse files
committed
2 parents 8753483 + 03c1ec0 commit defb61a

16 files changed

+2426
-1824
lines changed

package-lock.json

Lines changed: 2135 additions & 1796 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@
120120
"karma-sourcemap-loader": "0.3.7",
121121
"karma-spec-reporter": "0.0.32",
122122
"karma-webpack": "3.0.0",
123-
"marked": "0.3.7",
124123
"node-sass": "4.9.0",
125124
"postcss-loader": "2.1.4",
126125
"raw-loader": "0.5.1",

src/button/button.directive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class Button implements OnInit {
3030
*/
3131
@Input() size: "normal" | "sm" = "normal";
3232
// a whole lot of HostBindings ... this way we don't have to touch the elementRef directly
33-
@HostBinding("class") btnClass = "bx--btn";
33+
@HostBinding("class.bx--btn") baseClass = true;
3434
@HostBinding("class.bx--btn--primary") primary = true;
3535
@HostBinding("class.bx--btn--secondary") secondary = false;
3636
@HostBinding("class.bx--btn--tertiary") tertiary = false;

src/calendar/month-view/calendar-month.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
22
Component,
33
Input,
4-
OnInit,
4+
OnInit
55
} from "@angular/core";
66
import { DateTimeModel } from "./../date-time-model.class";
77
import { range } from "../../common/utils";

src/calendar/months-view/calendar-months.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
22
Component,
33
Input,
4-
OnInit,
4+
OnInit
55
} from "@angular/core";
66
import { DateTimeModel } from "./../date-time-model.class";
77
import { range } from "../../common/utils";

src/calendar/quarter-view/calendar-quarter.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { TranslateService } from "@ngx-translate/core";
22
import {
33
Component,
44
Input,
5-
OnInit,
5+
OnInit
66
} from "@angular/core";
77
import { DateTimeModel } from "./../date-time-model.class";
88
import { range } from "../../common/utils";

src/calendar/year-view/calendar-year.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
22
Component,
33
Input,
4-
OnInit,
4+
OnInit
55
} from "@angular/core";
66
import { DateTimeModel } from "./../date-time-model.class";
77
import { range } from "../../common/utils";

src/dialog/tooltip/tooltip.stories.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ storiesOf("Tooltip", module)
1313
imports: [
1414
DialogModule,
1515
TranslateModule.forRoot()
16-
],
16+
]
1717
})
1818
)
1919
.addDecorator(withKnobs)

src/modal/alert-modal.component.ts

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
import {
2+
Component,
3+
Injector,
4+
ElementRef,
5+
Inject
6+
} from "@angular/core";
7+
import {
8+
trigger,
9+
state,
10+
style,
11+
transition,
12+
animate
13+
} from "@angular/animations";
14+
import Modal from "./modal.decorator";
15+
16+
/**
17+
* Component to create standard modals for presenting content or asking for user's input.
18+
* It can show as a passive modal showing only text or show as a transactional modal with
19+
* multiple buttons for different actions for the user to choose from.
20+
*
21+
* Using a modal in your application requires `ibm-modal-placeholder` which would generally be
22+
* placed near the end of your app component template (app.component.ts or app.component.html) as:
23+
*
24+
* ```html
25+
* <ibm-modal-placeholder></ibm-modal-placeholder>
26+
* ```
27+
*
28+
* Example of opening the modal:
29+
*
30+
* ```typescript
31+
* \@Component({
32+
* selector: "app-modal-demo",
33+
* template: `
34+
* <button class="btn--primary" (click)="openModal()">Open modal</button>
35+
* <ibm-modal-placeholder></ibm-modal-placeholder>`
36+
* })
37+
* export class ModalDemo {
38+
* openModal() {
39+
* this.modalService.show({
40+
* modalType: "default",
41+
* modalLabel: "optional header text",
42+
* modalTitle: "Modal modalTitle",
43+
* text: "Modal text",
44+
* buttons: [{
45+
* text: "Button text",
46+
* type: "primary",
47+
* click: clickFunction
48+
* }]
49+
* });
50+
* }
51+
* }
52+
* ```
53+
*
54+
* @export
55+
* @class AlertModalComponent
56+
*/
57+
@Modal()
58+
@Component({
59+
selector: "ibm-alert-modal",
60+
template: `
61+
<ibm-modal [modalType]="modalType">
62+
<ibm-modal-header (closeSelect)="closeModal()">
63+
<p class="bx--modal-header__label bx--type-delta">{{modalLabel}}</p>
64+
<p class="bx--modal-header__heading bx--type-beta">{{modalTitle}}</p>
65+
</ibm-modal-header>
66+
<div class="bx--modal-content">
67+
<p>{{modalContent}}</p>
68+
</div>
69+
<ibm-modal-footer *ngIf="buttons.length > 0">
70+
<ng-container *ngFor="let button of buttons; let i = index">
71+
<button
72+
ibmButton="{{button.type}}"
73+
(click)="buttonClicked(i)"
74+
[id]="button.id"
75+
[attr.modal-primary-focus]="(button.type.indexOf('primary') !== -1 ? '' : null)">
76+
{{button.text}}
77+
</button>
78+
</ng-container>
79+
</ibm-modal-footer>
80+
</ibm-modal>
81+
`
82+
})
83+
export class AlertModalComponent {
84+
/**
85+
* Creates an instance of `AlertModalComponent`.
86+
* @param {ModalService} modalService
87+
* @memberof AlertModalComponent
88+
*/
89+
constructor(
90+
@Inject("modalType") public modalType = "default",
91+
@Inject("modalLabel") public modalLabel: string,
92+
@Inject("modalTitle") public modalTitle: string,
93+
@Inject("modalContent") public modalContent: string,
94+
@Inject("buttons") public buttons = []
95+
) {
96+
for (let i = 0; i < this.buttons.length; i++) {
97+
const button = this.buttons[i];
98+
if (!button.id) {
99+
button.id = `alert-modal-button-${i}`;
100+
}
101+
if (!button.type) {
102+
button.type = "secondary";
103+
}
104+
}
105+
}
106+
107+
buttonClicked(buttonIndex) {
108+
const button = this.buttons[buttonIndex];
109+
if (button.click) {
110+
button.click();
111+
}
112+
113+
this.closeModal();
114+
}
115+
116+
closeModal() {
117+
// let call the @Modal.destroy() explicitly or otherwise the modal won't close
118+
this["destroy"]();
119+
}
120+
}

src/modal/modal-header.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ import { Component, Output, EventEmitter, Input } from "@angular/core";
1919
selector: "ibm-modal-header",
2020
template: `
2121
<header class="{{modalType}} bx--modal-header" role="banner">
22-
<h5 class="bx--modal-header__heading">
22+
<div class="bx--modal-header">
2323
<ng-content></ng-content>
24-
</h5>
24+
</div>
2525
<button
2626
class="bx--modal-close"
2727
attr.aria-label="{{'MODAL.CLOSE' | translate}}"
@@ -35,7 +35,7 @@ import { Component, Output, EventEmitter, Input } from "@angular/core";
3535
width="10"
3636
aria-label="close the modal"
3737
alt="close the modal">
38-
<title>close the modal</title>
38+
<title>{{'MODAL.CLOSE' | translate}}</title>
3939
<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"></path>
4040
</svg>
4141
</button>

0 commit comments

Comments
 (0)