Skip to content

Commit ef77164

Browse files
committed
modal update
1 parent 4eb0670 commit ef77164

File tree

6 files changed

+111
-211
lines changed

6 files changed

+111
-211
lines changed

src/modal/README.md

Lines changed: 0 additions & 188 deletions
This file was deleted.

src/modal/modal-footer.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ import { Component } from "@angular/core";
88
@Component({
99
selector: "ibm-modal-footer",
1010
template: `
11-
<footer role="contentinfo" class="modal_footer--border">
11+
<footer role="contentinfo" class="bx--modal-footer">
1212
<ng-content></ng-content>
1313
</footer>
14-
`
14+
`,
15+
styleUrls: ["./../../node_modules/carbon-components/scss/components/modal/_modal.scss"]
1516
})
1617
export class ModalFooterComponent {}

src/modal/modal-header.component.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,31 @@ import { Component, Output, EventEmitter, Input } from "@angular/core";
1818
@Component({
1919
selector: "ibm-modal-header",
2020
template: `
21-
<header class="{{modalType}} modal_header" role="banner">
22-
<h5 class="header_title">
21+
<header class="{{modalType}} bx--modal-header" role="banner">
22+
<h5 class="bx--modal-header__heading">
2323
<ng-content></ng-content>
2424
</h5>
25-
<button class="close--white-md" attr.aria-label="{{'MODAL.CLOSE' | translate}}" (click)="onClose()">
26-
<ibm-static-icon icon="x" classList="close_icon" size="sm"></ibm-static-icon>
25+
<button
26+
class="bx--modal-close"
27+
attr.aria-label="{{'MODAL.CLOSE' | translate}}"
28+
(click)="onClose()">
29+
<svg
30+
class="bx--modal-close__icon"
31+
fill-rule="evenodd"
32+
height="10"
33+
role="img"
34+
viewBox="0 0 10 10"
35+
width="10"
36+
aria-label="close the modal"
37+
alt="close the modal">
38+
<title>close the modal</title>
39+
<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>
40+
</svg>
2741
</button>
2842
</header>
2943
30-
`
44+
`,
45+
styleUrls: ["./../../node_modules/carbon-components/scss/components/modal/_modal.scss"]
3146
})
3247
export class ModalHeaderComponent {
3348
/**

src/modal/modal.component.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,8 @@ import { cycleTabs } from "./../common/tab.service";
8686
selector: "ibm-modal",
8787
template: `
8888
<ibm-overlay (overlaySelect)="overlaySelected.emit()">
89-
<div [ngClass]="{
90-
'modal--sm': size === 'sm',
91-
'modal': size === 'default' || size === 'md',
92-
'modal--lg': size === 'lg',
93-
'modal--xl': size === 'xl',
94-
'modal--xxl': size === 'xxl',
95-
'modal--warning': modalType === 'warning',
96-
'modal--error': modalType === 'error'
97-
}"
89+
<div
90+
class="bx--modal-container"
9891
[@modalState]="modalState"
9992
role="main"
10093
aria-modal="true"
@@ -107,17 +100,16 @@ import { cycleTabs } from "./../common/tab.service";
107100
`,
108101
animations: [
109102
trigger("modalState", [
110-
// state("in", style({opacity: 1, transform: "translate(0, 0)"})),
111103
state("void", style({transform: "translate(0, 5%)", opacity: 0})),
112104
transition(":enter", [
113105
animate("200ms ease-in"),
114106
]),
115107
transition(":leave", [
116-
// style({opacity: 1, transform: "translate(0, 0"}),
117108
animate(200, style({transform: "translate(0, 5%)", opacity: 0}))
118109
])
119110
])
120-
]
111+
],
112+
styleUrls: ["./../../node_modules/carbon-components/scss/components/modal/_modal.scss"]
121113
})
122114
export class ModalComponent implements OnInit, OnDestroy {
123115
/**
@@ -126,7 +118,7 @@ export class ModalComponent implements OnInit, OnDestroy {
126118
* @type {"sm" | "md" | "default" | "lg" | "xl" | "xxl"}
127119
* @memberof ModalComponent
128120
*/
129-
@Input() size = "xl";
121+
@Input() size = "default";
130122
/**
131123
* Classification of the modal.
132124
* @type {"default" | "warning" | "error"}

src/modal/modal.stories.ts

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import { storiesOf, moduleMetadata } from "@storybook/angular";
2+
import { withKnobs } from "@storybook/addon-knobs/angular";
3+
4+
import { TranslateModule } from "@ngx-translate/core";
5+
6+
import { ModalModule } from "../";
7+
import { Component, Injector } from "@angular/core";
8+
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
9+
import { Modal, ModalService } from "../";
10+
11+
@Modal()
12+
@Component({
13+
selector: "app-sample-modal",
14+
template: `
15+
<ibm-modal>
16+
<ibm-modal-header (closeSelect)="closeModal()">Header text</ibm-modal-header>
17+
<section class="bx--modal-content">
18+
<h1>Sample modal works.</h1>
19+
<p class="bx--modal-content__text">{{modalText}}</p>
20+
</section>
21+
<ibm-modal-footer>
22+
<button class="bx--btn bx--btn--primary" (click)="closeModal()">Close</button>
23+
</ibm-modal-footer>
24+
</ibm-modal>
25+
`,
26+
styleUrls: ["./../../node_modules/carbon-components/scss/components/modal/_modal.scss"]
27+
})
28+
class SampleModalComponent {
29+
modalText: string;
30+
constructor(private injector: Injector) {
31+
this.modalText = this.injector.get("modalText");
32+
}
33+
}
34+
35+
@Modal()
36+
@Component({
37+
selector: "app-modal-story",
38+
template: `
39+
<button class="bx--btn bx--btn--primary" (click)="openModal()">Open Modal</button>
40+
`,
41+
styleUrls: ["./../../node_modules/carbon-components/scss/components/button/_button.scss"]
42+
})
43+
class ModalStory {
44+
45+
constructor(private modalService: ModalService) { }
46+
47+
openModal() {
48+
this.modalService.create({
49+
component: SampleModalComponent,
50+
inputs: {
51+
modalText: "Hello, World!"
52+
}
53+
});
54+
}
55+
}
56+
57+
storiesOf("Modal", module)
58+
.addDecorator(
59+
moduleMetadata({
60+
declarations: [
61+
ModalStory,
62+
SampleModalComponent
63+
],
64+
imports: [
65+
ModalModule,
66+
BrowserAnimationsModule,
67+
TranslateModule.forRoot()
68+
],
69+
entryComponents: [
70+
SampleModalComponent
71+
]
72+
})
73+
)
74+
.addDecorator(withKnobs)
75+
.add("Basic", () => ({
76+
template: `
77+
<app-modal-story></app-modal-story>
78+
<ibm-modal-placeholder></ibm-modal-placeholder>
79+
`
80+
}));

src/modal/overlay.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ import {
1919
selector: "ibm-overlay",
2020
template: `
2121
<section
22-
class="modal-backdrop"
22+
class="bx--modal bx--modal-tall is-visible"
2323
(click)="overlayClick($event)"
24-
style="display:block;"
2524
#overlay>
2625
<ng-content></ng-content>
2726
</section>
28-
`
27+
`,
28+
styleUrls: ["./../../node_modules/carbon-components/scss/components/modal/_modal.scss"]
2929
})
3030
export class OverlayComponent {
3131
/**

0 commit comments

Comments
 (0)