Skip to content

Commit 50e02ce

Browse files
authored
Merge pull request #215 from panpan-lin/issue-163-light-style-input
Add light style to Input Component
2 parents 9cede02 + 8439b9a commit 50e02ce

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

src/input/input.directive.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Directive, HostBinding } from "@angular/core";
1+
import { Directive, HostBinding, Input } from "@angular/core";
22

33
/**
44
* A directive for applying styling to an input element.
@@ -15,5 +15,13 @@ import { Directive, HostBinding } from "@angular/core";
1515
selector: "[ibmText]"
1616
})
1717
export class TextInput {
18+
/**
19+
* `light` or `dark` input theme
20+
*/
21+
@Input() theme: "light" | "dark" = "dark";
22+
1823
@HostBinding("class.bx--text-input") inputClass = true;
24+
@HostBinding("class.bx--text-input--light") get isLightTheme() {
25+
return this.theme === "light";
26+
}
1927
}

src/input/input.stories.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { storiesOf, moduleMetadata } from "@storybook/angular";
22
import { action } from "@storybook/addon-actions";
3-
import { withKnobs, boolean } from "@storybook/addon-knobs/angular";
3+
import { withKnobs } from "@storybook/addon-knobs/angular";
44

55
import { InputModule } from "../";
66

@@ -22,8 +22,19 @@ storiesOf("Input", module).addDecorator(
2222
template: `
2323
<input ibmText aria-label="input" placeholder="Optional placeholder text"/>
2424
`
25-
})).add("TextArea", () => ({
25+
}))
26+
.add("Light Input", () => ({
27+
template: `
28+
<input ibmText theme="light" aria-label="input" placeholder="Optional placeholder text"/>
29+
`
30+
}))
31+
.add("TextArea", () => ({
2632
template: `
2733
<textarea ibmTextArea aria-label="textarea" placeholder="Optional placeholder text" rows="4" cols="50"></textarea>
2834
`
35+
}))
36+
.add("Light TextArea", () => ({
37+
template: `
38+
<textarea ibmTextArea theme="light" aria-label="textarea" placeholder="Optional placeholder text" rows="4" cols="50"></textarea>
39+
`
2940
}));

src/input/text-area.directive.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Directive, HostBinding } from "@angular/core";
1+
import { Directive, HostBinding, Input } from "@angular/core";
22

33
/**
44
* A directive for applying styling to a textarea element.
@@ -15,5 +15,13 @@ import { Directive, HostBinding } from "@angular/core";
1515
selector: "[ibmTextArea]"
1616
})
1717
export class TextArea {
18+
/**
19+
* `light` or `dark` input theme
20+
*/
21+
@Input() theme: "light" | "dark" = "dark";
22+
1823
@HostBinding("class.bx--text-area") baseClass = true;
24+
@HostBinding("class.bx--text-area--light") get isLightTheme() {
25+
return this.theme === "light";
26+
}
1927
}

0 commit comments

Comments
 (0)