Skip to content

Commit fd1e816

Browse files
committed
refactor(forms): move form related components to seperate modules
1 parent 7d4723c commit fd1e816

19 files changed

+222
-86
lines changed

src/checkbox/checkbox.module.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// modules
2+
import { NgModule } from "@angular/core";
3+
import { FormsModule } from "@angular/forms";
4+
import { CommonModule } from "@angular/common";
5+
6+
// imports
7+
import { CheckboxComponent } from "./checkbox.component";
8+
9+
// exports
10+
export { CheckboxComponent } from "./checkbox.component";
11+
12+
@NgModule({
13+
declarations: [
14+
CheckboxComponent,
15+
],
16+
exports: [
17+
CheckboxComponent,
18+
],
19+
imports: [
20+
CommonModule,
21+
FormsModule
22+
]
23+
})
24+
export class CheckboxModule { }

src/checkbox/checkbox.stories.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { storiesOf, moduleMetadata } from "@storybook/angular";
2+
import { action } from "@storybook/addon-actions";
3+
import { withKnobs, boolean } from "@storybook/addon-knobs/angular";
4+
5+
import { CheckboxModule } from "../";
6+
7+
storiesOf("Checkbox", module).addDecorator(
8+
moduleMetadata({
9+
imports: [CheckboxModule]
10+
})
11+
)
12+
.addDecorator(withKnobs)
13+
.add("Basic", () => ({
14+
template: `
15+
<ibm-checkbox
16+
[checked]="checked"
17+
[disabled]="disabled"
18+
[indeterminate]="indeterminate"
19+
(change)="onChange($event)"
20+
(indeterminateChange)="onIndeterminateChange($event)">
21+
Checkbox
22+
</ibm-checkbox>
23+
`,
24+
props: {
25+
checked: boolean("checked", false),
26+
disabled: boolean("disabled", false),
27+
indeterminate: boolean("indeterminate", false),
28+
onChange: action("Change fired!"),
29+
onIndeterminateChange: action("Indeterminate change fired!")
30+
}
31+
}));

src/forms/forms.module.ts

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,37 @@
22
import { NgModule } from "@angular/core";
33
import { FormsModule } from "@angular/forms";
44
import { CommonModule } from "@angular/common";
5-
import { StaticIconModule } from "./../icon/static-icon.module";
65

76
// imports
8-
import { CheckboxComponent } from "./checkbox.component";
9-
import { SwitchComponent } from "./switch.component";
10-
import { RadioComponent, RadioGroup } from "./radio.component";
11-
import { LabelComponent } from "./label.component";
7+
import { CheckboxModule } from "../checkbox/checkbox.module";
8+
import { SwitchModule } from "../switch/switch.module";
9+
import { RadioModule } from "../radio/radio.module";
10+
import { InputModule } from "../input/input.module";
11+
import { ButtonModule } from "../button/button.module";
1212

1313
// exports
14-
export { CheckboxComponent } from "./checkbox.component";
15-
export { SwitchComponent } from "./switch.component";
16-
export { RadioComponent, RadioGroup } from "./radio.component";
17-
export { LabelComponent } from "./label.component";
14+
export { CheckboxModule } from "../checkbox/checkbox.module";
15+
export { SwitchModule } from "../switch/switch.module";
16+
export { RadioModule } from "../radio/radio.module";
17+
export { InputModule } from "../input/input.module";
18+
export { ButtonModule } from "../button/button.module";
1819

1920
@NgModule({
20-
declarations: [
21-
CheckboxComponent,
22-
SwitchComponent,
23-
RadioComponent,
24-
RadioGroup,
25-
LabelComponent
26-
],
2721
exports: [
28-
CheckboxComponent,
29-
SwitchComponent,
30-
RadioComponent,
31-
RadioGroup,
32-
LabelComponent
22+
CheckboxModule,
23+
SwitchModule,
24+
RadioModule,
25+
InputModule,
26+
ButtonModule
3327
],
3428
imports: [
3529
CommonModule,
3630
FormsModule,
37-
StaticIconModule
31+
CheckboxModule,
32+
SwitchModule,
33+
RadioModule,
34+
InputModule,
35+
ButtonModule
3836
]
3937
})
4038
export class NFormsModule { }

src/forms/forms.stories.ts

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

src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ export * from "./utils/position";
1515
export * from "./content-switcher/content-switcher.module";
1616
export * from "./accordion/accordion.module";
1717
export * from "./button/button.module";
18+
export * from "./checkbox/checkbox.module";
19+
export * from "./switch/switch.module";
20+
export * from "./radio/radio.module";
21+
export * from "./input/input.module";

src/input/input.module.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// modules
2+
import { NgModule } from "@angular/core";
3+
import { FormsModule } from "@angular/forms";
4+
import { CommonModule } from "@angular/common";
5+
6+
// imports
7+
import { LabelComponent } from "../input/label.component";
8+
9+
// exports
10+
export { LabelComponent } from "../input/label.component";
11+
12+
@NgModule({
13+
declarations: [
14+
LabelComponent
15+
],
16+
exports: [
17+
LabelComponent
18+
],
19+
imports: [
20+
CommonModule,
21+
FormsModule,
22+
]
23+
})
24+
export class InputModule { }

src/input/input.stories.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { storiesOf, moduleMetadata } from "@storybook/angular";
2+
import { action } from "@storybook/addon-actions";
3+
import { withKnobs, boolean } from "@storybook/addon-knobs/angular";
4+
5+
import { InputModule } from "../";
6+
7+
storiesOf("Input", module).addDecorator(
8+
moduleMetadata({
9+
imports: [InputModule]
10+
})
11+
)
12+
.addDecorator(withKnobs)
13+
.add("Label", () => ({
14+
template: `
15+
<ibm-label>
16+
Some Title
17+
<input type="text" class="bx--text-input" placeholder="Optional placeholder text">
18+
</ibm-label>
19+
`
20+
}));
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
22
import { ComponentFixture, TestBed, fakeAsync, tick, async } from "@angular/core/testing";
33
import { By } from "@angular/platform-browser";
44
import { DebugElement } from "@angular/core";
5-
import { StaticIconModule } from "./../icon/static-icon.module";
5+
import { StaticIconModule } from "../icon/static-icon.module";
66

77
import { LabelComponent } from "./label.component";
88

0 commit comments

Comments
 (0)