Skip to content

Commit 9510e51

Browse files
authored
Merge branch 'master' into master
2 parents ce76833 + 763dd52 commit 9510e51

16 files changed

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

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)