Skip to content

Commit 8b40523

Browse files
committed
docs: nest textarea docs within 'input' components
Signed-off-by: Akshat Patel <akshat@live.ca>
1 parent ea02b92 commit 8b40523

File tree

5 files changed

+124
-44
lines changed

5 files changed

+124
-44
lines changed

src/input/input.stories.ts

Lines changed: 9 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
/* tslint:disable variable-name */
22

3-
import { moduleMetadata, Meta, Story } from "@storybook/angular";
4-
import { InputModule, Label } from "./";
3+
import { moduleMetadata, Meta } from "@storybook/angular";
4+
import { InputModule, TextInputLabelComponent } from "./";
55

66
export default {
77
title: "Components/Input",
88
decorators: [
99
moduleMetadata({
1010
imports: [InputModule]
1111
})
12-
]
12+
],
13+
component: TextInputLabelComponent
1314
} as Meta;
1415

15-
const Template: Story<Label> = (args) => ({
16+
const Template = (args) => ({
1617
props: args,
1718
template: `
18-
<cds-label
19+
<cds-text-label
1920
[helperText]="helperText"
2021
[invalid]="invalid"
2122
[invalidText]="invalidText"
@@ -32,7 +33,7 @@ const Template: Story<Label> = (args) => ({
3233
[theme]="theme"
3334
[placeholder]="placeholder"
3435
[autocomplete]="autocomplete">
35-
</cds-label>
36+
</cds-text-label>
3637
`
3738
});
3839
export const Basic = Template.bind({});
@@ -61,53 +62,18 @@ Basic.argTypes = {
6162
options: ["sm", "md", "lg"],
6263
defaultValue: "md",
6364
contorl: "select"
64-
},
65-
component: Label
65+
}
6666
};
6767

68-
const TextareaTemplate: Story<Label> = (args) => ({
69-
props: args,
70-
template: `
71-
<cds-label
72-
[helperText]="helperText"
73-
[invalid]="invalid"
74-
[disabled]="disabled"
75-
[invalidText]="invalidText">
76-
{{label}}
77-
<textarea
78-
cdsTextArea
79-
[placeholder]="placeholder"
80-
[invalid]="invalid"
81-
[disabled]="disabled"
82-
[theme]="theme"
83-
[rows]="rows"
84-
[cols]="cols"
85-
aria-label="textarea"></textarea>
86-
</cds-label>
87-
`
88-
});
89-
export const TextArea = TextareaTemplate.bind({});
90-
TextArea.args = {
91-
...Basic.args,
92-
cols: 50,
93-
rows: 4
94-
};
95-
TextArea.argTypes = {
96-
...Basic.argTypes
97-
};
9868

99-
const SkeletonTemplate: Story<Label> = (args) => ({
69+
const SkeletonTemplate = (args) => ({
10070
props: args,
10171
template: `
10272
<cds-label skeleton="true">
10373
<input cdsText skeleton="true">
10474
</cds-label>
10575
<br>
10676
<input cdsText skeleton="true">
107-
<br><br>
108-
<cds-label skeleton="true">
109-
<div cdsTextArea skeleton="true"></div>
110-
</cds-label>
11177
`
11278
});
11379
export const Skeleton = SkeletonTemplate.bind({});

src/input/label.component.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ import { TextArea } from "./text-area.directive";
1515
import { TextInput } from "./input.directive";
1616

1717
/**
18-
* [See demo](../../?path=/story/components-input--label)
18+
* Get started with importing the module:
19+
*
20+
* ```typescript
21+
* import { InputModule } from 'carbon-components-angular';
22+
* ```
1923
*
2024
* To prevent attribute drilling, use `ibm-text-label` or `ibm-textarea-label` components
2125
*
@@ -25,6 +29,8 @@ import { TextInput } from "./input.directive";
2529
* <input cdsText type="text" class="input-field">
2630
* </cds-label>
2731
* ```
32+
*
33+
* [See demo](../../?path=/story/components-input--basic)
2834
*/
2935
@Component({
3036
selector: "cds-label, ibm-label",

src/input/text-input-label.component.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,22 @@ import {
99
ChangeDetectorRef
1010
} from "@angular/core";
1111

12+
/**
13+
* Get started with importing the module:
14+
*
15+
* ```typescript
16+
* import { InputModule } from 'carbon-components-angular';
17+
* ```
18+
*
19+
* ```html
20+
* <cds-text-label>
21+
* Label
22+
* <input cdsText type="text" class="input-field">
23+
* </cds-text-label>
24+
* ```
25+
*
26+
* [See demo](../../?path=/story/components-input--basic)
27+
*/
1228
@Component({
1329
selector: "cds-text-label, ibm-text-label",
1430
template: `

src/input/textarea-label.component.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,22 @@ import {
1212

1313
import { TextArea } from "./text-area.directive";
1414

15+
/**
16+
* Get started with importing the module:
17+
*
18+
* ```typescript
19+
* import { InputModule } from 'carbon-components-angular';
20+
* ```
21+
*
22+
* ```html
23+
* <cds-textarea-label>
24+
* Label
25+
* <textarea cdsTextArea class="textarea-field">
26+
* </cds-textarea-label>
27+
* ```
28+
*
29+
* [See demo](../../?path=/story/components-input-text-area--basic)
30+
*/
1531
@Component({
1632
selector: "cds-textarea-label, ibm-textarea-label",
1733
template: `

src/input/textarea.stories.ts

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/* tslint:disable variable-name */
2+
3+
import { moduleMetadata, Meta } from "@storybook/angular";
4+
import { InputModule, TextareaLabelComponent } from "./";
5+
6+
export default {
7+
title: "Components/Input/Text area",
8+
decorators: [
9+
moduleMetadata({
10+
imports: [InputModule]
11+
})
12+
],
13+
component: TextareaLabelComponent
14+
} as Meta;
15+
16+
const Template = (args) => ({
17+
props: args,
18+
template: `
19+
<cds-textarea-label
20+
[helperText]="helperText"
21+
[invalid]="invalid"
22+
[disabled]="disabled"
23+
[invalidText]="invalidText">
24+
{{label}}
25+
<textarea
26+
cdsTextArea
27+
[placeholder]="placeholder"
28+
[invalid]="invalid"
29+
[disabled]="disabled"
30+
[theme]="theme"
31+
[rows]="rows"
32+
[cols]="cols"
33+
aria-label="textarea"></textarea>
34+
</cds-textarea-label>
35+
`
36+
});
37+
export const Basic = Template.bind({});
38+
Basic.args = {
39+
disabled: false,
40+
invalid: false,
41+
invalidText: "Invalid entry",
42+
warn: false,
43+
warnText: "This is a warning!",
44+
label: "Text input label",
45+
helperText: "Optional helper text",
46+
placeholder: "Placeholder",
47+
cols: 50,
48+
rows: 4
49+
};
50+
Basic.argTypes = {
51+
autocomplete: {
52+
options: ["on", "off"],
53+
defaultValue: "on",
54+
control: "radio"
55+
},
56+
theme: {
57+
options: ["light", "dark"],
58+
defaultValue: "dark",
59+
control: "radio"
60+
},
61+
size: {
62+
options: ["sm", "md", "lg"],
63+
defaultValue: "md",
64+
contorl: "select"
65+
}
66+
};
67+
68+
const SkeletonTemplate = (args) => ({
69+
props: args,
70+
template: `
71+
<cds-textarea-label skeleton="true">
72+
<div cdsTextArea skeleton="true"></div>
73+
</cds-textarea-label>
74+
`
75+
});
76+
export const Skeleton = SkeletonTemplate.bind({});

0 commit comments

Comments
 (0)